diff --git a/packages/uni-mp-vite/src/plugin/build.ts b/packages/uni-mp-vite/src/plugin/build.ts index 486a4042caa665fe1d010b943da062fb42831c79..860d81013d3799f7d818a4b222398275067f7864 100644 --- a/packages/uni-mp-vite/src/plugin/build.ts +++ b/packages/uni-mp-vite/src/plugin/build.ts @@ -119,8 +119,8 @@ function createMoveToVendorChunkFn(): GetManualChunk { const cache = new Map() const inputDir = normalizePath(process.env.UNI_INPUT_DIR) return (id, { getModuleInfo }) => { - id = normalizePath(id) - const filename = id.split('?')[0] + const normalizedId = normalizePath(id) + const filename = normalizedId.split('?')[0] // 处理项目内的js,ts文件 if (EXTNAME_JS_RE.test(filename)) { if (filename.startsWith(inputDir) && !filename.includes('node_modules')) { @@ -131,19 +131,20 @@ function createMoveToVendorChunkFn(): GetManualChunk { !chunkFileNameBlackList.includes(chunkFileName) && !hasJsonFile(chunkFileName) // 无同名的page,component ) { - debugChunk(chunkFileName, id) + debugChunk(chunkFileName, normalizedId) return chunkFileName } return } // 非项目内的 js 资源,均打包到 vendor - debugChunk('common/vendor', id) + debugChunk('common/vendor', normalizedId) return 'common/vendor' } if ( - isVueJs(id) || - (id.includes('node_modules') && - !isCSSRequest(id) && + isVueJs(normalizedId) || + (normalizedId.includes('node_modules') && + !isCSSRequest(normalizedId) && + // 使用原始路径,格式化的可能找不到模块信息 https://github.com/dcloudio/uni-app/issues/3425 staticImportedByEntry(id, getModuleInfo, cache)) ) { debugChunk('common/vendor', id)