Skip to content
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

[RFC] Shared Bundle #540

Closed
Tracked by #1115
huozhi opened this issue Jun 9, 2024 · 1 comment · Fixed by #600
Closed
Tracked by #1115

[RFC] Shared Bundle #540

huozhi opened this issue Jun 9, 2024 · 1 comment · Fixed by #600
Labels

Comments

@huozhi
Copy link
Owner

huozhi commented Jun 9, 2024

Background

shared-runtime modules is not ideal for shared chunks spltting as it's fully based on code splitting strategy, when you import different exports from a shared module, they could be split into different chunks instead of being grouped into a same output bundle, event they're in the same group of split chunks.

Thus we need to have an entry as input for a shared module, and then alias it like the other chunks. Since now we have the relative exports in #538 , so we could auto generate shared entries based on a special convention.

Proposal

Add a file starting with _ to indicate shared module, e.g. _mod.js or _mod/index.js will be shared across entries. Usually leading underscore _ can deliver a private module vibe.

Then bunchee should create a bundle for _shared, where input file is ./src/_shared.js. And the rest follows the rules of normal entries. This could improve the shared modules story and without adding much new convention or patterns to memorize

@amannn
Copy link

amannn commented Aug 21, 2024

That would sound great to me!

I just ran into an issue with shared modules again, where 3 entry points import from a shared runtime, but somehow 3 copies of the shared runtime end up in the dist folder (one for each entry point).

I'll try to work around it by moving the shared runtime to another entry point for the time being, but imports would sound really cool 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants