Skip to content

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Feb 6, 2026

This PR implements build.chunkImportMap option, which utilizes import maps feature to optimize chunk caching efficiency.
This PR is based on #16552 and uses Rolldown's experimental importmaps feature. Huge thanks to @bhbs who have researched this topic and gave us the insights.

The implementation in the Vite core relies on import.meta.resolve. For that reason, only browsers with import.meta.resolve support are supported when this option is used.
To align with this, plugin-legacy now considers import.meta.resolve to be "widely-available". In other words, browsers without import.meta.resolve will use the legacy chunks instead of the modern chunks. The plugin-legacy support for this feature is implemented by using the import map support in SystemJS.

Note that experimental.renderBuiltUrl currently does not work with this option. To properly support the combination of that option + this option, it requires more effort to design how to handle absolute URLs (e.g. how to support the case where renderBuiltUrl returns an absolute URL that should be mapped by the import map).

Also note that this optimization currently does not apply to CSS and assets. But this shouldn't affect largely as it will only invalidate the JS file that is importing them and would not affect the JS files that transitively imports the changed CSS / asset.

fixes #6773
fixes #10636
close #16552

@sapphi-red sapphi-red added p3-significant High priority enhancement (priority) trigger: preview labels Feb 10, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 10, 2026

Open in StackBlitz

@vitejs/plugin-legacy

pnpm add https://pkg.pr.new/vitejs/vite/@vitejs/plugin-legacy@21580 -D
npm i https://pkg.pr.new/vitejs/vite/@vitejs/plugin-legacy@21580 -D
yarn add https://pkg.pr.new/vitejs/vite/@vitejs/plugin-legacy@21580.tgz -D

vite

pnpm add https://pkg.pr.new/vitejs/vite@21580 -D
npm i https://pkg.pr.new/vitejs/vite@21580 -D
yarn add https://pkg.pr.new/vitejs/vite@21580.tgz -D

commit: aed7c01

@sapphi-red sapphi-red marked this pull request as ready for review February 13, 2026 06:53
@github-project-automation github-project-automation bot moved this to Discussing in Team Board Feb 13, 2026
@sapphi-red sapphi-red changed the title feat: chunk importmap feat(build): chunk importmap Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: build p3-significant High priority enhancement (priority) trigger: preview

Projects

Status: Discussing

1 participant