Add opt-in behavior for custom transforms to support bundles

This commit is contained in:
Ron Buckton committed 2019-05-07 17:29:02 -07:00
1 parent 8c07b40cb6
commit 0c1a283bf9
8 files changed
+109 -39

No files matched your search

+20 -14
View File
@@ -140,22 +140,28 @@ namespace ts {
],
{
before: [
context => node => visitNode(node, function visitor(node: Node): Node {
if (isIdentifier(node) && node.text === "original") {
const newNode = createIdentifier("changed");
setSourceMapRange(newNode, {
pos: 0,
end: 7,
// Do not provide a custom skipTrivia function for `source`.
source: createSourceMapSource("another.html", "changed;")
});
return newNode;
}
return visitEachChild(node, visitor, context);
})
context => {
const transformSourceFile: Transformer<SourceFile> = node => visitNode(node, function visitor(node: Node): Node {
if (isIdentifier(node) && node.text === "original") {
const newNode = createIdentifier("changed");
setSourceMapRange(newNode, {
pos: 0,
end: 7,
// Do not provide a custom skipTrivia function for `source`.
source: createSourceMapSource("another.html", "changed;")
});
return newNode;
}
return visitEachChild(node, visitor, context);
});
return {
transformSourceFile,
transformBundle: node => createBundle(map(node.sourceFiles, transformSourceFile), node.prepends),
};
}
]
},
{ sourceMap: true }
{ sourceMap: true, outFile: "source.js" }
);
});