-
Notifications
You must be signed in to change notification settings - Fork 320
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
Build each entry independently when testing Vite #4981
Conversation
📋 StatsFile sizes
Modules
View stats and visualisations on the review app Action run for a6628e8 |
6f6c282
to
a6628e8
Compare
// as Vite would split shared code in a separate chunk if trying | ||
// to build an array of entries in `build.rollupOptions.input` | ||
// or `build.lib.entry` | ||
const entryName = process.env.ENTRY_NAME ?? 'single-component' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note Set a default here to avoid things breaking badly when runing Vite outside of npm run vite -w @govuk-frontend/bundler-integrations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me 👍🏻
Builds
initAll.mjs
andsingle-component.mjs
independently during Vite integration tests, to work around Vite cleverly optimising a build with multiple entries by splitting shared code in a separate file. After investigation, it seems we can only make separate builds to circumvent that cleverness.Simplest option looked to allow to pass the name of the file through environment variable, so we can run the build command multiple times targeting a separate entry. As we want to have the same build folder structure as for Webpack and Rollup, both builds will need to output to the same folder, for which we need to disable Vite automatically cleaning up its build folder.
Closes #4978.