From c2355bffe64ef837a0a62020a49667a1a1b6ad3d Mon Sep 17 00:00:00 2001 From: linziyang Date: Sun, 25 Aug 2024 15:05:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(mp):=20=E6=94=AF=E6=8C=81npm=20link&monore?= =?UTF-8?q?po=E7=AD=89=E4=B8=8D=E5=9C=A8root=E8=B7=AF=E5=BE=84=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E8=BD=AF=E9=93=BE=E6=8E=A5=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-cli-shared/src/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/uni-cli-shared/src/utils.ts b/packages/uni-cli-shared/src/utils.ts index 6ff76d7d517..ad34212f667 100644 --- a/packages/uni-cli-shared/src/utils.ts +++ b/packages/uni-cli-shared/src/utils.ts @@ -107,10 +107,16 @@ export function normalizeMiniProgramFilename( filename: string, inputDir?: string ) { - if (!inputDir || !path.isAbsolute(filename)) { - return normalizeNodeModules(filename) + let relativeFilename = filename + if (inputDir && path.isAbsolute(filename)) { + relativeFilename = path.relative(inputDir, filename) } - return normalizeNodeModules(path.relative(inputDir, filename)) + if (/^\.\.(\/|\\)/.test(relativeFilename)) { + const level = `_${relativeFilename.match(/\.\.(\/|\\)/g)!.length}` + relativeFilename = relativeFilename.replace(/\.\.(\/|\\)/g, '') + relativeFilename = path.join('_symlinks', level, relativeFilename) + } + return normalizeNodeModules(relativeFilename) } export function normalizeParsePlugins(