You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERROR in ./index.js 2:11
Module parse failed: Unexpected token (2:11)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| class Foo {
> property = true;
| }
Expected behavior:
code compiles with no issue
using @babel/preset-env and shippedProposals: true so class properties should be loaded with no issue
Environment
Babel version: 7.23.9
Node version: 18.17.0
npm version: 9.8.1
OS: 13.0
webpack version: 4.47.0
Possible solution
I found #11796 which seems very similar. Except that was an issue with how @babel/preset-env was being included/configured. I seem to be configuring it properly.
The docs for @babel/plugin-transform-class-properties say that This plugin is included in @babel/preset-env, in ES2022.
This is my list of targets that .browserslistrc compiles to:
Hey @arasmussen! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
All your targets support class fields, so Babel is not compiling them. Then, you are using an old version of webpack that throws when it sees class fields. I suggest either updating webpack, or changing your targets to that Babel compiles class fields.
I'd like to support using webpack as a target to compute which features to compile in the future, but we don't support it yet: #14963
馃捇
How are you using Babel?
babel-loader (webpack)
Input code
I created a very simple repo here: https://github.com/arasmussen/babel-repro
Configuration file name
No response
Configuration
Current and expected behavior
Source file:
Current behavior:
Expected behavior:
Environment
Possible solution
I found #11796 which seems very similar. Except that was an issue with how @babel/preset-env was being included/configured. I seem to be configuring it properly.
The docs for
@babel/plugin-transform-class-properties
say thatThis plugin is included in @babel/preset-env, in ES2022
.This is my list of targets that .browserslistrc compiles to:
All of these browsers appear to support ES2022. Any help would be greatly appreciated, thank you.
Additional context
No response
The text was updated successfully, but these errors were encountered: