ng-packagr 16.1.0-next.0 → 16.1.0
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/file-system/file-watcher.js +1 -1
- package/lib/file-system/file-watcher.js.map +1 -1
- 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/ng-package/entry-point/compile-ngc.transform.js +2 -2
- package/lib/ng-package/entry-point/compile-ngc.transform.js.map +1 -1
- package/lib/ng-package/package.transform.js +2 -2
- package/lib/ng-package/package.transform.js.map +1 -1
- package/lib/ngc/compile-source-files.d.ts +3 -2
- package/lib/ngc/compile-source-files.js +64 -28
- 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 +15 -1
- package/lib/ts/cache-compiler-host.js.map +1 -1
- package/lib/ts/tsconfig.js +1 -2
- package/lib/ts/tsconfig.js.map +1 -1
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ function createFileWatch(basePaths, ignoredPaths = []) {
|
|
|
34
34
|
log.debug(`Watching for changes: basePath: ${basePaths}, ignoredPaths: ${ignoredPaths}`);
|
|
35
35
|
const watch = chokidar.watch([], {
|
|
36
36
|
ignoreInitial: true,
|
|
37
|
-
ignored: [...ignoredPaths, /\.map$/],
|
|
37
|
+
ignored: [...ignoredPaths, /\.map$/, /.tsbuildinfo$/],
|
|
38
38
|
persistent: true,
|
|
39
39
|
});
|
|
40
40
|
const isLinux = (0, os_1.platform)() === 'linux';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAqC;AACrC,2BAA8B;AAC9B,2CAA6B;AAC7B,+BAA4C;AAC5C,kDAAoC;AACpC,wCAA+C;AAU/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K,QAAQ,EAAE;YAC/C,2GAA2G;YAC3G,OAAO;SACR;QAED,QAAQ,CAAC,IAAI,CAAC;YACZ,QAAQ,EAAE,IAAA,qBAAc,EAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChD,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,IAAI,iBAAU,CAAC,QAAQ,CAAC,EAAE;YACtC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAyB,EAAE,QAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;YAE9G,kEAAkE;YAClE,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AA9CD,0CA8CC","sourcesContent":["import * as chokidar from 'chokidar';\nimport { platform } from 'os';\nimport * as path from 'path';\nimport { Observable, Observer } from 'rxjs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\ntype AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';\nexport type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;\n\nexport interface FileChangedEvent {\n filePath: string;\n event: FileWatchEvent;\n}\n\nexport function createFileWatch(\n basePaths: string | string[],\n ignoredPaths: (RegExp | string)[] = [],\n): {\n watcher: chokidar.FSWatcher;\n onFileChange: Observable<FileChangedEvent>;\n} {\n log.debug(`Watching for changes: basePath: ${basePaths}, ignoredPaths: ${ignoredPaths}`);\n\n const watch = chokidar.watch([], {\n ignoreInitial: true,\n ignored: [...ignoredPaths, /\\.map$/, /.tsbuildinfo$/],\n persistent: true,\n });\n\n const isLinux = platform() === 'linux';\n const handleFileChange = (event: AllFileWatchEvents, filePath: string, observer: Observer<FileChangedEvent>) => {\n log.debug(`Watch: Path changed. Event: ${event}, Path: ${filePath}`);\n\n if (isLinux) {\n // Workaround for Linux where chokidar will not handle future events\n // for files that were unlinked and immediately recreated.\n watch.unwatch(filePath);\n watch.add(filePath);\n }\n\n if (event === 'unlinkDir' || event === 'addDir') {\n // we don't need to trigger on directory removed or renamed as chokidar will fire the changes for each file\n return;\n }\n\n observer.next({\n filePath: ensureUnixPath(path.resolve(filePath)),\n event,\n });\n };\n\n return {\n watcher: watch,\n onFileChange: new Observable(observer => {\n watch.on('all', (event: AllFileWatchEvents, filePath: string) => handleFileChange(event, filePath, observer));\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return () => watch.close();\n }),\n };\n}\n"]}
|
|
@@ -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, analysesSourcesFileCache);
|
|
46
|
+
const compilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, 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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7B,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"]}
|
|
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,GAAqB,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IAEvF,KAAK,MAAM,UAAU,IAAI,gBAAgB,EAAE;QACzC,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;KACnD;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC,CACH,CAAC;AAEF;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,KAAiB,EAAE,UAA0B,EAAE,WAA6B;IACrG,MAAM,EAAE,WAAW,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;IAC1F,MAAM,UAAU,GAAG,WAAW,IAAK,WAAW,CAAC,UAAU,CAA4B,CAAC;IACtF,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAChD,MAAM,WAAW,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACvD,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAE1D,IAAA,WAAK,EAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAuB;QAC1C,2FAA2F;QAC3F,GAAI,UAAU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C,oCAAoC,UAAU,CAAC,CAAC,CAAE,UAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC;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 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"]}
|
|
@@ -55,12 +55,12 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
|
|
|
55
55
|
const { moduleResolutionCache } = entryPoint.cache;
|
|
56
56
|
spinner.start(`Compiling with Angular sources in Ivy ${tsConfig.options.compilationMode || 'full'} compilation mode.`);
|
|
57
57
|
(_a = (_c = entryPoint.cache).stylesheetProcessor) !== null && _a !== void 0 ? _a : (_c.stylesheetProcessor = new StylesheetProcessor(projectBasePath, basePath, cssUrl, styleIncludePaths, options.cacheEnabled && options.cacheDirectory));
|
|
58
|
-
await (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, {
|
|
58
|
+
await (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, options, {
|
|
59
59
|
outDir: path.dirname(esm2022),
|
|
60
60
|
declarationDir: path.dirname(declarations),
|
|
61
61
|
declaration: true,
|
|
62
62
|
target: typescript_1.default.ScriptTarget.ES2022,
|
|
63
|
-
}, entryPoint.cache.stylesheetProcessor
|
|
63
|
+
}, entryPoint.cache.stylesheetProcessor);
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
66
|
spinner.fail();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-ngc.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/compile-ngc.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8C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EACf,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,cAAc,CAC/C,EAAC;YAEF,MAAM,IAAA,yCAAkB,EACtB,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB;gBACE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC7B,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;gBAC1C,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;aAC/B,EACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"compile-ngc.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/compile-ngc.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,2CAA6B;AAC7B,4DAA4B;AAC5B,qDAAwE;AACxE,yEAAoE;AAEpE,gDAAiE;AACjE,oCAAwG;AAGjG,MAAM,0BAA0B,GAAG,CACxC,mBAAoD,EACpD,OAAyB,EACd,EAAE;IACb,OAAO,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;;;QACxC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;YAClB,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAqB,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;QACjE,MAAM,UAAU,GAAmB,WAAW,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;QACzD,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAE5D,IAAI;YACF,sCAAsC;YACtC,MAAM,QAAQ,GAAG,IA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B,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA9DW,QAAA,0BAA0B,8BA8DrC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { StylesheetProcessor as StylesheetProcessorClass } from '../../styles/stylesheet-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport { EntryPointNode, PackageNode, isEntryPoint, isEntryPointInProgress, isPackage } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\nexport const compileNgcTransformFactory = (\n StylesheetProcessor: typeof StylesheetProcessorClass,\n options: NgPackagrOptions,\n): Transform => {\n return transformFromPromise(async graph => {\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n const entryPoint: EntryPointNode = entryPoints.find(isEntryPointInProgress());\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const projectBasePath = ngPackageNode.data.primary.basePath;\n\n try {\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2022: esm2022, declarations } = entryPoint.data.destinationFiles;\n const { basePath, cssUrl, styleIncludePaths } = entryPoint.data.entryPoint;\n const { moduleResolutionCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in Ivy ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n\n entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(\n projectBasePath,\n basePath,\n cssUrl,\n styleIncludePaths,\n options.cacheEnabled && options.cacheDirectory,\n );\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n options,\n {\n outDir: path.dirname(esm2022),\n declarationDir: path.dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2022,\n },\n entryPoint.cache.stylesheetProcessor,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n } finally {\n if (!options.watch) {\n entryPoint.cache.stylesheetProcessor?.destroy();\n }\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
|
|
@@ -127,7 +127,7 @@ const watchTransformFactory = (project, _options, analyseSourcesTransform, entry
|
|
|
127
127
|
for (const entryPoint of graph.filter(nodes_1.isEntryPoint)) {
|
|
128
128
|
const isDirty = [...allNodesToClean].some(dependent => entryPoint.dependents.has(dependent));
|
|
129
129
|
if (isDirty) {
|
|
130
|
-
entryPoint.state =
|
|
130
|
+
entryPoint.state = node_1.STATE_DIRTY;
|
|
131
131
|
uriToClean.forEach(url => {
|
|
132
132
|
entryPoint.cache.analysesSourcesFileCache.delete((0, nodes_1.fileUrlPath)(url));
|
|
133
133
|
});
|
|
@@ -178,7 +178,7 @@ const scheduleEntryPoints = (epTransform) => (0, rxjs_1.pipe)((0, rxjs_1.concatM
|
|
|
178
178
|
// The array index is the depth.
|
|
179
179
|
const groups = depGraph.overallOrder().map(nodes_1.ngUrl);
|
|
180
180
|
// Build entry points with lower depth values first.
|
|
181
|
-
return (0, rxjs_1.from)(groups).pipe((0, rxjs_1.map)((epUrl) => graph.find((0, nodes_1.byEntryPoint)().and(ep => ep.url === epUrl))), (0, rxjs_1.filter)((entryPoint) => entryPoint.state !==
|
|
181
|
+
return (0, rxjs_1.from)(groups).pipe((0, rxjs_1.map)((epUrl) => graph.find((0, nodes_1.byEntryPoint)().and(ep => ep.url === epUrl))), (0, rxjs_1.filter)((entryPoint) => entryPoint.state !== node_1.STATE_DONE), (0, rxjs_1.concatMap)(ep => (0, rxjs_1.of)(ep).pipe(
|
|
182
182
|
// Mark the entry point as 'in-progress'
|
|
183
183
|
(0, rxjs_1.tap)(entryPoint => (entryPoint.state = node_1.STATE_IN_PROGRESS)), (0, rxjs_1.map)(() => graph), epTransform)), (0, rxjs_1.takeLast)(1), // don't use last as sometimes it this will cause 'no elements in sequence',
|
|
184
184
|
(0, rxjs_1.defaultIfEmpty)(graph));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA4C;AAC5C,+BAiBc;AACd,8DAA8D;AAE9D,wCAAkD;AAElD,0CAAwC;AACxC,oCAAoC;AACpC,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAuD;AACvD,mCASiB;AAGjB;;;;;;;;;;;;;;;GAeG;AACI,MAAM,uBAAuB,GAClC,CACE,OAAe,EACf,OAAyB,EACzB,qBAAgC,EAChC,uBAAkC,EAClC,mBAA8B,EAC9B,EAAE,CACJ,CAAC,OAA+B,EAA0B,EAAE;IAC1D,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAErC,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK;QAClC,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC;QACvF,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC,CAAC;IAEjF,MAAM,MAAM,GAAG,IAAA,aAAK,EAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,mBAAW,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC,IAAI;IACjB,qCAAqC;IACrC,oFAAoF;IACpF,IAAA,gBAAS,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;QACtB,KAAK,CAAC,IAAI,GAAG,MAAM,IAAA,oCAAgB,EAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAEjD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;QAE5C,IAAI,cAAc,EAAE;YAClB,IAAI;gBACF,MAA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AE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,EAC9F,IAAA,aAAM,EAAC,CAAC,UAA0B,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,KAAK,MAAM,CAAC,EAC5E,IAAA,gBAAS,EAAC,EAAE,CAAC,EAAE,CACb,IAAA,SAAY,EAAC,EAAE,CAAC,CAAC,IAAI;IACnB,wCAAwC;IACxC,IAAA,UAAG,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,wBAAiB,CAAC,CAAC,EACzD,IAAA,UAAG,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAChB,WAAW,CACZ,CACF,EACD,IAAA,eAAQ,EAAC,CAAC,CAAC,EAAE,4EAA4E;IACzF,IAAA,qBAAc,EAAC,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport {\n NEVER,\n Observable,\n catchError,\n concatMap,\n debounceTime,\n defaultIfEmpty,\n filter,\n finalize,\n from,\n map,\n of as observableOf,\n pipe,\n startWith,\n switchMap,\n takeLast,\n tap,\n} from 'rxjs';\nimport { createFileWatch } from '../file-system/file-watcher';\nimport { BuildGraph } from '../graph/build-graph';\nimport { STATE_IN_PROGRESS } from '../graph/node';\nimport { Transform } from '../graph/transform';\nimport { colors } from '../utils/color';\nimport { rmdir } from '../utils/fs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { discoverPackages } from './discover-packages';\nimport {\n EntryPointNode,\n PackageNode,\n byEntryPoint,\n fileUrl,\n fileUrlPath,\n isEntryPoint,\n isPackage,\n ngUrl,\n} from './nodes';\nimport { NgPackagrOptions } from './options.di';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory =\n (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform,\n ) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n log.info(`Building Angular Package`);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);\n\n const pkgUri = ngUrl(project);\n const ngPkg = new PackageNode(pkgUri);\n\n return source$.pipe(\n // Discover packages and entry points\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(async graph => {\n ngPkg.data = await discoverPackages({ project });\n\n graph.put(ngPkg);\n const { dest, deleteDestPath } = ngPkg.data;\n\n if (deleteDestPath) {\n try {\n await rmdir(dest, { recursive: true });\n } catch {}\n }\n\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(\n ngUrl(moduleId),\n ngPkg.cache.sourcesFileCache,\n ngPkg.cache.moduleResolutionCache,\n );\n node.data = { entryPoint, destinationFiles };\n node.state = 'dirty';\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n // Add entry points to graph\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform,\n finalize(() => {\n for (const node of ngPkg.dependents) {\n if (node instanceof EntryPointNode) {\n node.cache.stylesheetProcessor?.destroy();\n }\n }\n }),\n );\n };\n\nconst watchTransformFactory =\n (project: string, _options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const { data, cache } = graph.find(isPackage);\n const { onFileChange, watcher } = createFileWatch([], [data.dest]);\n graph.watcher = watcher;\n\n return onFileChange.pipe(\n tap(fileChange => {\n const { filePath } = fileChange;\n const { sourcesFileCache } = cache;\n const cachedSourceFile = sourcesFileCache.get(filePath);\n const { declarationFileName } = cachedSourceFile || {};\n const uriToClean = [filePath, declarationFileName].map(x => fileUrl(ensureUnixPath(x)));\n const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));\n\n if (!cachedSourceFile) {\n if (!nodesToClean) {\n return;\n }\n }\n\n const allNodesToClean = [\n ...nodesToClean,\n // if a non ts file changes we need to clean up its direct dependees\n // this is mainly done for resources such as html and css\n ...nodesToClean.filter(node => !node.url.endsWith('.ts')).flatMap(node => [...node.dependees]),\n ];\n\n // delete node that changes\n for (const { url } of allNodesToClean) {\n sourcesFileCache.delete(fileUrlPath(url));\n }\n\n for (const entryPoint of graph.filter(isEntryPoint)) {\n const isDirty = [...allNodesToClean].some(dependent => entryPoint.dependents.has(dependent));\n if (isDirty) {\n entryPoint.state = 'dirty';\n\n uriToClean.forEach(url => {\n entryPoint.cache.analysesSourcesFileCache.delete(fileUrlPath(url));\n });\n }\n }\n }),\n debounceTime(200),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n map(() => graph),\n );\n }),\n switchMap(graph => {\n return observableOf(graph).pipe(\n buildTransformFactory(project, analyseSourcesTransform, entryPointTransform),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n\n return NEVER;\n }),\n );\n }),\n );\n };\n\nconst buildTransformFactory =\n (project: string, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const startTime = Date.now();\n\n const pkgUri = ngUrl(project);\n\n return source$.pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform),\n tap(graph => {\n const ngPkg = graph.get(pkgUri);\n log.success('\\n------------------------------------------------------------------------------');\n log.success(`Built Angular Package\n - from: ${ngPkg.data.src}\n - to: ${ngPkg.data.dest}`);\n log.success('------------------------------------------------------------------------------');\n const b = colors.bold;\n const w = colors.white;\n log.msg(w(`\\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\\n`));\n }),\n );\n };\n\nconst scheduleEntryPoints = (epTransform: Transform): Transform =>\n pipe(\n concatMap(graph => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n\n for (const entryPoint of entryPoints) {\n // Remove `ng://` prefix for better error messages\n const from = entryPoint.url.substring(5);\n depGraph.addNode(from);\n\n for (const { url } of entryPoint.filter(isEntryPoint)) {\n const to = url.substring(5);\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // The array index is the depth.\n const groups = depGraph.overallOrder().map(ngUrl);\n\n // Build entry points with lower depth values first.\n return from(groups).pipe(\n map((epUrl: string): EntryPointNode => graph.find(byEntryPoint().and(ep => ep.url === epUrl))),\n filter((entryPoint: EntryPointNode): boolean => entryPoint.state !== 'done'),\n concatMap(ep =>\n observableOf(ep).pipe(\n // Mark the entry point as 'in-progress'\n tap(entryPoint => (entryPoint.state = STATE_IN_PROGRESS)),\n map(() => graph),\n epTransform,\n ),\n ),\n takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',\n defaultIfEmpty(graph),\n );\n }),\n );\n"]}
|
|
1
|
+
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;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BAAU,CAAC,EAChF,IAAA,gBAAS,EAAC,EAAE,CAAC,EAAE,CACb,IAAA,SAAY,EAAC,EAAE,CAAC,CAAC,IAAI;IACnB,wCAAwC;IACxC,IAAA,UAAG,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,wBAAiB,CAAC,CAAC,EACzD,IAAA,UAAG,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAChB,WAAW,CACZ,CACF,EACD,IAAA,eAAQ,EAAC,CAAC,CAAC,EAAE,4EAA4E;IACzF,IAAA,qBAAc,EAAC,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport {\n NEVER,\n Observable,\n catchError,\n concatMap,\n debounceTime,\n defaultIfEmpty,\n filter,\n finalize,\n from,\n map,\n of as observableOf,\n pipe,\n startWith,\n switchMap,\n takeLast,\n tap,\n} from 'rxjs';\nimport { createFileWatch } from '../file-system/file-watcher';\nimport { BuildGraph } from '../graph/build-graph';\nimport { STATE_DIRTY, STATE_DONE, STATE_IN_PROGRESS } from '../graph/node';\nimport { Transform } from '../graph/transform';\nimport { colors } from '../utils/color';\nimport { rmdir } from '../utils/fs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { discoverPackages } from './discover-packages';\nimport {\n EntryPointNode,\n PackageNode,\n byEntryPoint,\n fileUrl,\n fileUrlPath,\n isEntryPoint,\n isPackage,\n ngUrl,\n} from './nodes';\nimport { NgPackagrOptions } from './options.di';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory =\n (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform,\n ) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n log.info(`Building Angular Package`);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);\n\n const pkgUri = ngUrl(project);\n const ngPkg = new PackageNode(pkgUri);\n\n return source$.pipe(\n // Discover packages and entry points\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(async graph => {\n ngPkg.data = await discoverPackages({ project });\n\n graph.put(ngPkg);\n const { dest, deleteDestPath } = ngPkg.data;\n\n if (deleteDestPath) {\n try {\n await rmdir(dest, { recursive: true });\n } catch {}\n }\n\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(\n ngUrl(moduleId),\n ngPkg.cache.sourcesFileCache,\n ngPkg.cache.moduleResolutionCache,\n );\n node.data = { entryPoint, destinationFiles };\n node.state = 'dirty';\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n // Add entry points to graph\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform,\n finalize(() => {\n for (const node of ngPkg.dependents) {\n if (node instanceof EntryPointNode) {\n node.cache.stylesheetProcessor?.destroy();\n }\n }\n }),\n );\n };\n\nconst watchTransformFactory =\n (project: string, _options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const { data, cache } = graph.find(isPackage);\n const { onFileChange, watcher } = createFileWatch([], [data.dest]);\n graph.watcher = watcher;\n\n return onFileChange.pipe(\n tap(fileChange => {\n const { filePath } = fileChange;\n const { sourcesFileCache } = cache;\n const cachedSourceFile = sourcesFileCache.get(filePath);\n const { declarationFileName } = cachedSourceFile || {};\n const uriToClean = [filePath, declarationFileName].map(x => fileUrl(ensureUnixPath(x)));\n const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));\n\n if (!cachedSourceFile) {\n if (!nodesToClean) {\n return;\n }\n }\n\n const allNodesToClean = [\n ...nodesToClean,\n // if a non ts file changes we need to clean up its direct dependees\n // this is mainly done for resources such as html and css\n ...nodesToClean.filter(node => !node.url.endsWith('.ts')).flatMap(node => [...node.dependees]),\n ];\n\n // delete node that changes\n for (const { url } of allNodesToClean) {\n sourcesFileCache.delete(fileUrlPath(url));\n }\n\n for (const entryPoint of graph.filter(isEntryPoint)) {\n const isDirty = [...allNodesToClean].some(dependent => entryPoint.dependents.has(dependent));\n if (isDirty) {\n entryPoint.state = STATE_DIRTY;\n\n uriToClean.forEach(url => {\n entryPoint.cache.analysesSourcesFileCache.delete(fileUrlPath(url));\n });\n }\n }\n }),\n debounceTime(200),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n map(() => graph),\n );\n }),\n switchMap(graph => {\n return observableOf(graph).pipe(\n buildTransformFactory(project, analyseSourcesTransform, entryPointTransform),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n\n return NEVER;\n }),\n );\n }),\n );\n };\n\nconst buildTransformFactory =\n (project: string, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const startTime = Date.now();\n\n const pkgUri = ngUrl(project);\n\n return source$.pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform),\n tap(graph => {\n const ngPkg = graph.get(pkgUri);\n log.success('\\n------------------------------------------------------------------------------');\n log.success(`Built Angular Package\n - from: ${ngPkg.data.src}\n - to: ${ngPkg.data.dest}`);\n log.success('------------------------------------------------------------------------------');\n const b = colors.bold;\n const w = colors.white;\n log.msg(w(`\\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\\n`));\n }),\n );\n };\n\nconst scheduleEntryPoints = (epTransform: Transform): Transform =>\n pipe(\n concatMap(graph => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n\n for (const entryPoint of entryPoints) {\n // Remove `ng://` prefix for better error messages\n const from = entryPoint.url.substring(5);\n depGraph.addNode(from);\n\n for (const { url } of entryPoint.filter(isEntryPoint)) {\n const to = url.substring(5);\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // The array index is the depth.\n const groups = depGraph.overallOrder().map(ngUrl);\n\n // Build entry points with lower depth values first.\n return from(groups).pipe(\n map((epUrl: string): EntryPointNode => graph.find(byEntryPoint().and(ep => ep.url === epUrl))),\n filter((entryPoint: EntryPointNode): boolean => entryPoint.state !== STATE_DONE),\n concatMap(ep =>\n observableOf(ep).pipe(\n // Mark the entry point as 'in-progress'\n tap(entryPoint => (entryPoint.state = STATE_IN_PROGRESS)),\n map(() => graph),\n epTransform,\n ),\n ),\n takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',\n defaultIfEmpty(graph),\n );\n }),\n );\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { BuildGraph } from '../graph/build-graph';
|
|
4
|
+
import { NgPackagrOptions } from '../ng-package/options.di';
|
|
4
5
|
import { StylesheetProcessor } from '../styles/stylesheet-processor';
|
|
5
|
-
export declare function compileSourceFiles(graph: BuildGraph, tsConfig: ParsedConfiguration, moduleResolutionCache: ts.ModuleResolutionCache, extraOptions?: Partial<CompilerOptions>, stylesheetProcessor?: StylesheetProcessor
|
|
6
|
+
export declare function compileSourceFiles(graph: BuildGraph, tsConfig: ParsedConfiguration, moduleResolutionCache: ts.ModuleResolutionCache, options: NgPackagrOptions, extraOptions?: Partial<CompilerOptions>, stylesheetProcessor?: StylesheetProcessor): Promise<void>;
|
|
@@ -27,20 +27,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.compileSourceFiles = void 0;
|
|
30
|
+
const node_path_1 = require("node:path");
|
|
30
31
|
const typescript_1 = __importDefault(require("typescript"));
|
|
31
32
|
const nodes_1 = require("../ng-package/nodes");
|
|
32
33
|
const cache_compiler_host_1 = require("../ts/cache-compiler-host");
|
|
33
34
|
const log = __importStar(require("../utils/log"));
|
|
34
35
|
const ng_compiler_cli_1 = require("../utils/ng-compiler-cli");
|
|
35
|
-
async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraOptions, stylesheetProcessor
|
|
36
|
+
async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, options, extraOptions, stylesheetProcessor) {
|
|
37
|
+
var _a, _b;
|
|
36
38
|
const { NgtscProgram, formatDiagnostics } = await (0, ng_compiler_cli_1.ngCompilerCli)();
|
|
39
|
+
const { cacheDirectory, watch, cacheEnabled } = options;
|
|
37
40
|
const tsConfigOptions = { ...tsConfig.options, ...extraOptions };
|
|
38
41
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
39
42
|
const ngPackageNode = graph.find(nodes_1.isPackage);
|
|
40
43
|
const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;
|
|
41
|
-
const
|
|
44
|
+
const cacheDir = cacheEnabled && cacheDirectory;
|
|
45
|
+
if (cacheDir) {
|
|
46
|
+
(_a = tsConfigOptions.incremental) !== null && _a !== void 0 ? _a : (tsConfigOptions.incremental = true);
|
|
47
|
+
(_b = tsConfigOptions.tsBuildInfoFile) !== null && _b !== void 0 ? _b : (tsConfigOptions.tsBuildInfoFile = (0, node_path_1.join)(cacheDir, `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`));
|
|
48
|
+
}
|
|
49
|
+
const emittedFiles = new Set();
|
|
50
|
+
const tsCompilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, emittedFiles, stylesheetProcessor, inlineStyleLanguage);
|
|
42
51
|
const cache = entryPoint.cache;
|
|
43
52
|
const sourceFileCache = cache.sourcesFileCache;
|
|
53
|
+
let usingBuildInfo = false;
|
|
54
|
+
let oldBuilder = cache.oldBuilder;
|
|
55
|
+
if (!oldBuilder && cacheDir) {
|
|
56
|
+
oldBuilder = typescript_1.default.readBuilderProgram(tsConfigOptions, tsCompilerHost);
|
|
57
|
+
usingBuildInfo = true;
|
|
58
|
+
}
|
|
44
59
|
// Create the Angular specific program that contains the Angular compiler
|
|
45
60
|
const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);
|
|
46
61
|
const angularCompiler = angularProgram.compiler;
|
|
@@ -50,8 +65,8 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraO
|
|
|
50
65
|
const typeScriptProgram = angularProgram.getTsProgram();
|
|
51
66
|
(0, cache_compiler_host_1.augmentProgramWithVersioning)(typeScriptProgram);
|
|
52
67
|
let builder;
|
|
53
|
-
if (watch) {
|
|
54
|
-
builder = cache.oldBuilder = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost,
|
|
68
|
+
if (watch || cacheDir) {
|
|
69
|
+
builder = cache.oldBuilder = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost, oldBuilder);
|
|
55
70
|
cache.oldNgtscProgram = angularProgram;
|
|
56
71
|
}
|
|
57
72
|
else {
|
|
@@ -88,6 +103,23 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraO
|
|
|
88
103
|
}
|
|
89
104
|
affectedFiles.add(result.affected);
|
|
90
105
|
}
|
|
106
|
+
// Add all files with associated template type checking files.
|
|
107
|
+
// Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.
|
|
108
|
+
// To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build
|
|
109
|
+
// info is present.
|
|
110
|
+
if (usingBuildInfo) {
|
|
111
|
+
for (const sourceFile of builder.getSourceFiles()) {
|
|
112
|
+
if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {
|
|
113
|
+
// This file name conversion relies on internal compiler logic and should be converted
|
|
114
|
+
// to an official method when available. 15 is length of `.ngtypecheck.ts`
|
|
115
|
+
const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';
|
|
116
|
+
const originalSourceFile = builder.getSourceFile(originalFilename);
|
|
117
|
+
if (originalSourceFile) {
|
|
118
|
+
affectedFiles.add(originalSourceFile);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
91
123
|
}
|
|
92
124
|
// Collect program level diagnostics
|
|
93
125
|
const allDiagnostics = [
|
|
@@ -100,33 +132,22 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraO
|
|
|
100
132
|
await angularCompiler.analyzeAsync();
|
|
101
133
|
// Collect source file specific diagnostics
|
|
102
134
|
for (const sourceFile of builder.getSourceFiles()) {
|
|
103
|
-
if (
|
|
104
|
-
|
|
135
|
+
if (ignoreForDiagnostics.has(sourceFile)) {
|
|
136
|
+
continue;
|
|
105
137
|
}
|
|
138
|
+
allDiagnostics.push(...builder.getDeclarationDiagnostics(sourceFile), ...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));
|
|
139
|
+
// Declaration files cannot have template diagnostics
|
|
106
140
|
if (sourceFile.isDeclarationFile) {
|
|
107
141
|
continue;
|
|
108
142
|
}
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {
|
|
117
|
-
// Use cached Angular diagnostics for unchanged and unaffected files
|
|
118
|
-
const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);
|
|
119
|
-
if (angularDiagnostics === null || angularDiagnostics === void 0 ? void 0 : angularDiagnostics.length) {
|
|
120
|
-
allDiagnostics.push(...angularDiagnostics);
|
|
121
|
-
}
|
|
143
|
+
// Only request Angular template diagnostics for affected files to avoid
|
|
144
|
+
// overhead of template diagnostics for unchanged files.
|
|
145
|
+
if (affectedFiles.has(sourceFile)) {
|
|
146
|
+
const angularDiagnostics = angularCompiler.getDiagnosticsForFile(sourceFile, affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1);
|
|
147
|
+
allDiagnostics.push(...angularDiagnostics);
|
|
148
|
+
sourceFileCache.updateAngularDiagnostics(sourceFile, angularDiagnostics);
|
|
122
149
|
}
|
|
123
150
|
}
|
|
124
|
-
// Collect new Angular diagnostics for files affected by changes
|
|
125
|
-
for (const affectedFile of affectedFiles) {
|
|
126
|
-
const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, /** OptimizeFor.WholeProgram */ 1);
|
|
127
|
-
allDiagnostics.push(...angularDiagnostics);
|
|
128
|
-
sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);
|
|
129
|
-
}
|
|
130
151
|
const otherDiagnostics = [];
|
|
131
152
|
const errorDiagnostics = [];
|
|
132
153
|
for (const diagnostic of allDiagnostics) {
|
|
@@ -140,14 +161,29 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraO
|
|
|
140
161
|
if (otherDiagnostics.length) {
|
|
141
162
|
log.msg(formatDiagnostics(errorDiagnostics));
|
|
142
163
|
}
|
|
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
|
+
}
|
|
143
171
|
if (errorDiagnostics.length) {
|
|
144
172
|
throw new Error(formatDiagnostics(errorDiagnostics));
|
|
145
173
|
}
|
|
146
|
-
const transformers = angularCompiler.prepareEmit().transformers;
|
|
147
174
|
for (const sourceFile of builder.getSourceFiles()) {
|
|
148
|
-
if (
|
|
149
|
-
|
|
175
|
+
if (ignoreForEmit.has(sourceFile)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (emittedFiles.has(sourceFile.fileName)) {
|
|
179
|
+
angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {
|
|
183
|
+
continue;
|
|
150
184
|
}
|
|
185
|
+
builder.emit(sourceFile, undefined, undefined, undefined, transformers);
|
|
186
|
+
angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
|
|
151
187
|
}
|
|
152
188
|
}
|
|
153
189
|
exports.compileSourceFiles = compileSourceFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAA4B;AAE5B,+CAAqG;AAErG,mEAA4F;AAC5F,kDAAoC;AACpC,8DAAyD;A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AAM,kBAAkB,GAAG,eAAe,CAAC,qBAAqB,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAC,CAAC,CAAC;QAElH,cAAc,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC;QAC3C,eAAe,CAAC,wBAAwB,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;KAC5E;IAED,MAAM,gBAAgB,GAAG,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,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAClC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;SACzE;KACF;AACH,CAAC;AAhKD,gDAgKC","sourcesContent":["import type { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { EntryPointNode, PackageNode, isEntryPointInProgress, isPackage } from '../ng-package/nodes';\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 extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n watch?: boolean,\n) {\n const { NgtscProgram, formatDiagnostics } = await ngCompilerCli();\n\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 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\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 // 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\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.getDeclarationDiagnostics(sourceFile),\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.incrementalCompilation.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 */ 1);\n\n allDiagnostics.push(...angularDiagnostics);\n sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);\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 builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n }\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,EA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AC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC9C;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC;IAChE,IAAI,0CAA0C,IAAI,OAAO,EAAE;QACzD,6EAA6E;QAC7E,OAAO,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE;YAClF,QAAQ;SACT;KACF;IAED,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,MAAM,IAAI,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"]}
|
|
@@ -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, stylesheetProcessor?: StylesheetProcessor, inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'], sourcesFileCache?: FileCache): CompilerHost;
|
|
8
|
+
export declare function cacheCompilerHost(graph: BuildGraph, entryPoint: EntryPointNode, compilerOptions: CompilerOptions, moduleResolutionCache: ts.ModuleResolutionCache, emittedFiles?: Set<string>, stylesheetProcessor?: StylesheetProcessor, inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'], sourcesFileCache?: FileCache): CompilerHost;
|
|
9
9
|
export declare function augmentProgramWithVersioning(program: ts.Program): void;
|
|
@@ -29,12 +29,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.augmentProgramWithVersioning = exports.cacheCompilerHost = void 0;
|
|
30
30
|
const convert_source_map_1 = __importDefault(require("convert-source-map"));
|
|
31
31
|
const crypto_1 = require("crypto");
|
|
32
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
32
33
|
const path = __importStar(require("path"));
|
|
33
34
|
const typescript_1 = __importDefault(require("typescript"));
|
|
34
35
|
const node_1 = require("../graph/node");
|
|
35
36
|
const nodes_1 = require("../ng-package/nodes");
|
|
36
37
|
const path_1 = require("../utils/path");
|
|
37
|
-
function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage, sourcesFileCache = entryPoint.cache.sourcesFileCache) {
|
|
38
|
+
function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionCache, emittedFiles, stylesheetProcessor, inlineStyleLanguage, sourcesFileCache = entryPoint.cache.sourcesFileCache) {
|
|
38
39
|
const compilerHost = typescript_1.default.createIncrementalCompilerHost(compilerOptions);
|
|
39
40
|
const getNode = (fileName) => {
|
|
40
41
|
const nodeUri = (0, nodes_1.fileUrl)((0, path_1.ensureUnixPath)(fileName));
|
|
@@ -72,6 +73,15 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
72
73
|
return cache.sourceFile;
|
|
73
74
|
},
|
|
74
75
|
writeFile: (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
|
76
|
+
if (fileName.includes('.ngtypecheck.')) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!(sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) && fileName.endsWith('.tsbuildinfo')) {
|
|
80
|
+
// Save builder info contents to specified location
|
|
81
|
+
compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
(0, node_assert_1.default)((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1, 'Invalid TypeScript program emit for ' + fileName);
|
|
75
85
|
if (fileName.endsWith('.d.ts')) {
|
|
76
86
|
if (fileName === flatModuleFileDtsPath) {
|
|
77
87
|
if (hasIndexEntryFile) {
|
|
@@ -86,6 +96,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
sourceFiles.forEach(source => {
|
|
99
|
+
emittedFiles === null || emittedFiles === void 0 ? void 0 : emittedFiles.add(source.fileName);
|
|
89
100
|
const cache = sourcesFileCache.getOrCreate(source.fileName);
|
|
90
101
|
if (!cache.declarationFileName) {
|
|
91
102
|
cache.declarationFileName = (0, path_1.ensureUnixPath)(fileName);
|
|
@@ -107,6 +118,9 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
107
118
|
version,
|
|
108
119
|
map,
|
|
109
120
|
});
|
|
121
|
+
sourceFiles.forEach(source => {
|
|
122
|
+
emittedFiles === null || emittedFiles === void 0 ? void 0 : emittedFiles.add(source.fileName);
|
|
123
|
+
});
|
|
110
124
|
}
|
|
111
125
|
compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
112
126
|
},
|
|
@@ -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,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,C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AAC,cAAc,GAAG,UAAU,GAAG,UAAU;QAC9C,MAAM,KAAK,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 * 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.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"]}
|
|
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,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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G,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;oBAC3D,eAAe,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;iBAC/C;gBAED,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;gBAEpB,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;aACnC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAjND,8CAiNC;AAED,SAAgB,4BAA4B,CAAC,OAAmB;IAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAClD,OAAO,CAAC,cAAc,GAAG,UAAU,GAAG,UAAU;QAC9C,MAAM,KAAK,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 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"]}
|
package/lib/ts/tsconfig.js
CHANGED
|
@@ -39,14 +39,13 @@ async function readDefaultTsConfig(fileName = exports.defaultTsConfigPath) {
|
|
|
39
39
|
// these options are mandatory
|
|
40
40
|
const extraOptions = {
|
|
41
41
|
target: typescript_1.default.ScriptTarget.ES2022,
|
|
42
|
-
experimentalDecorators: true,
|
|
43
42
|
// sourcemaps
|
|
44
43
|
sourceMap: false,
|
|
45
44
|
inlineSources: true,
|
|
46
45
|
inlineSourceMap: true,
|
|
47
46
|
outDir: '',
|
|
48
47
|
declaration: true,
|
|
49
|
-
// ng compiler
|
|
48
|
+
// ng compiler
|
|
50
49
|
enableResourceInlining: true,
|
|
51
50
|
// these are required to set the appropriate EmitFlags
|
|
52
51
|
flatModuleId: 'AUTOGENERATED',
|
package/lib/ts/tsconfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,4DAA4B;AAE5B,kDAAoC;AACpC,8DAAyD;AAE5C,QAAA,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;AACrF;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAAC,QAAQ,GAAG,2BAAmB;IAC/D,8BAA8B;IAC9B,MAAM,YAAY,GAAoB;QACpC,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,4DAA4B;AAE5B,kDAAoC;AACpC,8DAAyD;AAE5C,QAAA,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;AACrF;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAAC,QAAQ,GAAG,2BAAmB;IAC/D,8BAA8B;IAC9B,MAAM,YAAY,GAAoB;QACpC,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;QAE9B,aAAa;QACb,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QAErB,MAAM,E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CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;SAC/C;aAAM;YACL,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;SACzD;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzBD,oEAyBC","sourcesContent":["import type { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { EntryPointNode } from '../ng-package/nodes';\nimport * as log from '../utils/log';\nimport { ngCompilerCli } from '../utils/ng-compiler-cli';\n\nexport const defaultTsConfigPath = path.join(__dirname, 'conf', 'tsconfig.ngc.json');\n/**\n * Reads the default TypeScript configuration.\n */\nasync function readDefaultTsConfig(fileName = defaultTsConfigPath): Promise<ParsedConfiguration> {\n // these options are mandatory\n const extraOptions: CompilerOptions = {\n target: ts.ScriptTarget.ES2022,\n\n // sourcemaps\n sourceMap: false,\n inlineSources: true,\n inlineSourceMap: true,\n\n outDir: '',\n declaration: true,\n\n // ng compiler\n enableResourceInlining: true,\n\n // these are required to set the appropriate EmitFlags\n flatModuleId: 'AUTOGENERATED',\n flatModuleOutFile: 'AUTOGENERATED',\n };\n\n const { readConfiguration } = await ngCompilerCli();\n\n return readConfiguration(fileName, extraOptions);\n}\n\n/**\n * Creates a parsed TypeScript configuration object.\n *\n * @param values File path or parsed configuration.\n */\nasync function createDefaultTsConfig(values?: ParsedConfiguration | string): Promise<ParsedConfiguration> {\n if (!values) {\n return readDefaultTsConfig();\n } else if (typeof values === 'string') {\n return readDefaultTsConfig(values);\n } else {\n return values;\n }\n}\n\n/**\n * Initializes TypeScript Compiler options and Angular Compiler options by overriding the\n * default config with entry point-specific values.\n */\nexport async function initializeTsConfig(\n defaultTsConfig: ParsedConfiguration | string | undefined,\n entryPoints: EntryPointNode[],\n): Promise<void> {\n const defaultTsConfigParsed = await createDefaultTsConfig(defaultTsConfig);\n if (defaultTsConfigParsed.errors.length > 0) {\n const { formatDiagnostics } = await ngCompilerCli();\n throw new Error(formatDiagnostics(defaultTsConfigParsed.errors));\n }\n\n entryPoints.forEach(currentEntryPoint => {\n const { entryPoint } = currentEntryPoint.data;\n log.debug(`Initializing tsconfig for ${entryPoint.moduleId}`);\n const basePath = path.dirname(entryPoint.entryFilePath);\n\n // Resolve defaults from DI token and create a deep copy of the defaults\n const tsConfig: ParsedConfiguration = JSON.parse(JSON.stringify(defaultTsConfigParsed));\n const overrideOptions: CompilerOptions = {\n flatModuleId: entryPoint.moduleId,\n flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,\n basePath,\n rootDir: basePath,\n sourceRoot: '',\n };\n\n tsConfig.rootNames = [entryPoint.entryFilePath];\n tsConfig.options = { ...tsConfig.options, ...overrideOptions };\n currentEntryPoint.data.tsConfig = tsConfig;\n });\n}\n\n/**\n * Set the paths for entrypoint dependencies.\n *\n * This doesn't mutate the object.\n *\n * @param parsedTsConfig - A parsed tsconfig\n * @param entryPoints - A list of entryPoints\n * @param pointToSource Point the path mapping to either the source code or emitted declarations.\n * Typically for analysis one should point to the source files while for a compilation once should use the emitted declarations\n */\nexport function setDependenciesTsConfigPaths(\n parsedTsConfig: ParsedConfiguration,\n entryPoints: EntryPointNode[],\n pointToSource = false,\n): ParsedConfiguration {\n const tsConfig = JSON.parse(JSON.stringify(parsedTsConfig));\n\n // Add paths mappings for dependencies\n if (!tsConfig.options.paths) {\n tsConfig.options.paths = {};\n }\n\n for (const dep of entryPoints) {\n const { entryPoint } = dep.data;\n const { moduleId, destinationFiles, entryFilePath } = entryPoint;\n const mappedPath = [pointToSource ? entryFilePath : destinationFiles.declarations];\n\n if (!tsConfig.options.paths[moduleId]) {\n tsConfig.options.paths[moduleId] = mappedPath;\n } else {\n tsConfig.options.paths[moduleId].unshift(...mappedPath);\n }\n }\n\n return tsConfig;\n}\n"]}
|