Skip to content

Commit

Permalink
fix: should not replace to alias when filePath is not in src (web-inf…
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe committed Mar 13, 2023
1 parent 4d89ad2 commit e1b6881
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/kind-eagles-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/app-tools': patch
---

fix: should not replace to alias when filePath is not in src
fix: 不应该替换为别名,当 filePath 不在 src 目录中时
10 changes: 9 additions & 1 deletion packages/solutions/app-tools/src/analyze/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ export const replaceWithAlias = (
base: string,
filePath: string,
alias: string,
) => normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
) => {
if (filePath.includes(base)) {
return normalizeToPosixPath(
path.join(alias, path.relative(base, filePath)),
);
} else {
return filePath;
}
};

export const parseModule = async ({
source,
Expand Down

0 comments on commit e1b6881

Please sign in to comment.