Prevent it from generating shared internal modules and bundling unused dependences from another entry point altogether
See original GitHub issueClear and concise description of the problem
For example, with configuration below:
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, 'src/main.ts'),
admin: path.resolve(__dirname, 'src/admin/main.ts'),
},
},
},
It builds with manifest.json
as below:
Suggested solution
The _Image.js
is a component used in both entry, but it’s an internal component, it should be bundled in to admain.js
and main.js
. The _vendor.js
includes all dependences in both entry, but not all of them was actually used in that particular entry, there should be a separation of vendors for each entry, I mean just like admin.vendor.js
, main.vendor.js
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Get Webpack not to bundle files - Stack Overflow
Webpack's sole purpose is to do bundling; are you sure you don't want any bundling, or do you just want some things to...
Read more >JavaScript Modules Part 2: Module Bundling - freeCodeCamp
On a high level, module bundling is simply the process of stitching together a group of modules (and their dependencies) into a single...
Read more >The Complete JavaScript Module Bundlers Guide - Snipcart
This in-depth guide will help you understand what you need to know about JavaScript module bundlers. A list of the top 5 best...
Read more >rollup.js
These commands assume the entry point to your application is named main.js , and that you'd like all imports compiled into a single...
Read more >Dependency Pre-Bundling - Vite
CommonJS and UMD compatibility: During development, Vite's dev serves all code as native ESM. · Performance: Vite converts ESM dependencies with many internal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am having this problem as well. If I specify
build.rollupOptions.input: { ... }
then modules that are shared between the input/entry files get bundled into a separate chunk. The chunk is named after one of the shared modules (a React component), e.g.Header.954792bd.js
.I don’t understand why this happens and how to change the behaviour. I could find nothing in the Vite and the Rollup documentation.
You can configure how the entry/chunk is created using
rollupOptions.output
. The output you see is Vite’s default bundling method with a vendor chunk (e.g._vendor.js
) for node_modules, and source-code (e.g._Image.js
) being code-splitted with Rollup. Re “not all of them was actually used” for the vendor chunk, this strategy is changed in Vite 2.9, so you should see finer-grain chunking for it.Since Vite can only decide on one default chunking strategy for everyone, it’s expected for the user to configure
rollupOptions
if you need something specific. Closing the issue with the explanation above.