-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
dedupe leads to errors in a monorepo with hoisted dependencies #86
Comments
Thanks for the issue 🍺 This is going to be a difficult one to remedy in a monorepo. I'm afraid the setup is going to be a bit complex in order to get multiple folks working on triage. Can you provide a repo that has a reproducible setup? One with the setup you're using would be most helpful. |
@shellscape sure thing, here is a repo reproducing the issue: https://github.com/jpaquim/rollup-monorepo-issue Run yarn at the root, then navigate to packages/template and run yarn build, and you should see the resulting |
I don't have enough context on the internals of rollup or this plugin, so this will probably be naïve, but it seems that just replacing However, I'm not sure if this would actually work inside a nested package, what the behaviour of require.resolve would be in that situation... |
#34 is likely to affect this as well. |
I've created a PR for this #98 |
Great, thank you @LarsDenBakker and @shellscape for the great work! |
👍 we're still working on getting publishing smoothed out, so please have patience on that getting to NPM |
How Do We Reproduce?
Here is a repo reproducing the issue: https://github.com/jpaquim/rollup-monorepo-issue
Steps:
dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/')
or more simplydedupe: ['svelte', 'svelte/internal']
.Expected Behavior
The imported package should be correctly bundled with the rest of the output.
Actual Behavior
The imported package is not resolved correctly, rollup complains:
(!) Unresolved dependencies https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency svelte/internal (imported by src/App.svelte)
Consequently, the import statement remains in the output. In my case:
import { SvelteComponent, init, safe_not_equal, element, text, space, attr, insert, append, set_data, noop, detach } from 'svelte/internal';
Comments
The issue seems to be related to this line, where the importee is overwritten with
join(process.cwd(), 'node_modules', importee)
.In a monorepo context,
process.cwd()
will typically refer to the package where the rollup command is started from, but with hoisting, the relevant node_modules are actually at the root of the monorepo, thus leading to the conflict.The text was updated successfully, but these errors were encountered: