-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Nullish assignment (??=) not working in new project #9908
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
Comments
This is possibly now resolved. |
i still get this error with [email protected] installed... i'm interested in tips if anyone has working? i have craco installed already so went looking for how to enable this in babel and tried simply including module.exports = {
babel: {
plugins: [
"@babel/plugin-proposal-logical-assignment-operators"
],
}
} |
Bump: still present in 4.0.1. I think an upgrade to babel-loader would fix this. |
We were able to temporarily solve this issue by using module.exports = {
webpack: (config, env) => {
const rules = config.module.rules.find(rule => !!rule.oneOf).oneOf;
const babelLoaderRule = rules.find(rule => rule.loader.includes('babel-loader'));
babelLoaderRule.options.plugins.push('@babel/plugin-proposal-logical-assignment-operators');
return config;
},
}; The config may vary, so you may want to do |
thanks for encouraging me to retry @pandomic... i can confirm corresponding craco config above does work as well fyi, those previous errors mentioned were from a different issue - additional eslintConfig required after upgrading from react-scripts 3.4.3 to 4 |
Still present in 4.0.1 |
Confirmed to not work on none typescript projects as well. |
This error was being reported to me but for another reason, just in-case anyone is having the same issue. It was due to my IDE auto-importing in a foolish way. It set the path to outside of the src directory and then reached back-in. // import { sectionTheme } from '../../src/components/chakra/section'; // The auto-import that broke things
import { sectionTheme } from '../components/chakra/section'; // replaced with this I suspect maybe the CRA config runs things through a different loader in they're not under src maybe so it didn't run the correct ts loader. |
I got the same issue when I try to import my package to CRA project ./node_modules/@trakas/react/es/hooks/useLocalStorage.js 6:56
Module parse failed: Unexpected token (6:56)
File was processed with these loaders:
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| try {
| const valueInString = localStorage.getItem(key);
> return valueInString ? JSON.parse(valueInString) ?? initialValue : initialValue;
| } catch {
| return initialValue; |
I have been having this problem when I deleted my package-lock.json in a non-create-react-app project, my suspicions so far are:
|
My PR #10832 should fix this issue. We have to wait for review. |
Reporting a similar error with
|
Nice, It's working for me.
|
im getting a similiar im using next.js
|
I'm having the same issue as @JulienMartel. Are there any updates on the resolution of this? |
@JulienMartel @kandipierre |
yes I added this manually and it fixed my issue. Thanks @weiliang903. |
Out of nowhere, a coworker's codebase started complaining over It seems related to a recently merged PR where I used NPM v7 by accident (on another machine) and it mixed up lock files... But even though I even made a fresh clone, and it wasn't working either. I even compared both
|
Ok, now I really woundered. It must be explained as a dark magic and nothing else. My CRA project just worked fine about 10 minutes ago, but after a subsequent "Save All" in IDE the project became display the syntax error described in this Issue to any first occurrence of The real mystic is that both success and error states was encountered in the same However, I've already tried I don't believe in magic. But what else could cause this stupid situation when nothing was changed and it switched from success to error in same NodeJS: 14.16.0 |
I'm not sure, whether the following attempts are correct at all, however I tried the following and it did not help:
|
I did upgrade |
The irony of |
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. |
Adding my 👍 to remove the stale label. It seems like #10832 would fix this issue, but it's awaiting review. |
Typescript 4 supports the nullish assignment operator (??=). Creating a new Typescript project with CRA 4 supports this operator in the editor, but when running
yarn start
it gives a Webpack parsing error.I asked on SO here and they confirm the bug and suggest it requires a Babel upgrade.
Steps to reproduce:
yarn start
Expected result:
App starts
Actual result:
The text was updated successfully, but these errors were encountered: