NgtscProgram.prototype.emit = function (opts) {
     var _this = this;
     var emitCallback = opts && opts.emitCallback || defaultEmitCallback;
     this.ensureAnalyzed();
     // Since there is no .d.ts transformation API, .d.ts files are transformed during write.
     var writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
         if (fileName.endsWith('.d.ts')) {
             data = sourceFiles.reduce(function (data, sf) { return _this.compilation.transformedDtsFor(sf.fileName, data); }, data);
         }
         else if (_this.closureCompilerEnabled && fileName.endsWith('.ts')) {
             data = nocollapse_hack_1.nocollapseHack(data);
         }
         _this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
     };
     var transforms = [transform_1.ivyTransformFactory(this.compilation, this.reflector, this.coreImportsFrom)];
     if (this.factoryToSourceInfo !== null) {
         transforms.push(factories_1.generatedFactoryTransform(this.factoryToSourceInfo, this.coreImportsFrom));
     }
     // Run the emit, including a custom transformer that will downlevel the Ivy decorators in code.
     var emitResult = emitCallback({
         program: this.tsProgram,
         host: this.host,
         options: this.options,
         emitOnlyDtsFiles: false, writeFile: writeFile,
         customTransformers: {
             before: transforms,
         },
     });
     return emitResult;
 };
Beispiel #2
0
 NgtscProgram.prototype.emit = function (opts) {
     var _this = this;
     var emitCallback = opts && opts.emitCallback || defaultEmitCallback;
     if (this.compilation === undefined) {
         this.compilation = this.makeCompilation();
         this.tsProgram.getSourceFiles()
             .filter(function (file) { return !file.fileName.endsWith('.d.ts'); })
             .forEach(function (file) { return _this.compilation.analyzeSync(file); });
     }
     // Since there is no .d.ts transformation API, .d.ts files are transformed during write.
     var writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
         if (fileName.endsWith('.d.ts')) {
             data = sourceFiles.reduce(function (data, sf) { return _this.compilation.transformedDtsFor(sf.fileName, data, fileName); }, data);
         }
         _this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
     };
     // Run the emit, including a custom transformer that will downlevel the Ivy decorators in code.
     var emitResult = emitCallback({
         program: this.tsProgram,
         host: this.host,
         options: this.options,
         emitOnlyDtsFiles: false, writeFile: writeFile,
         customTransformers: {
             before: [transform_1.ivyTransformFactory(this.compilation, this.reflector, this.coreImportsFrom)],
         },
     });
     return emitResult;
 };
Beispiel #3
0
 emit(opts) {
     const emitCallback = opts && opts.emitCallback || defaultEmitCallback;
     this.ensureAnalyzed();
     // Since there is no .d.ts transformation API, .d.ts files are transformed during write.
     const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
         if (fileName.endsWith('.d.ts')) {
             data = sourceFiles.reduce((data, sf) => this.compilation.transformedDtsFor(sf.fileName, data), data);
         }
         else if (this.closureCompilerEnabled && fileName.endsWith('.ts')) {
             data = nocollapse_hack_1.nocollapseHack(data);
         }
         this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
     };
     const customTransforms = opts && opts.customTransformers;
     const beforeTransforms = [transform_1.ivyTransformFactory(this.compilation, this.reflector, this.coreImportsFrom)];
     if (this.factoryToSourceInfo !== null) {
         beforeTransforms.push(shims_1.generatedFactoryTransform(this.factoryToSourceInfo, this.coreImportsFrom));
     }
     if (this.isCore) {
         beforeTransforms.push(switch_1.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: beforeTransforms,
             after: customTransforms && customTransforms.afterTs,
         },
     });
     return emitResult;
 }