huozhi / bunchee

Zero config bundler for ECMAScript and TypeScript packages
https://npmjs.com/bunchee
861 stars 28 forks source link

feat: custom shared module #480

Closed huozhi closed 3 months ago

huozhi commented 3 months ago

Introduce a new pattern that you can make your code being split into a certain chunk group, the modules like shared react context can be shared among among the bundles with same format.

Convention

<base name>.<layer>-runtime.<ext>

Having a file convention like foo.shared-runtime.js, it will match the convention and shared will become the layer it's going to be bundled into. Bundler will create a new chunk group contains those files.

If you have a shared module that needs to share across the entries, this convention can be used to achieve.

Resolves #429