Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Resolve all modules using Node resolution algorithm, but embed only specific ones #171

Closed
slavafomin opened this issue Jul 19, 2018 · 3 comments

Comments

@slavafomin
Copy link

slavafomin commented Jul 19, 2018

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!

@slavafomin slavafomin changed the title Resolve modules using Node resolution algorithm, but embed only specific ones Resolve all modules using Node resolution algorithm, but embed only specific ones Jul 19, 2018
@slavafomin
Copy link
Author

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.

@TrySound
Copy link
Member

TrySound commented Oct 1, 2018

Isn't external rollup option what you need?

@dima-takoy-zz
Copy link

I think it can be closed.

@TrySound TrySound closed this as completed May 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants