From c56caaa1058b414e5290db8460a4df9e873e40a0 Mon Sep 17 00:00:00 2001 From: MisterLuffy Date: Wed, 20 Sep 2023 18:20:34 +0800 Subject: [PATCH] fix: replacer got an invalid path if tsconfig.json is out of package dir (#200) --- src/utils/trie.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/trie.ts b/src/utils/trie.ts index 0808f6f..d64d326 100644 --- a/src/utils/trie.ts +++ b/src/utils/trie.ts @@ -12,7 +12,7 @@ */ /** */ -import { isAbsolute, normalize, relative } from 'path'; +import { isAbsolute, normalize, relative, resolve } from 'path'; import { findBasePathOfAlias, relativeOutPathToConfigDir } from '../helpers'; import { Alias, IProjectConfig, PathLike } from '../interfaces'; @@ -83,7 +83,10 @@ export class TrieNode { .replace(/\*$/, '') .replace(/\.([mc])?ts(x)?$/, '.$1js$2'); if (isAbsolute(path)) { - path = relative(config.configDir, path); + path = relative( + resolve(config.configDir, config.baseUrl), + path + ); } if (