Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mp): 支持npm link&monorepo等不在root路径下的软链接引用 #5108

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/uni-cli-shared/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down