-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
🐞 Describe the Bug
The Ember code base contains instances of optional chaining, in this case it' about this line. Although targets have been properly defined (node: 'current'), when running a fresh new app with FastBoot in node 10, this does not get transpiled as expected, and FastBoot throws.
🔬 Minimal Reproduction
Here is a reproduction: https://github.com/simonihmig/ember-transpilation-reproduction. This is basically a fresh new 3.24 app, with ember-cli-fastboot installed and targets.js updated for node.
Make sure you are using node 10 (pinned for volta), then run yarn start to see the FastBoot error
😕 Actual Behavior
Optional chaining should get transpiled for node 10, which does not support it. But it does not, and node 10 throws this when running the app in FastBoot:
/var/folders/q3/yzggf_l965zbzps_bk8xr37c0000gn/T/broccoli-12464N2d65poMnE2Z/out-170-append_ember_auto_import_analyzer/assets/vendor.js:26317
this.forEach(item => ret.push(item[methodName]?.(...args)));
^
SyntaxError: Unexpected token .
at new Script (vm.js:83:7)
at VMSandbox.eval (/Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/vm-sandbox.js:13:22)
at /Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/ember-app.js:190:15
at Array.forEach (<anonymous>)
at EmberApp.loadAppFiles (/Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/ember-app.js:187:21)
at EmberApp.retrieveSandboxedApp (/Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/ember-app.js:235:10)
at new EmberApp (/Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/ember-app.js:61:21)
at FastBoot._buildEmberApp (/Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/index.js:114:17)
at new FastBoot (/Users/simonihmig/Projects/test-addon/node_modules/fastboot/src/index.js:52:10)
at app.use (/Users/simonihmig/Projects/test-addon/node_modules/ember-cli-fastboot/index.js:335:29)
🤔 Expected Behavior
Correct transpilation for node 10.
🌍 Environment
- Ember: 3.24
- Node.js/npm: 10
➕ Additional Context
If you run CI=true yarn start instead - enabling transpilation for IE11 - the optional chaining does get transpiled as expected!
Opening this issue here, as the default DX of a fresh Ember app w/ FastBoot is affected. But the root cause could of course lie elsewhere. Maybe @babel/preset-env is somehow now working correctly with the node config option?