babel: Compilation error "Support for the experimental syntax 'classProperties' isn't currently enabled" despite having the plugin installed when using linked packages
Bug Report
Current Behavior
I have the following tree (simplified)
-/test
--.babelrc
--some-test-file.js
-.babelrc
-some-file.js
If I run babel through cli in /, it compiles flawlessly.
Here’s the catch: / is a linked package, which /test, another project (test suite for said package), is using (uncompiled version of it, so I wouldn’t have to worry about hot module reloading).
Now, both / and /test have @babel/plugin-proposal-class-properties in their .babelrc configs.
When I run Webpack in test suite, I get the following error on a file from / package:
ERROR in ../src/Page.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Users\wojte\Projekty\react-pdf\src\Page.jsx: Support for the experimental syntax 'classProperties' isn't currently enabled (38:9):
Input Code
-
REPL or Repo link if applicable:
- Clone: https://github.com/wojtekmaj/react-pdf/tree/babel-7
yarncd testyarnyarn start
Please note that master branch runs on Babel 6. I did not have this issue before. It’s stopping me from doing the upgrade.
Expected behavior/code A clear and concise description of what you expected to happen (or code).
Babel should have read .babelrc from / package and use it for parsing the file from /.
Babel Configuration (.babelrc, package.json, cli command)
// `.babelrc in `/`
{
"presets": [
"@babel/env",
"@babel/react"
],
"plugins": [
"@babel/transform-runtime",
"@babel/proposal-class-properties"
]
}
// `.babelrc in `/test`
{
"presets": [
[
"@babel/env",
{
"modules": false
}
],
"@babel/react"
],
"plugins": [
"@babel/transform-runtime",
"@babel/proposal-class-properties"
]
}
Environment
- Babel version(s): 7.0.0
- Node/npm version: 10.4.0/6.4.1
- OS: Windows 10
- Monorepo: ?
- How you are using Babel:
loader
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 17 (11 by maintainers)
That didn’t work. I think that your initial suggestion that
babel-loadersimply does not run is not true, as the error comes frombabel-loaderand the file that should be loaded by it.babel, or babel-loader simply does not recognize which
.babelrcto use and uses none. Why do I think so? We’re getting this error:and it just happens that both
/.babelrcand/test/.babelrccontain"@babel/proposal-class-properties"in"plugins"section!At the end of the error I quoted above, there’s this stack:
so it looks like Babel properly resolved the symlink path. This gave me an idea that maybe
babelRcRootsshould have also been resolved:and tada! It worked.
But I still think I shouldn’t have needed to manually point babelrc roots for it.