Skip to content

Commit

Permalink
fix: add hash to lib chunk names (#7190)
Browse files Browse the repository at this point in the history
Co-authored-by: patak-dev <matias.capeletto@gmail.com>
  • Loading branch information
pd4d10 and patak-dev committed May 11, 2022
1 parent a543220 commit c81cedf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite/src/node/build.ts
Expand Up @@ -433,7 +433,7 @@ async function doBuild(
? resolveLibFilename(libOptions, output.format || 'es', config.root)
: path.posix.join(options.assetsDir, `[name].[hash].js`),
chunkFileNames: libOptions
? `[name].js`
? `[name].[hash].js`
: path.posix.join(options.assetsDir, `[name].[hash].js`),
assetFileNames: libOptions
? `[name].[ext]`
Expand Down
3 changes: 3 additions & 0 deletions playground/lib/__tests__/lib.spec.ts
Expand Up @@ -44,6 +44,9 @@ describe.runIf(isBuild)('build', () => {
'utf-8'
)
expect(code).not.toMatch('__vitePreload')

// Test that library chunks are hashed
expect(code).toMatch(/await import\("\.\/message.[a-z\d]{8}.js"\)/)
})

test('@import hoist', async () => {
Expand Down

0 comments on commit c81cedf

Please sign in to comment.