This commit is contained in:
Wang Kejun 2022-09-29 09:56:50 +08:00
parent f591b95454
commit 1186517b35
3 changed files with 13 additions and 2 deletions

View File

@ -353,7 +353,9 @@ function analyzeEntity(filename, path, program, relativePath) {
var moduleSpecifier = node.moduleSpecifier, importClause = node.importClause;
if (ts.isStringLiteral(moduleSpecifier) && !moduleSpecifier.text.startsWith(env_1.LIB_OAK_DOMAIN)) {
// 编译后的路径默认要深一层
var moduleSpecifier2Text = relativePath ? path_1.default.join(relativePath, moduleSpecifier.text) : path_1.default.join('..', moduleSpecifier.text);
var moduleSpecifier2Text = relativePath
? path_1.default.join(relativePath, moduleSpecifier.text).replace(/\\/g, '/')
: path_1.default.join('..', moduleSpecifier.text).replace(/\\/g, '/');
additionalImports.push(factory.updateImportDeclaration(node, undefined, undefined, importClause, factory.createStringLiteral(moduleSpecifier2Text), undefined));
}
}

View File

@ -30,6 +30,7 @@
"@types/uuid": "^8.3.0",
"assert": "^2.0.0",
"cross-env": "^7.0.2",
"cross-spawn": "^7.0.3",
"fs-extra": "^10.0.0",
"mocha": "^8.2.1",
"ts-node": "~10.9.1",

View File

@ -513,7 +513,15 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela
const { moduleSpecifier, importClause } = node;
if (ts.isStringLiteral(moduleSpecifier) && !moduleSpecifier.text.startsWith(LIB_OAK_DOMAIN)) {
// 编译后的路径默认要深一层
const moduleSpecifier2Text = relativePath ? PathLib.join(relativePath, moduleSpecifier.text) : PathLib.join('..', moduleSpecifier.text);
const moduleSpecifier2Text = relativePath
? PathLib.join(
relativePath,
moduleSpecifier.text
).replace(/\\/g, '/')
: PathLib.join('..', moduleSpecifier.text).replace(
/\\/g,
'/'
);
additionalImports.push(
factory.updateImportDeclaration(
node,