Skip to content

Commit

Permalink
test: use a case to introduce the case when there is no [name]
Browse files Browse the repository at this point in the history
  • Loading branch information
aleen42 committed Jan 6, 2023
1 parent ebcb513 commit 1c3b5bc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions playground/legacy/__tests__/legacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Empty file added playground/legacy/custom0.js
Empty file.
Empty file added playground/legacy/custom1.js
Empty file.
Empty file added playground/legacy/custom2.js
Empty file.
3 changes: 3 additions & 0 deletions playground/legacy/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
4 changes: 4 additions & 0 deletions playground/legacy/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
},
Expand Down

0 comments on commit 1c3b5bc

Please sign in to comment.