Last active
March 31, 2019 19:53
-
-
Save longlho/2b6c215c95e2b08f24e3300f43138115 to your computer and use it in GitHub Desktop.
transformer-p3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const visitor: ts.Visitor = (node: ts.Node): ts.Node => { | |
if (ts.isImportDeclaration(node) && node.moduleSpecifier) { | |
const newNode = ts.getMutableClone(node) // Clone the node | |
const oldPathWithQuotes = node.moduleSpecifier.getText(sf) | |
const newPath = rewritePath(oldPathWithQuotes.slice(1, oldPathWithQuotes.length - 2)) | |
newNode.moduleSpecifier = ts.createStringLiteral(newPath) | |
} | |
return ts.visitEachChild(node, visitor) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment