-
-
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
upgrading to react-script 3.3.1 breaks optional chaining #8445
Comments
@ggascoigne I encountered the same problem when upgrading to 3.3.1. I was able to resolve the issue and stay on 3.3.1 by deleting my node_modules folder and reinstalling my dependencies. I don't understand the underlying issue but sharing this info in case it helps others. |
Removing ESLint complains about PS: Disabling |
@lnhrdt removing node_modules works for me. Thanks. |
Same issue here. Removing node_modules did not help. We're ejected, though, so I added @babel/plugin-proposal-nullish-coalescing-operator to our .babelrc file myself, then it started working again. |
Removing node_modules did not work for me. Our project is not ejected. |
This issue is still present on 3.4.0. |
Looking at the diff of 3.3.0 vs. 3.3.1, I'm guessing that #8353 (FYI @ianschmitz) may be the culprit because it removed the babel plugins for optional chaining, null coalescing, and dynamic import. To verify that this was the culprit, I manually added the optional chaining and null-coalescing babel plugins to CRA 3.4.0 using customize-cra. When I did this, Until this is fixed, here's workaround instructions that worked for me for those two operators:
// .babelrc
{
"plugins": [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator"
]
} FYI: I couldn't get customize-cra's |
@justingrant would you be able to upload your lock file here by chance? |
@ianschmitz - Sure, here's my package-lock.json: https://gist.github.com/justingrant/cb9b3c088f90abd8382141ebe608f141 In case it's helpful, here's my package.json too (with private stuff removed): https://gist.github.com/justingrant/194b21ccea3510ee8ef972c0cd9d8ca4 FWIW, I tried rebuilding my node_modules and that didn't fix the problem. I get the same problem on 3.3.1 and 3.4.0. Also, while researching this problem I found a similar issue in the webpack repo: webpack/webpack#10227. I'm not sure if this is the same root cause because that issue uses ts-loader for typescript but my app uses babel. But at least wanted to capture it here to save others some Googling in case it's related. That repro seems to depend on "browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version"
]
} Here's two other issues which I came across which also might be (or might not be!) related to this issue: |
Interesting! Can you try updating your browserslist dev settings to include |
I think i've tracked down the source of the issue. It looks like we will require acornjs/acorn#890 and acornjs/acorn#891 to be merged and included by webpack before we can fully delegate the decision to transform optional chaining and nullish coalescing to browserslist completely. This syntax isn't yet understood by acorn which webpack uses to parse the source. I'll test this more later to confirm when i get the time. Assuming the above is the case, we will add the plugins back in the next patch release until we get a newer version of webpack that will support the syntax. Until then a quick fix could be to update your browserslist config to include |
@ianschmitz - Sorry for delayed response. Looks like you already identified the root cause. Do you still need me to test Also, where does the babel cache live? Can I just delete it, instead of all of node_modules? I'd love to avoid re-creating node_modules every time I want to change my |
It should live at I haven't had a chance to verify this in-depth, so would appreciate to get additional verification from you folks before we restore the plugins. Thanks! 😄 |
Confirmed in our end that removing |
@ianschmitz - I can confirm that adding |
I can confirm it. Same as @justingrant did |
Perfect. Thanks everyone. Will have a PR fix up shortly. |
Since upgrading to react-scripts 3.3.1 my code, which uses optional chaining, fails to compile.
The text was updated successfully, but these errors were encountered: