Plugins: preserveModules in yarn monorepo outputs full project path

Created on 20 Apr 2020  ยท  6Comments  ยท  Source: rollup/plugins

  • Rollup Plugin Name: @rollup/plugin-node-resolve
  • Rollup Plugin Version: 7.1.3
  • Rollup Version: 2.6.1
  • Operating System (or Browser): Ubuntu 1804 / Chromium
  • Node Version: 13.13.0

Reproduction

git clone ...
yarn
cd packages/office-ui-fabric-vue
yarn rollup -c
(check ./lib)

Expected Behavior

Modules should be emitted into ./lib/, e.g. ./lib/index.js.

Actual Behavior

Modules are emitted with the relative path to the project root, e.g. ./lib/packages/office-ui-fabric-vue/src/index.js.

I think this might stem form the _virtual folder being emitted from the project root rather than the package root. Maybe this is an issue with i.e. node-resolve? Sadly I have no idea where to look to triage this...

tยน ๐Ÿž bug xโท โ‹… stale ๐Ÿ”Œ plugin-node-resolve

Most helpful comment

(Yeah, sorry. Initially I wanted to open it in rollup, but I wasn't sure if it was plugin related or not...)

You are totally right, sorry. I created a small repro to showcase this issue. I've included the built files in git:

git clone https://github.com/johannes-z/rollup-yarn-preserveModules
yarn install
# optional, already built, doesn't use rollup anyway
cd packages/producer
yarn build

cd packages/consumer
yarn build

packages/consumer then created ./lib/packages/consumer/src/index.js.

I've also tried pnpm: packages/consumer created ./lib/src/index.js in this case... pnpm does not change anything in my production repo though.

Edit: I'm pretty sure this is related to @rollup/plugin-node-resolve. Removing it changes the emitted modules (although they are still not correct) to: lib/consumer/src/index.js

All 6 comments

_(It looks like you used the template from rollup/rollup. You're in rollup/plugins fwiw ๐Ÿ˜„ )_

Thanks for the repo, but I'm afraid there's a bit too much going on there to effectively triage. In the plugin repo's issue template for bugs, there's a link that explains what and why we need a _minimal_ reproduction. I don't think we'll be able to triage this one for you unless you're able to drill / distill your repo down to a minimal reproduction case. Like a teensy tiny reproduction that exhibits the same behavior.

(Yeah, sorry. Initially I wanted to open it in rollup, but I wasn't sure if it was plugin related or not...)

You are totally right, sorry. I created a small repro to showcase this issue. I've included the built files in git:

git clone https://github.com/johannes-z/rollup-yarn-preserveModules
yarn install
# optional, already built, doesn't use rollup anyway
cd packages/producer
yarn build

cd packages/consumer
yarn build

packages/consumer then created ./lib/packages/consumer/src/index.js.

I've also tried pnpm: packages/consumer created ./lib/src/index.js in this case... pnpm does not change anything in my production repo though.

Edit: I'm pretty sure this is related to @rollup/plugin-node-resolve. Removing it changes the emitted modules (although they are still not correct) to: lib/consumer/src/index.js

Not sure, but could it be related to #277 ? I opened that issue as a suggestion, but later realized that plugin-node-resolve is actually messing up output paths..

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.# Comment to post when closing a stale issue. โ“˜

I am running into this same issue now @johannes-z did you ever solve it?

yes. you have to mark every node module put into _virtual as external, then the output will be correct.

Was this page helpful?
0 / 5 - 0 ratings