Parcel 2: @parcel/transformer-babel: Support for the experimental syntax 'optionalChaining' isn't currently enabled:
See original GitHub issue🐛 bug report
When trying to use a babel proposal, e.g optional chaining, Parcel 2 throws an error
🎛 Configuration (.babelrc, package.json, cli command)
.babelrc
{
"plugins": [
"@babel/plugin-proposal-optional-chaining"
]
}
{
"private": true,
"name": "web",
"version": "1.0.0",
"main": "index.js",
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
"parcel": "^2.0.0-alpha.3.2"
},
"scripts": {
"dev": "parcel src/index.html"
},
"browserslist": [
"last 1 Chrome versions"
]
}
🤔 Expected Behavior
Parcel should use the current babelrc config
😯 Current Behavior
Parcel throws
× @parcel/transformer-babel: Support for the experimental syntax 'optionalChaining' isn't currently enabled
💻 Code Sample
const foo = undefined?.bar
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Support for the experimental syntax 'optionalChaining' isn't ...
At the time of writing, optional chaining might not work in NUXT project with node > 12, try using the current LTS version...
Read more >@parcel/transformer-babel | Yarn - Package Manager
This Parcel transformer plugin is responsible for transforming assets with Babel. It uses @babel/core to resolve babel config the same way Babel does...
Read more >this experimental syntax requires enabling the parser plugin
If you are talking about Parcel.js, you need to install and configure some Babel plugins, to enable Class Private Properties and Methods:.
Read more >babel/plugin-transform-typescript
This plugin adds support for the types syntax used by the TypeScript programming ... supports certain JavaScript proposals such as optional chaining (...
Read more >Enable Optional Chaining in TypeScript - SuperTommy.com
TypeScript added optional chaining in version 3.7 that should just work but ... Support for the experimental syntax 'optionalChaining' isn't ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have a similar problem, when using parcel v2 alpha3 with a TypeScript file, the optional chaining operator also raises the error above. I think TypeScript files compiled by
tsc
does not emit an optional chaining operator.The babelrc isn’t used because this to babel https://github.com/parcel-bundler/parcel/blob/92fd22f262eb6f301bfd00769066a8f6fb2ef1e4/packages/transformers/babel/src/config.js#L36-L40 doesn’t find it.
cc @padmaia might have more insight into the babel config resolution.
To explicitly allow them with
babelrcRoots
: