Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(legacy)!: should rename x.[hash].js to x-legacy.[hash].js #11599

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: use a case to introduce the case when there is no [name]
aleen42 committed Jan 6, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1c3b5bc96286d7c9e2eceb01d00e2ba071c6cf3a
7 changes: 7 additions & 0 deletions playground/legacy/__tests__/legacy.spec.ts
Original file line number Diff line number Diff line change
@@ -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(
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
@@ -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()
}
4 changes: 4 additions & 0 deletions playground/legacy/vite.config.js
Original file line number Diff line number Diff line change
@@ -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`
},