Skip to content

Commit 64445e9

Browse files
fatfiszlependu
authored andcommitted
Use a more appropriate regexp for removing hash from a filename (vercel#4510)
Fixes one of the problems described in vercel#4433. The old regexp was removing everything after a hyphen, so with a chunk name like so: ``` chunks/path-to-a-file-[hash].js ``` the saved chunk name was ``` chunks/path ``` This caused problems, because webpack by default changes `/` to `-` in chunk names generated e.g. by ``import(`foo/${bar}`)``. After this change the chunk name will be ``` chunks/path-to-a-file ```
1 parent 5cb18e7 commit 64445e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function getAvailableChunks (distDir) {
1313

1414
chunkFiles.forEach(filename => {
1515
if (/\.js$/.test(filename)) {
16-
const chunkName = filename.replace(/-.*/, '')
16+
const chunkName = filename.replace(/-[^-]*/, '')
1717
chunksMap[chunkName] = filename
1818
}
1919
})

0 commit comments

Comments
 (0)