forked from mirrors/misskey
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:
parent
1c6e5365d6
commit
21a4f95bd6
4 changed files with 495 additions and 266 deletions
|
|
@ -153,11 +153,10 @@ export function getConfig(): UserConfig {
|
|||
name: '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',
|
||||
test: /i18n\.ts/,
|
||||
minSize: 0,
|
||||
maxSize: 1,
|
||||
includeDependenciesRecursively: false,
|
||||
test: /i18n\.ts|locale\.ts/,
|
||||
}],
|
||||
},
|
||||
entryFileNames: `scripts/${localesHash}-[hash:8].js`,
|
||||
|
|
|
|||
|
|
@ -194,11 +194,10 @@ export function getConfig(): UserConfig {
|
|||
name: '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',
|
||||
test: /i18n\.ts/,
|
||||
minSize: 0,
|
||||
maxSize: 1,
|
||||
includeDependenciesRecursively: false,
|
||||
test: /i18n\.ts|locale\.ts/,
|
||||
}],
|
||||
},
|
||||
entryFileNames: `scripts/${localesHash}-[hash:8].js`,
|
||||
|
|
|
|||
745
pnpm-lock.yaml
generated
745
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -63,6 +63,8 @@ overrides:
|
|||
'@aiscript-dev/aiscript-languageserver': '-'
|
||||
chokidar: 5.0.0
|
||||
lodash: 4.18.1
|
||||
# remove when vite is updated to versions with rolldown > 1.1.0
|
||||
vite>rolldown: "~1.1.0"
|
||||
engineStrict: true
|
||||
saveExact: true
|
||||
shellEmulator: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue