ng-packagr 16.2.1 → 16.2.2
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.
- package/lib/ng-package/entry-point/analyse-sources.transform.js +1 -1
- package/lib/ng-package/entry-point/analyse-sources.transform.js.map +1 -1
- package/lib/ngc/compile-source-files.js +2 -13
- package/lib/ngc/compile-source-files.js.map +1 -1
- package/lib/ts/cache-compiler-host.d.ts +1 -1
- package/lib/ts/cache-compiler-host.js +1 -5
- package/lib/ts/cache-compiler-host.js.map +1 -1
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ function analyseEntryPoint(graph, entryPoint, entryPoints) {
|
|
|
43
43
|
target: typescript_1.default.ScriptTarget.Latest,
|
|
44
44
|
strict: false,
|
|
45
45
|
};
|
|
46
|
-
const compilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, undefined,
|
|
46
|
+
const compilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, undefined, analysesSourcesFileCache);
|
|
47
47
|
const potentialDependencies = new Set();
|
|
48
48
|
compilerHost.resolveTypeReferenceDirectives = (moduleNames, containingFile, redirectedReference, options) => {
|
|
49
49
|
return moduleNames.map(name => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/analyse-sources.transform.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+C;AAC/C,+BAAiC;AACjC,4DAA4B;AAG5B,sEAAiE;AACjE,yCAAwC;AACxC,2CAAkD;AAClD,oCAAgF;AAEnE,QAAA,uBAAuB,GAAc,IAAA,WAAI,EACpD,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;IACV,MAAM,WAAW,GAAqB,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAq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AAC;IAEnH,UAAU,CAAC,KAAK,CAAC,WAAW,GAAG,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IAE1F,MAAM,iBAAiB,GAAmC,EAAE,CAAC;IAC7D,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE;QAC7B,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;KACvD;IAED,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE;QAC9C,MAAM,GAAG,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAE1C,IAAI,GAAG,EAAE;YACP,IAAA,WAAK,EAAC,iCAAiC,QAAQ,OAAO,UAAU,EAAE,CAAC,CAAC;YAEpE,IAAI,QAAQ,KAAK,UAAU,EAAE;gBAC3B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;aACnF;YAED,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,KAAK,CAAC,CAAC,EAAE;gBACnC,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,iCAAiC,QAAQ,GAAG,CAAC,CAAC;aACxF;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAC3B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,yBAAyB,QAAQ,iBAAiB,CAAC,CAAC;SAC9F;KACF;AACH,CAAC","sourcesContent":["import { basename, dirname, join } from 'path';\nimport { map, pipe } from 'rxjs';\nimport ts from 'typescript';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Transform } from '../../graph/transform';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { debug } from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, isEntryPoint, isPackage } from '../nodes';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n const dirtyEntryPoints: EntryPointNode[] = entryPoints.filter(x => x.state !== 'done');\n\n for (const entryPoint of dirtyEntryPoints) {\n analyseEntryPoint(graph, entryPoint, entryPoints);\n }\n\n return graph;\n }),\n);\n\n/**\n * Analyses an entrypoint, searching for TypeScript dependencies and additional resources (Templates and Stylesheets).\n *\n * @param graph Build graph\n * @param entryPoint Current entry point that should be analysed.\n * @param entryPoints List of all entry points.\n */\nfunction analyseEntryPoint(graph: BuildGraph, entryPoint: EntryPointNode, entryPoints: EntryPointNode[]) {\n const { oldPrograms, analysesSourcesFileCache, moduleResolutionCache } = entryPoint.cache;\n const oldProgram = oldPrograms && (oldPrograms['analysis'] as ts.Program | undefined);\n const { moduleId } = entryPoint.data.entryPoint;\n const packageNode: PackageNode = graph.find(isPackage);\n const primaryModuleId = packageNode.data.primary.moduleId;\n\n debug(`Analysing sources for ${moduleId}`);\n const tsConfigOptions: ts.CompilerOptions = {\n // Needed because of `Property 'extendedDiagnostics' is incompatible with index signature.`\n ...(entryPoint.data.tsConfig.options as ts.CompilerOptions),\n skipLibCheck: true,\n noLib: true,\n noEmit: true,\n types: [],\n target: ts.ScriptTarget.Latest,\n strict: false,\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n undefined,\n undefined,\n analysesSourcesFileCache,\n );\n\n const potentialDependencies = new Set<string>();\n\n compilerHost.resolveTypeReferenceDirectives = (\n moduleNames: string[] | ts.FileReference[],\n containingFile: string,\n redirectedReference: ts.ResolvedProjectReference | undefined,\n options: ts.CompilerOptions,\n ) => {\n return moduleNames.map(name => {\n const moduleName = typeof name === 'string' ? name : name.fileName;\n\n if (!moduleName.startsWith('.')) {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n\n return undefined;\n }\n\n const result = ts.resolveTypeReferenceDirective(\n moduleName,\n ensureUnixPath(containingFile),\n options,\n compilerHost,\n redirectedReference,\n ).resolvedTypeReferenceDirective;\n\n return result;\n });\n };\n\n compilerHost.resolveModuleNames = (\n moduleNames: string[],\n containingFile: string,\n _reusedNames: string[] | undefined,\n redirectedReference: ts.ResolvedProjectReference | undefined,\n options: ts.CompilerOptions,\n ) => {\n return moduleNames.map(moduleName => {\n if (!moduleName.startsWith('.')) {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n\n return undefined;\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n options,\n compilerHost,\n moduleResolutionCache,\n redirectedReference,\n );\n\n return resolvedModule;\n });\n };\n\n const program: ts.Program = ts.createProgram(\n entryPoint.data.tsConfig.rootNames,\n tsConfigOptions,\n compilerHost,\n oldProgram,\n );\n\n // If an index file exists parallel to the entryFilePath it is not valid as index should be reserved as an\n // entry file of an entry-point based on node resolution strategy.\n if (basename(entryPoint.data.entryPoint.entryFilePath) !== 'index.ts') {\n const potentialIndexPath = join(dirname(entryPoint.data.entryPoint.entryFilePath), 'index.ts');\n const sf = program.getSourceFile(ensureUnixPath(potentialIndexPath));\n\n if (sf) {\n throw new Error(\n `Entry point '${moduleId}' has an 'index.ts' parallel to the 'entryFilePath'. ` +\n `The 'entryFilePath' should be updated to point to the 'index.ts' file.\\n` +\n `Full path: ${potentialIndexPath}`,\n );\n }\n }\n\n debug(`tsc program structure is reused: ${oldProgram ? (oldProgram as any).structureIsReused : 'No old program'}`);\n\n entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };\n\n const entryPointsMapped: Record<string, EntryPointNode> = {};\n for (const dep of entryPoints) {\n entryPointsMapped[dep.data.entryPoint.moduleId] = dep;\n }\n\n for (const moduleName of potentialDependencies) {\n const dep = entryPointsMapped[moduleName];\n\n if (dep) {\n debug(`Found entry point dependency: ${moduleId} -> ${moduleName}`);\n\n if (moduleId === moduleName) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on itself.`);\n }\n\n if (dep.some(n => entryPoint === n)) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on ${moduleId}.`);\n }\n\n entryPoint.dependsOn(dep);\n } else {\n throw new Error(`Entry point ${moduleName} which is required by ${moduleId} doesn't exist.`);\n }\n }\n}\n"]}
|
|
@@ -46,8 +46,7 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, option
|
|
|
46
46
|
(_a = tsConfigOptions.incremental) !== null && _a !== void 0 ? _a : (tsConfigOptions.incremental = true);
|
|
47
47
|
(_b = tsConfigOptions.tsBuildInfoFile) !== null && _b !== void 0 ? _b : (tsConfigOptions.tsBuildInfoFile = (0, node_path_1.join)(cacheDir, `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`));
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
const tsCompilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, emittedFiles, stylesheetProcessor, inlineStyleLanguage);
|
|
49
|
+
const tsCompilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage);
|
|
51
50
|
const cache = entryPoint.cache;
|
|
52
51
|
const sourceFileCache = cache.sourcesFileCache;
|
|
53
52
|
let usingBuildInfo = false;
|
|
@@ -161,24 +160,14 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, option
|
|
|
161
160
|
if (otherDiagnostics.length) {
|
|
162
161
|
log.msg(formatDiagnostics(errorDiagnostics));
|
|
163
162
|
}
|
|
164
|
-
const transformers = angularCompiler.prepareEmit().transformers;
|
|
165
|
-
if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {
|
|
166
|
-
// TypeScript will loop until there are no more affected files in the program
|
|
167
|
-
while (builder.emitNextAffectedFile(undefined, undefined, undefined, transformers)) {
|
|
168
|
-
// empty
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
163
|
if (errorDiagnostics.length) {
|
|
172
164
|
throw new Error(formatDiagnostics(errorDiagnostics));
|
|
173
165
|
}
|
|
166
|
+
const transformers = angularCompiler.prepareEmit().transformers;
|
|
174
167
|
for (const sourceFile of builder.getSourceFiles()) {
|
|
175
168
|
if (ignoreForEmit.has(sourceFile)) {
|
|
176
169
|
continue;
|
|
177
170
|
}
|
|
178
|
-
if (emittedFiles.has(sourceFile.fileName)) {
|
|
179
|
-
angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
171
|
if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {
|
|
183
172
|
continue;
|
|
184
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAiC;AACjC,4DAA4B;AAE5B,+CAAqG;AAGrG,mEAA4F;AAC5F,kDAAoC;AACpC,8DAAyD;AAElD,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,OAAyB,EACzB,YAAuC,EACvC,mBAAyC;;IAEzC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAA,+BAAa,GAAE,CAAC;IAClE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAA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,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;KACtD;IAED,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE;QACjD,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACjC,SAAS;SACV;QAED,IAAI,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YACzC,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;YACxE,SAAS;SACV;QAED,IAAI,eAAe,CAAC,sBAAsB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;YACrE,SAAS;SACV;QAED,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACxE,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;KACzE;AACH,CAAC;AAhND,gDAgNC","sourcesContent":["import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, PackageNode, isEntryPointInProgress, isPackage } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport * as log from '../utils/log';\nimport { ngCompilerCli } from '../utils/ng-compiler-cli';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { NgtscProgram, formatDiagnostics } = await ngCompilerCli();\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const emittedFiles = new Set<string>();\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n emittedFiles,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\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 || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n 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 // eslint-disable-next-line no-constant-condition\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 // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\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 }\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 continue;\n }\n\n allDiagnostics.push(\n ...builder.getDeclarationDiagnostics(sourceFile),\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n );\n\n // Declaration files cannot have template diagnostics\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(sourceFile, angularDiagnostics);\n }\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n // TypeScript will loop until there are no more affected files in the program\n while (builder.emitNextAffectedFile(undefined, undefined, undefined, transformers)) {\n // empty\n }\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (emittedFiles.has(sourceFile.fileName)) {\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAiC;AACjC,4DAA4B;AAE5B,+CAAqG;AAGrG,mEAA4F;AAC5F,kDAAoC;AACpC,8DAAyD;AAElD,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,OAAyB,EACzB,YAAuC,EACvC,mBAAyC;;IAEzC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAA,+BAAa,GAAE,CAAC;IAClE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC;IAEnE,MAAM,QAAQ,GAAG,YAAY,IAAI,cAAc,CAAC;IAChD,IAAI,QAAQ,EAAE;QACZ,MAAA,eAAe,CAAC,WAAW,oCAA3B,eAAe,CAAC,WAAW,GAAK,IAAI,EAAC;QACrC,MAAA,eAAe,CAAC,eAAe,oCAA/B,eAAe,CAAC,eAAe,GAAK,IAAA,gBAAI,EACtC,QAAQ,EACR,eAAe,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,cAAc,CACvE,EAAC;KACH;IAED,MAAM,cAAc,GAAG,IAAA,uCAAiB,EACtC,KAAK,EACL,UAAU,EACV,eAAe,EACf,qB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AG,EAAE,CAAC;IAC5B,MAAM,gBAAgB,GAAG,EAAE,CAAC;IAC5B,KAAK,MAAM,UAAU,IAAI,cAAc,EAAE;QACvC,IAAI,UAAU,CAAC,QAAQ,KAAK,oBAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE;YACvD,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACnC;aAAM;YACL,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACnC;KACF;IAED,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC9C;IAED,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;KACtD;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC;IAChE,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE;QACjD,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACjC,SAAS;SACV;QAED,IAAI,eAAe,CAAC,sBAAsB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;YACrE,SAAS;SACV;QAED,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACxE,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;KACzE;AACH,CAAC;AAlMD,gDAkMC","sourcesContent":["import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, PackageNode, isEntryPointInProgress, isPackage } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport * as log from '../utils/log';\nimport { ngCompilerCli } from '../utils/ng-compiler-cli';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { NgtscProgram, formatDiagnostics } = await ngCompilerCli();\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\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 || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n 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 // eslint-disable-next-line no-constant-condition\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 // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\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 }\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 continue;\n }\n\n allDiagnostics.push(\n ...builder.getDeclarationDiagnostics(sourceFile),\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n );\n\n // Declaration files cannot have template diagnostics\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(sourceFile, angularDiagnostics);\n }\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(errorDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n}\n"]}
|
|
@@ -5,5 +5,5 @@ import { FileCache } from '../file-system/file-cache';
|
|
|
5
5
|
import { BuildGraph } from '../graph/build-graph';
|
|
6
6
|
import { EntryPointNode } from '../ng-package/nodes';
|
|
7
7
|
import { StylesheetProcessor } from '../styles/stylesheet-processor';
|
|
8
|
-
export declare function cacheCompilerHost(graph: BuildGraph, entryPoint: EntryPointNode, compilerOptions: CompilerOptions, moduleResolutionCache: ts.ModuleResolutionCache,
|
|
8
|
+
export declare function cacheCompilerHost(graph: BuildGraph, entryPoint: EntryPointNode, compilerOptions: CompilerOptions, moduleResolutionCache: ts.ModuleResolutionCache, stylesheetProcessor?: StylesheetProcessor, inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'], sourcesFileCache?: FileCache): CompilerHost;
|
|
9
9
|
export declare function augmentProgramWithVersioning(program: ts.Program): void;
|
|
@@ -35,7 +35,7 @@ const typescript_1 = __importDefault(require("typescript"));
|
|
|
35
35
|
const node_1 = require("../graph/node");
|
|
36
36
|
const nodes_1 = require("../ng-package/nodes");
|
|
37
37
|
const path_1 = require("../utils/path");
|
|
38
|
-
function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache,
|
|
38
|
+
function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage, sourcesFileCache = entryPoint.cache.sourcesFileCache) {
|
|
39
39
|
const compilerHost = typescript_1.default.createIncrementalCompilerHost(compilerOptions);
|
|
40
40
|
const getNode = (fileName) => {
|
|
41
41
|
const nodeUri = (0, nodes_1.fileUrl)((0, path_1.ensureUnixPath)(fileName));
|
|
@@ -96,7 +96,6 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
sourceFiles.forEach(source => {
|
|
99
|
-
emittedFiles === null || emittedFiles === void 0 ? void 0 : emittedFiles.add(source.fileName);
|
|
100
99
|
const cache = sourcesFileCache.getOrCreate(source.fileName);
|
|
101
100
|
if (!cache.declarationFileName) {
|
|
102
101
|
cache.declarationFileName = (0, path_1.ensureUnixPath)(fileName);
|
|
@@ -118,9 +117,6 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
118
117
|
version,
|
|
119
118
|
map,
|
|
120
119
|
});
|
|
121
|
-
sourceFiles.forEach(source => {
|
|
122
|
-
emittedFiles === null || emittedFiles === void 0 ? void 0 : emittedFiles.add(source.fileName);
|
|
123
|
-
});
|
|
124
120
|
}
|
|
125
121
|
compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
126
122
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAkD;AAElD,mCAAoC;AACpC,8DAAiC;AACjC,2CAA6B;AAC7B,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,YAA0B,EAC1B,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CA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port { createHash } from 'crypto';\nimport assert from 'node:assert';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n emittedFiles?: Set<string>,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n const { flatModuleFile, destinationPath, entryFile } = entryPoint.data.entryPoint;\n const flatModuleFileDtsFilename = `${flatModuleFile}.d.ts`;\n const flatModuleFileDtsPath = ensureUnixPath(path.join(destinationPath, flatModuleFileDtsFilename));\n const hasIndexEntryFile = path.basename(entryFile.toLowerCase()) === 'index.ts';\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.includes('.ngtypecheck.')) {\n return;\n }\n\n if (!sourceFiles?.length && fileName.endsWith('.tsbuildinfo')) {\n // Save builder info contents to specified location\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n\n return;\n }\n\n assert(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);\n\n if (fileName.endsWith('.d.ts')) {\n if (fileName === flatModuleFileDtsPath) {\n if (hasIndexEntryFile) {\n // In case the entry file is index.ts, we should not emit the `d.ts` which are a re-export of the `index.ts`.\n // Because it will cause a conflict.\n return;\n } else {\n // Rename file to index.d.ts so that TypeScript can resolve types without\n // them needing to be referenced in the package.json manifest.\n fileName = fileName.replace(flatModuleFileDtsFilename, 'index.d.ts');\n }\n }\n\n sourceFiles.forEach(source => {\n emittedFiles?.add(source.fileName);\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n } else {\n fileName = fileName.replace(/\\.js(\\.map)?$/, '.mjs$1');\n const outputCache = entryPoint.cache.outputCache;\n\n // Extract inline sourcemap which will later be used by rolluo.\n const version = createHash('sha256').update(data).digest('hex');\n let map = undefined;\n if (fileName.endsWith('.mjs')) {\n const cachedData = outputCache.get(fileName);\n map = cachedData?.version === version ? cachedData.map : convertSourceMap.fromComment(data).toJSON();\n }\n\n outputCache.set(fileName, {\n content: data,\n version,\n map,\n });\n\n sourceFiles.forEach(source => {\n emittedFiles?.add(source.fileName);\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n\n return cache.content;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: compilerHost.readFile.call(this, fileName),\n });\n }\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n transformResource: async (data, context) => {\n if (context.resourceFile || context.type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const key = createHash('sha1').update(data).digest('hex');\n const fileName = `${context.containingFile}-${key}.${inlineStyleLanguage}`;\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: data,\n });\n\n const virtualFileNode = getNode(fileName);\n const containingFileNode = getNode(context.containingFile);\n virtualFileNode.dependsOn(containingFileNode);\n }\n\n cache.exists = true;\n\n return { content: cache.content };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAkD;AAElD,mCAAoC;AACpC,8DAAiC;AACjC,2CAA6B;AAC7B,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,WAAI,CAAC,OAAO,CAAC,CAAC;YACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC/B,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAClF,MAAM,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,GAAsD,kBAAkB,CAAC,GAAG,UAAU,CAAC,CAAC;QAEnG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC9B,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aACrE;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,oEAaC","sourcesContent":["import type { CompilerHost, CompilerOptions } from '@angular/compiler-cli';\nimport convertSourceMap from 'convert-source-map';\n\nimport { createHash } from 'crypto';\nimport assert from 'node:assert';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n const { flatModuleFile, destinationPath, entryFile } = entryPoint.data.entryPoint;\n const flatModuleFileDtsFilename = `${flatModuleFile}.d.ts`;\n const flatModuleFileDtsPath = ensureUnixPath(path.join(destinationPath, flatModuleFileDtsFilename));\n const hasIndexEntryFile = path.basename(entryFile.toLowerCase()) === 'index.ts';\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.includes('.ngtypecheck.')) {\n return;\n }\n\n if (!sourceFiles?.length && fileName.endsWith('.tsbuildinfo')) {\n // Save builder info contents to specified location\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n\n return;\n }\n\n assert(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);\n\n if (fileName.endsWith('.d.ts')) {\n if (fileName === flatModuleFileDtsPath) {\n if (hasIndexEntryFile) {\n // In case the entry file is index.ts, we should not emit the `d.ts` which are a re-export of the `index.ts`.\n // Because it will cause a conflict.\n return;\n } else {\n // Rename file to index.d.ts so that TypeScript can resolve types without\n // them needing to be referenced in the package.json manifest.\n fileName = fileName.replace(flatModuleFileDtsFilename, 'index.d.ts');\n }\n }\n\n sourceFiles.forEach(source => {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n } else {\n fileName = fileName.replace(/\\.js(\\.map)?$/, '.mjs$1');\n const outputCache = entryPoint.cache.outputCache;\n\n // Extract inline sourcemap which will later be used by rolluo.\n const version = createHash('sha256').update(data).digest('hex');\n let map = undefined;\n if (fileName.endsWith('.mjs')) {\n const cachedData = outputCache.get(fileName);\n map = cachedData?.version === version ? cachedData.map : convertSourceMap.fromComment(data).toJSON();\n }\n\n outputCache.set(fileName, {\n content: data,\n version,\n map,\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n\n return cache.content;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: compilerHost.readFile.call(this, fileName),\n });\n }\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n transformResource: async (data, context) => {\n if (context.resourceFile || context.type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const key = createHash('sha1').update(data).digest('hex');\n const fileName = `${context.containingFile}-${key}.${inlineStyleLanguage}`;\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: data,\n });\n\n const virtualFileNode = getNode(fileName);\n const containingFileNode = getNode(context.containingFile);\n virtualFileNode.dependsOn(containingFileNode);\n }\n\n cache.exists = true;\n\n return { content: cache.content };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
|