Skip to content

Commit

Permalink
fix(ivy): ngtsc program emit ignoring custom transformers
Browse files Browse the repository at this point in the history
Fixes the `customTransformers` that are passed to the `NgtscProgram.emit` not being passed along.
  • Loading branch information
crisbeto committed Dec 26, 2018
1 parent 13eb57a commit 1877bd5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/compiler-cli/src/ngtsc/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,31 @@ export class NgtscProgram implements api.Program {
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
};

const transforms =
const customTransforms = opts && opts.customTransformers;
const beforeTransforms =
[ivyTransformFactory(this.compilation !, this.reflector, this.coreImportsFrom)];
const afterTransforms = customTransforms && customTransforms.afterTs || [];

if (this.factoryToSourceInfo !== null) {
transforms.push(generatedFactoryTransform(this.factoryToSourceInfo, this.coreImportsFrom));
beforeTransforms.push(
generatedFactoryTransform(this.factoryToSourceInfo, this.coreImportsFrom));
}
if (this.isCore) {
transforms.push(ivySwitchTransform);
beforeTransforms.push(ivySwitchTransform);
}
if (customTransforms && customTransforms.beforeTs) {
beforeTransforms.push(...customTransforms.beforeTs);
}

// Run the emit, including a custom transformer that will downlevel the Ivy decorators in code.
const emitResult = emitCallback({
program: this.tsProgram,
host: this.host,
options: this.options,
emitOnlyDtsFiles: false, writeFile,
customTransformers: {
before: transforms,
before: beforeTransforms,
after: afterTransforms,
},
});
return emitResult;
Expand Down

0 comments on commit 1877bd5

Please sign in to comment.