feature(ngc): allow codegen to skip over .d.ts inputs (#11021)
This commit is contained in:
parent
aa5c8ca61f
commit
c7a874dd2f
|
@ -26,6 +26,7 @@ import {StaticReflector, StaticSymbol} from './static_reflector';
|
||||||
const nodeFs = require('fs');
|
const nodeFs = require('fs');
|
||||||
|
|
||||||
const GENERATED_FILES = /\.ngfactory\.ts$|\.css\.ts$|\.css\.shim\.ts$/;
|
const GENERATED_FILES = /\.ngfactory\.ts$|\.css\.ts$|\.css\.shim\.ts$/;
|
||||||
|
const GENERATED_OR_DTS_FILES = /\.d\.ts$|\.ngfactory\.ts$|\.css\.ts$|\.css\.shim\.ts$/;
|
||||||
|
|
||||||
const PREAMBLE = `/**
|
const PREAMBLE = `/**
|
||||||
* This file is generated by the Angular 2 template compiler.
|
* This file is generated by the Angular 2 template compiler.
|
||||||
|
@ -94,9 +95,13 @@ export class CodeGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
codegen(): Promise<any> {
|
codegen(): Promise<any> {
|
||||||
const filePaths = this.program.getSourceFiles()
|
// Compare with false since the default should be true
|
||||||
.map(sf => this.reflectorHost.getCanonicalFileName(sf.fileName))
|
const skipFileNames = (this.options.generateCodeForLibraries === false) ?
|
||||||
.filter(f => !GENERATED_FILES.test(f));
|
GENERATED_OR_DTS_FILES :
|
||||||
|
GENERATED_FILES;
|
||||||
|
let filePaths = this.program.getSourceFiles()
|
||||||
|
.filter(sf => !skipFileNames.test(sf.fileName))
|
||||||
|
.map(sf => this.reflectorHost.getCanonicalFileName(sf.fileName));
|
||||||
const fileMetas = filePaths.map((filePath) => this.readFileMetadata(filePath));
|
const fileMetas = filePaths.map((filePath) => this.readFileMetadata(filePath));
|
||||||
const ngModules = fileMetas.reduce((ngModules, fileMeta) => {
|
const ngModules = fileMetas.reduce((ngModules, fileMeta) => {
|
||||||
ngModules.push(...fileMeta.ngModules);
|
ngModules.push(...fileMeta.ngModules);
|
||||||
|
|
|
@ -16,6 +16,11 @@ interface Options extends ts.CompilerOptions {
|
||||||
// Don't produce .ngfactory.ts or .css.shim.ts files
|
// Don't produce .ngfactory.ts or .css.shim.ts files
|
||||||
skipTemplateCodegen: boolean;
|
skipTemplateCodegen: boolean;
|
||||||
|
|
||||||
|
// Whether to generate code for library code.
|
||||||
|
// If true, produce .ngfactory.ts and .css.shim.ts files for .d.ts inputs.
|
||||||
|
// Default is true.
|
||||||
|
generateCodeForLibraries?: boolean;
|
||||||
|
|
||||||
// Print extra information while running the compiler
|
// Print extra information while running the compiler
|
||||||
trace: boolean;
|
trace: boolean;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue