Skip to content
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

Parcel 2 not picking up babel configuration in a yarn monorepo #6119

Closed
rauschie opened this issue Apr 12, 2021 · 4 comments
Closed

Parcel 2 not picking up babel configuration in a yarn monorepo #6119

rauschie opened this issue Apr 12, 2021 · 4 comments
Labels

Comments

@rauschie
Copy link

🐛 bug report

🎛 Configuration (.babelrc, package.json, cli command)

Currently it seems that in a yarn monorepo, parcel does not pick up neither .babelrc, nor "babel" entry of package.json, whether its located at the workspace root or subrepo root.

🤔 Expected Behavior

The linked repo should build. Babel configuration in a subrepo root should be respected, or at the very least info should be provided where to put babel configuration in a monorepo in order for it to get respected by parcel

😯 Current Behavior

In a monorepo parcel complains about absence of plugin that is defined in .babelrc, regardless of .babelrc location

💁 Possible Solution

🔦 Context

I am trying to build a subrepo using parcel. Subrepo uses private class fields.

💻 Code Sample

the repo used to demonstrate the bug supposedly fixed in #4132 still does not build neither with beta.2 nor with nightly.639

🌍 Your Environment

Software Version(s)
Parcel
Node
npm/Yarn
Operating System
@Fr33maan
Copy link

I actually HAD TO add a package-lock.json (even an empty one works) in the subrepo to have the subrepo babel.config.json to be used by parcel.
I'm using a monorepo structure with lerna.

You can see in the doc that a package.json is not enough for parcel to consider a directory as a project directory, which is pretty confusing I think.

@rauschie
Copy link
Author

rauschie commented Apr 14, 2021

You can see in the doc that a package.json is not enough for parcel to consider a directory as a project directory, which is pretty confusing I think.

Well That's cute. Dropping an empty package-lock.json in the subrepo did indeed solve the problem, a million thanks for the workaround!

@mischnic
Copy link
Member

Adding package-lock.json files is not the correct solution.

Parcel just uses Babel's config resolution here, so this section applies: https://babeljs.io/docs/en/config-files#monorepos (so the "usual" approach of .babelrc's doesn't work in monorepos)

@mischnic
Copy link
Member

As described in the linked docs, you need to add a babel.config.json file in the root containing:

{ "babelrcRoots": ["app1", "app2"] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants