Resolve all modules using Node resolution algorithm, but embed only specific ones
slavafomin opened this issue · 3 comments
Hello!
Thank you for this great plugin!
I'm using the following imports in my project:
import {foo} from './foo';
, which should be resolved to: import {foo} from './foo/index.js';
according to the Node resolution algorithm.
But, at the same time, I have some modules in node_modules
, which I want to embed to my bundle and the ones I want to leave as external.
However, if I set the only
option to something like: only: ['tslib']
, the Rollup stops resolving my local imports like import {foo} from './foo';
. And if I omit the only
option, the modules are resolved correctly, but it embeds everything it could find to the final bundle (which I don't want to do).
Is there a way to use node resolution algorithm for all imports, but to embed only specific modules to the bundle?
I think these are two separate processes (module resolution and module embedding), and one option shouldn't prevent another from working.
It's OK (and desired) to embed all imports to a bundle, when you build a final application, however, when it comes to library building you need a more granular control of what to actually embed and what to leave as external dependency.
The only workaround I can think of so far is to run Rollup two times: one to resolve all local dependencies and leave everything from node_modules
as external and then to embed some external dependencies to the bundle. But I would really want to avoid such approach.
Could you elaborate on this issue please? Thanks!
I've implemented this plugin as a solution to this problem:
https://github.com/slavafomin/rollup-plugin-node-resolve-next
I will be glad for any input on it.
Isn't external
rollup option what you need?
I think it can be closed.