question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

incorrect `projectRoot` when using parcel in monorepo

See original GitHub issue

🐛 bug report

I’m using lerna with yarn workspace just like you guys do. When I run parcel within a sub package, it can’t read the .env .proxyrc.js files inside the package, instead it reads them from the root of repo.

After digging into the code, turns out that projectRoot was set incorrectly, and there is no way to specify its value. Here is the code in @parcel/core

https://github.com/parcel-bundler/parcel/blob/v2/packages/core/core/src/resolveOptions.js#L52-L61

🎛 Configuration

with all default Configurations

🤔 Expected Behavior

parcel can reads configurations inside the sub package

😯 Current Behavior

parcel reads configurations from the root of repo

🔦 Context

possible solutions:

  1. change parcel behavior in monorepo
  2. add an option --project-root( projectRoot in API) to allow user to specify projectRoot

🌍 Your Environment

Software Version(s)
Parcel 2.2.1
Node v16.9.1
npm/Yarn yarn 1.22.11 / npm 7.21.1
Operating System macOS 12.1

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
jpapinicommented, Mar 28, 2022

Adding an empty pnpm-lock.yaml (or any lockfile) file to a subpackage of the monorepo fakes the projectRoot directory of Parcel.

1reaction
mischniccommented, Apr 13, 2022

Note that Parcel doesn’t watch anything outside the package root. So moving it somewhere inside of the monorepo will not watch other packages you might import from the monorepo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setup a Monorepo with PNPM workspaces and speed it up ...
In this article we're going to have a deep dive into setting up a new monorepo using PNPM workspaces that hosts a Remix...
Read more >
Dependency resolution | Parcel 中文网
As Parcel builds your source code, it discovers dependencies, which allow code to be broken into separate files and reused in multiple places....
Read more >
Parcel
Parcel combines a great out-of-the-box development experience with a scalable ... You can even build a whole monorepo of packages in a single...
Read more >
The Ultimate Guide to TypeScript Monorepos
Tagged with typescript, javascript, programming, yarn. ... file in the project root and that will apply to all files in the Monorepo.
Read more >
We abandoned npm install, maybe you should too - Medium
As I'm sure you already know, monorepos are awesome! If you don't know, a monorepo is a repository with multiple applications and libraries, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found