-
Notifications
You must be signed in to change notification settings - Fork 916
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] webpack plugin does not resolve the ??
/ nullish coalescing operator
#3303
Comments
??
/ nullish coalescing operator??
/ nullish coalescing operator
I had a same kind of issue - "Unexpected token". My problem's reason was optional chaining operator.
I tried a several setups but no use. I solved by adding webpack babel-loader directly in snowpack.config.js plugins: [
[
'@snowpack/plugin-webpack',
{
extendConfig: (config) => {
config.module.rules.push({
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
targets: '> 0.25%, not dead',
plugins: [
['@babel/plugin-transform-runtime', { regenerator: true }], // some packages could require this plugin
],
},
},
});
return config;
},
},
],
], I expect this issue resolved by snowpack or @snowpack/plugin-webpack itself. |
I faced the same issue a couple days ago and managed to fix it by adding the following in my "browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"],
"development": ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
}, That browserlist is directly copied from CRA initial setup and seems to work without any issue so far. I can only guess that the browserlist configuration of the plugin ( |
Note, Webpack 4 does not support the I'm not sure what version of webpack you're using, but that might be something you could check. |
Closing this issue in favor of @Kcazer 's answer. It works :D |
Bug Report Quick Checklist
Describe the bug
Webpack plugin cannot resolve the
??
/ nullish coalescing operator.Sample error:
To Reproduce
npm init snowpack-app --template @snowpack/app-template-typescript
const demo = undefined ?? true;
in any line insrc/App.tsx
or in any file.npx snowpack build
Expected behavior
Webpack plugin should resolve the nullish coalescing operator, or snowpack itself.
edit: the only workaround that I could find to resolve this issue is to replace all
??
to||
/ logical OR operator.The text was updated successfully, but these errors were encountered: