-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Optional chaining not transpiled for node/FastBoot #19353
Comments
@simonihmig when I run "browserslist": [
"current node"
] In node 14.15.1 I believe the correct selector for all maintained node versions is: "browserslist": [
"maintained node versions"
], I'm also not sure about how this translates to the |
Well, whether that's right or not, but I assume that
I read their docs in a way that you can have a See https://babeljs.io/docs/en/babel-preset-env#targetsnode. Fwiw, there was a (merged) PR for |
mmk, dug in, the issue is that we use a pre-built version of Ember only for development builds. The reason we do this is so that compiling Ember does not affect the DX as much - it's a decently long compilation process, and when we started doing dynamic compilation we decided to use a prebuild version to avoid a regression. The issue is that the logic currently only takes into account the From this perspective, the To be honest, the double-layered setting that module.exports = [
...browsers,
'maintained node versions'
]; I think this would be a better set of defaults in the future, that way we would just be using |
To fix this bug as is, I think the steps are:
I don't think I'll have time to implement this in the near future, but am happy to help advise and review PRs! |
As suggested in emberjs/ember.js#19353 (comment)
I can confirm this fixes the problem! And yes, that Babel config is quite confusing: added Thanks for the super quick investigation! 🙏 |
Hey folks 👋 I am here to help get this fixed ASAP if y'all don't mind giving me a bit of guidance. This is causing a bit of pain for the whole Empress ecosystem since this line was added to Ember https://github.com/emberjs/ember.js/blob/v3.24.0/packages/%40ember/-internals/runtime/lib/mixins/array.js#L1350 and I can confirm what you say @pzuraq , this is only affecting development. Regarding
I know it's a bigger question to move over to using the recommended structure but that explains why it seems so complicated. It might also complicate the recommended solution to this if we want to follow the "proper" way of doing this 🤔 I'll put together my best guess at a PR now and we can use that as a discussion point 👍 |
Also I think you might have a slight misunderstanding of what
I think if we are pre-building using CI with is set to the oldest LTS (Node 10) then I think we're good 👍 |
It turns out that actually trying to effectively pre-build this wasn't going to be easy 🤔 especially with the issues around what "node: current" actually means. I have confirmed that my PR works and to be honest I don't really see that much of an impact on build time so if you're happy with it @pzuraq then I think we can go ahead with it 🎉 |
Fixed by #19397 |
To add to this, while defining the targets in anyway supported by I just realized that I caused a regression in the deployment setup by this, as |
🐞 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 andtargets.js
updated for node.Make sure you are using node 10 (pinned for
volta
), then runyarn 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:
🤔 Expected Behavior
Correct transpilation for node 10.
🌍 Environment
➕ 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 thenode
config option?The text was updated successfully, but these errors were encountered: