Skip to content

Commit

Permalink
refactor(preset-umi): make 3rd-party chunk name clean (#11716)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript authored Oct 11, 2023
1 parent 170863c commit 8e4db78
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/preset-umi/src/features/tmpFiles/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,15 @@ export function componentToChunkName(
),
'',
)
// 丢弃 .pnpm 下的多层 node_modules 避免 chunkName 过长
// ex. node_modules/.pnpm/[email protected]_xxxx/node_modules/dumi/dist/client/pages/404
.replace(/.+(node_modules(\/|\\))/, '$1')
// 丢弃 tnpm 目录下的软链结构避免 chunkName 过长
// ex. node_modules/_@umijs_utils@4.0.83@@umijs/utils/dist/index.js
.replace(/(\/|\\)_@?([^@]+@){2}/, '$1')
.replace(/^.(\/|\\)/, '')
.replace(/(\/|\\)/g, '__')
// 转换 tnpm node_modules 目录中的 @ 符号,它在 URL 上会被转义,可能导致 CDN 托管失败
// 转换 node_modules 目录中的 @ 符号,它在 URL 上会被转义,可能导致 CDN 托管失败
.replace(/@/g, '_')
.replace(/\.jsx?$/, '')
.replace(/\.tsx?$/, '')
Expand Down

0 comments on commit 8e4db78

Please sign in to comment.