fix: the script contains locale json is prefetched (#17585)

This commit upgrades rolldown used by vite to 1.1.0 and set
includeDependenciesRecursively instead of maxSize for
i18n code splitting group.

We unexpectedly prefetched the script file includes locale JSON
before this fix because locale inliner did not remove prefetch
for transitive dependency of i18n global variable.

Current locale inliner assumes the file contains i18n global
variable and the file contains i18n global variable are same file
and only removes prefetch for the file for i18n global variable
and leaves dependency files of the file.
However, in the previous fix for rolldown migration regression,
we set `maxSize: 1` for manual chunk of i18n.
This makes the chunk for i18n global variable (@/i18n.js) and
the chunk includes locale JSON (@@/js/locale.js) distinct chunks.
As a result, only prefetch for i18n global is removed and local
JSON remain in the prefetch file name dictionary (__vite__mapDeps).

There is two ways to fix this problem: 1) make rolldown to bundle
i18n related files into one but leave unrelated files separated
module or 2) update locale inliner to remove transitive dependency
of i18n of __vite__mapDeps.
2nd way is prune to rolldown changes, and it's possible by parsing
each .js file to (re)create module graph in inliner, it's complex.
Therefore, this commit fixes this with 1st way with
includeDependenciesRecursively option on `codeSplitting.groups`
newly added in rolldown 1.1.0.
Since latest vite as of writing (8.0.16) strictly depends on
rolldown 1.0.3, we cannot use it normally. We use overrides
to work around this problem. As far as I checked the vite
repository, upgrading rolldown to 1.1.x includes no code changes
except for package.json, so I hope this upgrade is safe.
This commit is contained in:
anatawa12 2026-06-20 08:59:01 +09:00 committed by GitHub
commit 21a4f95bd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 495 additions and 266 deletions

View file

@ -153,11 +153,10 @@ export function getConfig(): UserConfig {
name: 'vue', name: 'vue',
test: /node_modules[\\/]vue/, test: /node_modules[\\/]vue/,
}, { }, {
// split each i18n related module to each distinct module, deny hoisting // split i18n related module to distinct module
name: 'i18n', name: 'i18n',
test: /i18n\.ts/, includeDependenciesRecursively: false,
minSize: 0, test: /i18n\.ts|locale\.ts/,
maxSize: 1,
}], }],
}, },
entryFileNames: `scripts/${localesHash}-[hash:8].js`, entryFileNames: `scripts/${localesHash}-[hash:8].js`,

View file

@ -194,11 +194,10 @@ export function getConfig(): UserConfig {
name: 'photoswipe', name: 'photoswipe',
test: /node_modules[\\/]photoswipe/, test: /node_modules[\\/]photoswipe/,
}, { }, {
// split each i18n related module to each distinct module, deny hoisting // split i18n related module to distinct module
name: 'i18n', name: 'i18n',
test: /i18n\.ts/, includeDependenciesRecursively: false,
minSize: 0, test: /i18n\.ts|locale\.ts/,
maxSize: 1,
}], }],
}, },
entryFileNames: `scripts/${localesHash}-[hash:8].js`, entryFileNames: `scripts/${localesHash}-[hash:8].js`,

745
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -63,6 +63,8 @@ overrides:
'@aiscript-dev/aiscript-languageserver': '-' '@aiscript-dev/aiscript-languageserver': '-'
chokidar: 5.0.0 chokidar: 5.0.0
lodash: 4.18.1 lodash: 4.18.1
# remove when vite is updated to versions with rolldown > 1.1.0
vite>rolldown: "~1.1.0"
engineStrict: true engineStrict: true
saveExact: true saveExact: true
shellEmulator: true shellEmulator: true