From f5aee9af9401866632a65aeb6cf69f532427e5f1 Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Sat, 26 May 2018 13:18:44 +0300 Subject: [PATCH] fix(ts-transform-plugin): commonjs module fix #1 --- packages/ts-transform-paths/src/index.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/ts-transform-paths/src/index.ts b/packages/ts-transform-paths/src/index.ts index 0861028..462e8cf 100644 --- a/packages/ts-transform-paths/src/index.ts +++ b/packages/ts-transform-paths/src/index.ts @@ -63,15 +63,19 @@ function importPathVisitor( fixNode.pos = cachedPos fixNode.end = cachedPos + newStr.length - // const newSpec = ts.createLiteral(newImport) + const newSpec = ts.createLiteral(newImport) - // if (ts.isImportDeclaration(node)) return ts.updateImportDeclaration( - // node, undefined, undefined, undefined, newSpec - // ) + if (ts.isImportDeclaration(node)) return ts.updateImportDeclaration( + node, undefined, undefined, undefined, newSpec + ) + + if (ts.isExportDeclaration(node)) return ts.updateExportDeclaration( + node, undefined, undefined, undefined, newSpec + ) - // if (ts.isExportDeclaration(node)) return ts.updateExportDeclaration( - // node, undefined, undefined, undefined, newSpec - // ) + if (ts.isCallExpression(node)) return ts.updateCall( + node, node.expression, undefined, [newSpec] + ) } function patchEmitFiles(host: any): ts.TransformerFactory[] {