diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index 290f6b69ac1cf9..2ec5c56715ec7e 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -88,6 +88,13 @@ describe.runIf(isBuild)('build', () => { expect(manifest['../../vite/legacy-polyfills-legacy'].src).toBe( '../../vite/legacy-polyfills-legacy', ) + expect(manifest['custom0-legacy.js'].file).toMatch( + /chunk-X-legacy.\w{8}.js/, + ) + expect(manifest['custom1-legacy.js'].file).toMatch( + /chunk-X-legacy-\w{8}.js/, + ) + expect(manifest['custom2-legacy.js'].file).toMatch(/chunk-X-legacy\w{8}.js/) // modern polyfill expect(manifest['../../vite/legacy-polyfills']).toBeDefined() expect(manifest['../../vite/legacy-polyfills'].src).toBe( diff --git a/playground/legacy/custom0.js b/playground/legacy/custom0.js new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/playground/legacy/custom1.js b/playground/legacy/custom1.js new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/playground/legacy/custom2.js b/playground/legacy/custom2.js new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/playground/legacy/main.js b/playground/legacy/main.js index 91ba0b038104c4..aee9bda9594354 100644 --- a/playground/legacy/main.js +++ b/playground/legacy/main.js @@ -3,6 +3,9 @@ import viteSvgPath from './vite.svg' import MyWorker from './worker?worker' async function run() { + await import('./custom0.js') + await import('./custom1.js') + await import('./custom2.js') const { fn } = await import('./async.js') fn() } diff --git a/playground/legacy/vite.config.js b/playground/legacy/vite.config.js index 7adf0f784eeeb2..c15a8b14b40cd2 100644 --- a/playground/legacy/vite.config.js +++ b/playground/legacy/vite.config.js @@ -23,6 +23,10 @@ module.exports = { chunkFileNames(chunkInfo) { if (chunkInfo.name === 'immutable-chunk') { return `assets/${chunkInfo.name}.js` + } else if (/custom\d/.test(chunkInfo.name)) { + return `assets/chunk-X${ + ['.', '-', ''][/custom(\d)/.exec(chunkInfo.name)[1]] + }[hash].js` } return `assets/chunk-[name].[hash].js` },