-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Copy link
Labels
clarity: highinconsistencyInconsistency between dev & buildInconsistency between dev & buildp4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)
Description
Describe the bug
Bug
A comment inside a dynamic import() with a template literal prevents Vite 8's dynamicImportVarsPlugin from transforming it into a static glob map.
// BROKEN — import is left untransformed, matching files are not bundled
const strings = await import(/* strings */ `./translations/${locale}/strings.json`);
// WORKS — transformed into a static Object.assign map with all matching files
const strings = await import(`./translations/${locale}/strings.json`);These comments are harmless in Vite 7 (Rollup and Rolldown) but break dynamic import resolution in Vite 8 (Rolldown).
Expected behavior
Both forms should produce identical output.
Reproduce
npm install
npm run buildInspect dist/assets/index-*.js:
- With comment: the
import()passes through untransformed — no translation chunks are emitted. - Without comment:
dynamicImportVarsPluginproduces the expected static map and separate chunks for each translation file.
Reproduction
https://github.com/dake3601/vite-dynamic-import-repro
Steps to reproduce
Run npm install followed by npm run build
To see it working correctly remove the comment inside the import at main.js
System Info
System:
OS: Windows 11
Binaries:
Node: 24.13.0
npm: 11.6.2
npmPackages:
vite: ^8.0.0 => 8.0.0Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
clarity: highinconsistencyInconsistency between dev & buildInconsistency between dev & buildp4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)