From d8f1fd28834d63fb53931f01d1186aee176920bc Mon Sep 17 00:00:00 2001 From: hufeng Date: Fri, 27 May 2022 20:21:04 +0800 Subject: [PATCH] Remove path.normalize Signed-off-by: hufeng Change-Id: I2edbd01f453a7c9f73ee459e6ecb1f59f8e08534 --- ts2panda/src/recorder.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ts2panda/src/recorder.ts b/ts2panda/src/recorder.ts index e3ba10ca90..77f15d90c6 100644 --- a/ts2panda/src/recorder.ts +++ b/ts2panda/src/recorder.ts @@ -460,13 +460,6 @@ export class Recorder { return exportStmt; } - private getNormalizeModuleSpecifier(moduleSpecifier: ts.Expression): string { - if (!ts.isStringLiteral(moduleSpecifier)) { - throw new Error("moduleSpecifier must be a stringLiteral"); - } - return path.normalize(jshelpers.getTextOfIdentifierOrLiteral(moduleSpecifier)); - } - private recordEcmaNamedBindings(namedBindings: ts.NamedImportBindings, scope: ModuleScope, moduleRequest: string) { // import * as a from "a.js" if (ts.isNamespaceImport(namedBindings)) { @@ -508,7 +501,11 @@ export class Recorder { return; } - let moduleRequest: string = this.getNormalizeModuleSpecifier(node.moduleSpecifier); + if (!ts.isStringLiteral(node.moduleSpecifier)) { + throw new Error("moduleSpecifier must be a stringLiteral"); + } + + let moduleRequest: string = jshelpers.getTextOfIdentifierOrLiteral(node.moduleSpecifier); if (node.importClause) { let importClause: ts.ImportClause = node.importClause; @@ -521,7 +518,11 @@ export class Recorder { private recordEcmaExportDecl(node: ts.ExportDeclaration, scope: ModuleScope) { if (node.moduleSpecifier) { - let moduleRequest: string = this.getNormalizeModuleSpecifier(node.moduleSpecifier); + if (!ts.isStringLiteral(node.moduleSpecifier)) { + throw new Error("moduleSpecifier must be a stringLiteral"); + } + + let moduleRequest: string = jshelpers.getTextOfIdentifierOrLiteral(node.moduleSpecifier); if (node.exportClause) { let namedBindings: ts.NamedExportBindings = node.exportClause; -- Gitee