ng-packagr 12.1.0 → 12.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,19 +63,19 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraO
|
|
|
63
63
|
affectedFiles.add(result.affected);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
// Collect
|
|
66
|
+
// Collect program level diagnostics
|
|
67
67
|
const allDiagnostics = [
|
|
68
68
|
...angularCompiler.getOptionDiagnostics(),
|
|
69
69
|
...builder.getOptionsDiagnostics(),
|
|
70
70
|
...builder.getGlobalDiagnostics(),
|
|
71
|
-
...builder.getSyntacticDiagnostics(),
|
|
72
71
|
];
|
|
73
72
|
// Required to support asynchronous resource loading
|
|
74
73
|
// Must be done before creating transformers or getting template diagnostics
|
|
75
74
|
await angularCompiler.analyzeAsync();
|
|
75
|
+
// Collect source file specific diagnostics
|
|
76
76
|
for (const sourceFile of builder.getSourceFiles()) {
|
|
77
77
|
if (!ignoreForDiagnostics.has(sourceFile)) {
|
|
78
|
-
allDiagnostics.push(...builder.getSemanticDiagnostics(sourceFile));
|
|
78
|
+
allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));
|
|
79
79
|
}
|
|
80
80
|
if (sourceFile.isDeclarationFile) {
|
|
81
81
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ivy/compile-source-files.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,uEAA4E;AAC5E,qEAAuE;AACvE,iCAAiC;AACjC,oCAAoC;AAEpC,+DAAwF;AAExF,+CAA6E;AAE7E,qFAA+E;AAExE,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAAgC,EAChC,qBAA+C,EAC/C,YAA0C,EAC1C,mBAA6C,EAC7C,aAA6B,EAC7B,KAAe;IAEf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AAM,oBAAoB,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAClE,IAAI,QAAQ,KAAK,CAAC,EAAE;QAClB,IAAI,oBAAoB,CAAC,MAAM,EAAE;YAC/B,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;SAC/B;QAED,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC;QAChE,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE;YACjD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAClC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;aACzE;SACF;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACH,CAAC;AAjJD,gDAiJC","sourcesContent":["import * as ng from '@angular/compiler-cli';\nimport { OptimizeFor } from '@angular/compiler-cli/src/ngtsc/typecheck/api';\nimport { NgtscProgram } from '@angular/compiler-cli/src/ngtsc/program';\nimport * as ts from 'typescript';\nimport * as log from '../utils/log';\nimport * as ivy from '../ivy';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from './cache-compiler-host';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, isEntryPointInProgress } from '../ng-package/nodes';\nimport { NgccProcessor } from '../ngc/ngcc-processor';\nimport { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n extraOptions?: Partial<ng.CompilerOptions>,\n stylesheetProcessor?: ivy.StylesheetProcessor,\n ngccProcessor?: NgccProcessor,\n watch?: boolean,\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n\n const tsCompilerHost = ngccTransformCompilerHost(\n cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor),\n tsConfigOptions,\n ngccProcessor,\n moduleResolutionCache,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n cache.oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n }\n\n // Collect non-semantic diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ...builder.getSyntacticDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForDiagnostics.has(sourceFile)) {\n allDiagnostics.push(...builder.getSemanticDiagnostics(sourceFile));\n }\n\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Collect sources that are required to be emitted\n if (!ignoreForEmit.has(sourceFile) && !angularCompiler.incrementalDriver.safeToSkipEmit(sourceFile)) {\n // If required to emit, diagnostics may have also changed\n if (!ignoreForDiagnostics.has(sourceFile)) {\n affectedFiles.add(sourceFile);\n }\n } else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {\n // Use cached Angular diagnostics for unchanged and unaffected files\n const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);\n if (angularDiagnostics?.length) {\n allDiagnostics.push(...angularDiagnostics);\n }\n }\n }\n\n // Collect new Angular diagnostics for files affected by changes\n for (const affectedFile of affectedFiles) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, OptimizeFor.WholeProgram);\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);\n }\n\n // if we have an error we don't want to transpile.\n const exitCode = ng.exitCodeFromResult(allDiagnostics);\n const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);\n if (exitCode === 0) {\n if (formattedDiagnostics.length) {\n log.msg(formattedDiagnostics);\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForEmit.has(sourceFile)) {\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n }\n }\n } else {\n throw new Error(formattedDiagnostics);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ivy/compile-source-files.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,uEAA4E;AAC5E,qEAAuE;AACvE,iCAAiC;AACjC,oCAAoC;AAEpC,+DAAwF;AAExF,+CAA6E;AAE7E,qFAA+E;AAExE,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAAgC,EAChC,qBAA+C,EAC/C,YAA0C,EAC1C,mBAA6C,EAC7C,aAA6B,EAC7B,KAAe;IAEf,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAEvC,MAAM,eAAe,GAAuB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IACrF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAC,CAAC;IAExE,MAAM,cAAc,GAAG,wDAAyB,CAC9C,uCAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,EACjG,eAAe,EACf,aAAa,EACb,qBAAqB,CACtB,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,eAAe,GAAG,KAAK,CAAC,gBAAgB,CAAC;IAE/C,yEAAyE;IACzE,MAAM,cAAc,GAAG,IAAI,sBAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,CAA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from '@angular/compiler-cli';\nimport { OptimizeFor } from '@angular/compiler-cli/src/ngtsc/typecheck/api';\nimport { NgtscProgram } from '@angular/compiler-cli/src/ngtsc/program';\nimport * as ts from 'typescript';\nimport * as log from '../utils/log';\nimport * as ivy from '../ivy';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from './cache-compiler-host';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, isEntryPointInProgress } from '../ng-package/nodes';\nimport { NgccProcessor } from '../ngc/ngcc-processor';\nimport { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ng.ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n extraOptions?: Partial<ng.CompilerOptions>,\n stylesheetProcessor?: ivy.StylesheetProcessor,\n ngccProcessor?: NgccProcessor,\n watch?: boolean,\n) {\n log.debug(`ngc (v${ng.VERSION.full})`);\n\n const tsConfigOptions: ng.CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n\n const tsCompilerHost = ngccTransformCompilerHost(\n cacheCompilerHost(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor),\n tsConfigOptions,\n ngccProcessor,\n moduleResolutionCache,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n cache.oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForDiagnostics.has(sourceFile)) {\n allDiagnostics.push(\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n );\n }\n\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Collect sources that are required to be emitted\n if (!ignoreForEmit.has(sourceFile) && !angularCompiler.incrementalDriver.safeToSkipEmit(sourceFile)) {\n // If required to emit, diagnostics may have also changed\n if (!ignoreForDiagnostics.has(sourceFile)) {\n affectedFiles.add(sourceFile);\n }\n } else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {\n // Use cached Angular diagnostics for unchanged and unaffected files\n const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);\n if (angularDiagnostics?.length) {\n allDiagnostics.push(...angularDiagnostics);\n }\n }\n }\n\n // Collect new Angular diagnostics for files affected by changes\n for (const affectedFile of affectedFiles) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, OptimizeFor.WholeProgram);\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);\n }\n\n // if we have an error we don't want to transpile.\n const exitCode = ng.exitCodeFromResult(allDiagnostics);\n const formattedDiagnostics = ng.formatDiagnostics(allDiagnostics);\n if (exitCode === 0) {\n if (formattedDiagnostics.length) {\n log.msg(formattedDiagnostics);\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n for (const sourceFile of builder.getSourceFiles()) {\n if (!ignoreForEmit.has(sourceFile)) {\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n }\n }\n } else {\n throw new Error(formattedDiagnostics);\n }\n}\n"]}
|