fix(ivy): ngtsc program emit ignoring custom transformers (#27837)
Fixes the `customTransformers` that are passed to the `NgtscProgram.emit` not being passed along. PR Close #27837
This commit is contained in:

committed by
Kara Erickson

parent
48555f95c6
commit
13d23f315b
@ -22,7 +22,7 @@ import {performWatchCompilation, createPerformWatchHost} from './perform_watch'
|
||||
|
||||
export function main(
|
||||
args: string[], consoleError: (s: string) => void = console.error,
|
||||
config?: NgcParsedConfiguration): number {
|
||||
config?: NgcParsedConfiguration, customTransformers?: api.CustomTransformers): number {
|
||||
let {project, rootNames, options, errors: configErrors, watch, emitFlags} =
|
||||
config || readNgcCommandLineAndConfiguration(args);
|
||||
if (configErrors.length) {
|
||||
@ -32,8 +32,12 @@ export function main(
|
||||
const result = watchMode(project, options, consoleError);
|
||||
return reportErrorsAndExit(result.firstCompileResult, options, consoleError);
|
||||
}
|
||||
const {diagnostics: compileDiags} = performCompilation(
|
||||
{rootNames, options, emitFlags, emitCallback: createEmitCallback(options)});
|
||||
const {diagnostics: compileDiags} = performCompilation({
|
||||
rootNames,
|
||||
options,
|
||||
emitFlags,
|
||||
emitCallback: createEmitCallback(options), customTransformers
|
||||
});
|
||||
return reportErrorsAndExit(compileDiags, options, consoleError);
|
||||
}
|
||||
|
||||
|
@ -208,14 +208,21 @@ 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)];
|
||||
|
||||
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,
|
||||
@ -223,7 +230,8 @@ export class NgtscProgram implements api.Program {
|
||||
options: this.options,
|
||||
emitOnlyDtsFiles: false, writeFile,
|
||||
customTransformers: {
|
||||
before: transforms,
|
||||
before: beforeTransforms,
|
||||
after: customTransforms && customTransforms.afterTs,
|
||||
},
|
||||
});
|
||||
return emitResult;
|
||||
|
Reference in New Issue
Block a user