-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Impossible to adopt new JavaScript features #11339
Comments
I’m on a vacation but a few quick thoughts: Does it help to specify the However mrdoob/three.js#22437 (comment) doesn’t quite make sense to me. If you look at the build error, it’s webpack parser choking on the new syntax. Which means Babel has not compiled it. So the env preset actually looks like it “worked” — it did not try to compile anything — but webpack later choked on it because of an older parser or maybe lack of some option. So maybe it’s worth checking the reverse: does it help to set the browserslist to include older browsers. Thereby forcing Babel to compile private fields to a polyfill. Not quite what you wanted but if this works, at least it should prevent webpack from choking on the syntax it doesn’t know about. The actual fix on our side is likely to update webpack to a version that uses a parser which supports this syntax. It needs to be investigated which version is the minimal one with that support. To sum up:
I’m not actively working on this (and I’m on a vacation) but hopefully this provides pointers. |
Issue on the webpack repo: webpack/webpack#10216 |
Is it stage 4 already? |
@gaearon let me know if I can be of any help - since it's my comment. The project did indeed fail to build on latest CRA, but compiled when I ejected the config and added latest babel-preset-env manually to |
I think the issue is related to the CRA webpack config. CRA does a lesser processing through Babel for dependencies than it does for application code. I can create a new app and use a private field without issue, however in the same app I cannot use Webpack doesn't appear to add support for class fields until 5.36.0ish. (Didn't check if this includes private fields or not.)
Related links. create-react-app/packages/react-scripts/config/webpack.config.js Lines 389 to 479 in b45ae3c
CRA plugins for dependencies. create-react-app/packages/babel-preset-react-app/dependencies.js Lines 95 to 141 in b45ae3c
CRA plugins for application code. create-react-app/packages/babel-preset-react-app/create.js Lines 104 to 210 in b45ae3c
Webpack Class Fields PR |
I think this belongs to a much larger discussion and is more related to #11180. Bundlers need to be updated regularly. That's the main thing. |
Hi, forgive my question but I don't understand if we have a solution to this issue? I can't make the
Add the following code to test the lib in
When I do The compiler tells me to How can I fix this issue? Thanks. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
We recently tried to adopt private class fields in three.js after we realised that even Safari iOS had added support for them.
Turns out we can no longer use caniuse to know if we can adopt new JavaScript features. Bundlers and tools like create react app are behind browsers.
More info: mrdoob/three.js#22437
The text was updated successfully, but these errors were encountered: