Babel 7 monorepo issue
See original GitHub issuev7 Regression
Describe the regression
I want to run build/test cli command from packages as well, not just from the project root.
If I run npx babel-node index.js
in my project root, everything works as expected.
But if I run npx babel-node index.js
inside packages/packA
, I get the following error:
/Users/djudik/repos/babel-7/packages/packB/index.js:3
export default (a: number, b: number) => {
^^^^^^
SyntaxError: Unexpected token export
I assume that packB file does not get compiled when I want to use it from packA, not from the project root.
Input Code https://github.com/judikdavid/babel-7
Babel Configuration (.babelrc, package.json, cli command) https://github.com/judikdavid/babel-7/blob/master/babel.config.js
Expected behavior/code
I should be able to use babel from any packages folder and it should use the root babel.config.js
config.
Environment
- Babel version(s): “@babel/core”: “^7.1.2”
- Node/npm version: Node 10.11.0/npm 6.4.1
- OS: OSX 10.14]
- Monorepo: yes
- How you are using Babel: cli
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:22 (6 by maintainers)
Top Results From Across the Web
Upgrade to Babel 7
Babel has had issues previously with handling node_modules , symlinks, and monorepos. We've made some changes to account for this: Babel will stop...
Read more >javascript - Trying to configure Babel in a monorepo project
This is probably caused by react-native-modal not transpiling class property syntax. And, by default, node_modules will not be transpiled.
Read more >Monorepo setup with Lerna, TypeScript, Babel 7 and other
We could avoid all issues relate to code formatting with prettier . It will automatically format our code according to predefined standards.
Read more >@monorepo-template/jest-preset - npm
This error occurs when babel-jest and jest have different major versions. Resolve this by either upgrading one (preferred) or downgrading the ...
Read more >How to transpile node_modules with babel and webpack in a ...
How to transpile node_modules with babel and webpack in a monorepo. Somto — August 08, 2019 — Coding — 7 min. read. ℹ️...
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 find it super difficult to find a minimal working example project on this topic 😃
@nicolo-ribaudo
this is my monorepo structure, using yarn workspaces
all packages have a
main
pointing tosrc/index.js
on package.jsonI wan to import functions from
common
package insideapi
packagesample code:
use have a babel.config.js on root, it has the same configs of all packages, and we also tried to add
babelrcRoots
to try to fix some issues:We are getting the folowing error:
so it looks like babel-node is not transpiling
common
packagewe tried to run the api like this:
but this command broke the imports
then we used lerna run, and it worked well:
scripts of package.json (root)
scripts on api package.json (api)
am I missing anything?, should I have a
include
on babel.config.js or use --ignore when calling babel-node?