ng-packagr 15.2.2 → 16.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/graph/transform.js +1 -2
- package/lib/graph/transform.js.map +1 -1
- package/lib/ng-package/discover-packages.js +1 -2
- package/lib/ng-package/discover-packages.js.map +1 -1
- package/lib/ng-package/entry-point/analyse-sources.transform.js +1 -2
- package/lib/ng-package/entry-point/analyse-sources.transform.js.map +1 -1
- package/lib/ng-package/entry-point/compile-ngc.transform.js +2 -9
- package/lib/ng-package/entry-point/compile-ngc.transform.js.map +1 -1
- package/lib/ng-package/nodes.d.ts +1 -4
- package/lib/ng-package/nodes.js +1 -4
- package/lib/ng-package/nodes.js.map +1 -1
- package/lib/ng-package/package.transform.js +12 -13
- package/lib/ng-package/package.transform.js.map +1 -1
- package/lib/ngc/compile-source-files.d.ts +1 -2
- package/lib/ngc/compile-source-files.js +2 -3
- package/lib/ngc/compile-source-files.js.map +1 -1
- package/lib/packagr.js +1 -2
- package/lib/packagr.js.map +1 -1
- package/lib/utils/ng-compiler-cli.d.ts +0 -1
- package/lib/utils/ng-compiler-cli.js +1 -6
- package/lib/utils/ng-compiler-cli.js.map +1 -1
- package/package.json +4 -4
- package/lib/ng-package/ngcc-cache.d.ts +0 -18
- package/lib/ng-package/ngcc-cache.js +0 -40
- package/lib/ng-package/ngcc-cache.js.map +0 -1
- package/lib/ngc/ngcc-processor.d.ts +0 -25
- package/lib/ngc/ngcc-processor.js +0 -238
- package/lib/ngc/ngcc-processor.js.map +0 -1
- package/lib/ts/ngcc-transform-compiler-host.d.ts +0 -3
- package/lib/ts/ngcc-transform-compiler-host.js +0 -33
- package/lib/ts/ngcc-transform-compiler-host.js.map +0 -1
package/lib/graph/transform.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformFromPromise = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
|
-
const
|
|
6
|
-
const transformFromPromise = (transformFn) => (0, rxjs_1.pipe)((0, operators_1.switchMap)(async (graph) => {
|
|
5
|
+
const transformFromPromise = (transformFn) => (0, rxjs_1.pipe)((0, rxjs_1.switchMap)(async (graph) => {
|
|
7
6
|
const transformResult = await transformFn(graph);
|
|
8
7
|
return transformResult || graph;
|
|
9
8
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/lib/graph/transform.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/lib/graph/transform.ts"],"names":[],"mappings":";;;AAAA,+BAA6E;AAqBtE,MAAM,oBAAoB,GAAG,CAAC,WAAkC,EAAa,EAAE,CACpF,IAAA,WAAI,EACF,IAAA,gBAAS,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACtB,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC;IAEjD,OAAO,eAAe,IAAI,KAAK,CAAC;AAClC,CAAC,CAAC,CACH,CAAC;AAPS,QAAA,oBAAoB,wBAO7B","sourcesContent":["import { MonoTypeOperatorFunction, Observable, pipe, switchMap } from 'rxjs';\nimport { BuildGraph } from './build-graph';\n\n/**\n * A transformation applied over the build graph.\n *\n * By design, a pipeable operator over `BuildGraph`.\n * - A transformation takes a `BuildGraph` as input (from previous transformations).\n * - A transformation performs some operations based on the graph's data, potentially modifying nodes in the graph.\n * - It returns a `BuildGraph` that will be passed to subsequent transformations.\n *\n * @link https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#pipeable-operators\n */\nexport interface Transform extends MonoTypeOperatorFunction<BuildGraph> {\n (source$: Observable<BuildGraph>): Observable<BuildGraph>;\n}\n\nexport interface PromiseBasedTransform {\n (graph: BuildGraph): Promise<BuildGraph | void> | BuildGraph | void;\n}\n\nexport const transformFromPromise = (transformFn: PromiseBasedTransform): Transform =>\n pipe(\n switchMap(async graph => {\n const transformResult = await transformFn(graph);\n\n return transformResult || graph;\n }),\n );\n"]}
|
|
@@ -34,12 +34,11 @@ const entry_point_1 = require("./entry-point/entry-point");
|
|
|
34
34
|
const package_1 = require("./package");
|
|
35
35
|
const schema_1 = require("./schema");
|
|
36
36
|
async function readConfigFile(filePath) {
|
|
37
|
-
var _a;
|
|
38
37
|
if (!(await (0, fs_1.exists)(filePath))) {
|
|
39
38
|
return undefined;
|
|
40
39
|
}
|
|
41
40
|
if (filePath.endsWith('.js')) {
|
|
42
|
-
return
|
|
41
|
+
return Promise.resolve(`${filePath}`).then(s => __importStar(require(s)));
|
|
43
42
|
}
|
|
44
43
|
const data = await (0, fs_1.readFile)(filePath, 'utf-8');
|
|
45
44
|
return (0, jsonc_parser_1.parse)(data, undefined, { allowTrailingComma: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,2CAA6B;AAC7B,oCAAqD;AACrD,wCAA0C;AAC1C,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAyD;AACzD,uCAAsC;AACtC,qCAAmD;AAWnD,KAAK,UAAU,cAAc,CAAC,QAAgB
|
|
1
|
+
{"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,2CAA6B;AAC7B,oCAAqD;AACrD,wCAA0C;AAC1C,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAyD;AACzD,uCAAsC;AACtC,qCAAmD;AAWnD,KAAK,UAAU,cAAc,CAAC,QAAgB;IAC5C,IAAI,CAAC,CAAC,MAAM,IAAA,WAAM,EAAC,QAAQ,CAAC,CAAC,EAAE;QAC7B,OAAO,SAAS,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W,GAAG,MAAM,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,MAAM,WAAW,GAAmB,EAAE,CAAC;IAEvC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,gBAAgB,GAAG,MAAM,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACpE,IAAI,gBAAgB,EAAE;YACpB,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;SAClE;KACF;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,GAAG,CAAC,KAAK,CAAC,iCAAiC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KAC3F;IAED,OAAO,IAAI,mBAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAtBD,4CAsBC","sourcesContent":["import { parse as parseJson } from 'jsonc-parser';\nimport * as path from 'path';\nimport { exists, readFile, stat } from '../utils/fs';\nimport { globFiles } from '../utils/glob';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { validateNgPackageSchema } from './schema';\n\ninterface UserPackage {\n /** Values from the `package.json` file of this user package. */\n packageJson: Record<string, any>;\n /** NgPackageConfig for this user package. */\n ngPackageJson: Record<string, any>;\n /** Absolute directory path of this user package. */\n basePath: string;\n}\n\nasync function readConfigFile(filePath: string): Promise<any> {\n if (!(await exists(filePath))) {\n return undefined;\n }\n\n if (filePath.endsWith('.js')) {\n return import(filePath);\n }\n\n const data = await readFile(filePath, 'utf-8');\n\n return parseJson(data, undefined, { allowTrailingComma: true });\n}\n\n/**\n * Resolves a user's package by testing 'ng-package.json', or 'ng-package.js'.\n *\n * @param folderPathOrFilePath A path pointing either to a file or a directory\n * @param isSecondary A boolean determining if this is a secondary package\n * @return The user's package\n */\nasync function resolveUserPackage(folderPathOrFilePath: string, isSecondary = false): Promise<UserPackage | undefined> {\n const fullPath = path.resolve(folderPathOrFilePath);\n const pathStats = await stat(fullPath);\n const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);\n\n let ngPackageJson: unknown;\n if (pathStats.isDirectory()) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.json'));\n if (!ngPackageJson) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.js'));\n }\n } else {\n ngPackageJson = await readConfigFile(fullPath);\n }\n\n if (ngPackageJson) {\n ngPackageJson = ngPackageJson['default'] ?? ngPackageJson;\n\n validateNgPackageSchema(ngPackageJson);\n\n let packageJson: {} = {};\n if (!isSecondary) {\n const pkgJsonPath = path.join(basePath, 'package.json');\n packageJson = await readConfigFile(pkgJsonPath);\n\n if (!packageJson) {\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);\n }\n\n if (packageJson && typeof packageJson !== 'object') {\n throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);\n }\n }\n\n return {\n basePath,\n packageJson,\n ngPackageJson,\n };\n }\n\n if (pathStats.isDirectory()) {\n // return even if it's undefined and use defaults when it's not a file\n return undefined;\n }\n\n if (pathStats.isFile()) {\n throw new Error(`Trying to read a package from unsupported file extension. Path: ${folderPathOrFilePath}`);\n }\n\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath}`);\n}\n\n/**\n * Scans `directoryPath` and sub-folders, looking for `ng-package` files.\n * Similar to `find ${directoryPath} --name ng-package --exec dirname {}`.\n *\n * @param directoryPath Path pointing to a directory\n * @param excludeFolder A sub-folder of `directoryPath` that is excluded from search results.\n */\nasync function findSecondaryPackagesPaths(directoryPath: string, excludeFolder: string): Promise<string[]> {\n const ignore = ['**/node_modules/**', '**/.git/**', `${excludeFolder}/**`, 'ng-package.json'];\n\n const filePaths = await globFiles(`**/ng-package.json`, {\n ignore,\n nodir: true,\n cwd: directoryPath,\n });\n\n return filePaths.map(subpath => path.dirname(path.join(directoryPath, subpath)));\n}\n\n/**\n * Reads a secondary entry point from it's package file.\n *\n * @param primary The primary entry point.\n * @param userPackage The user package for the secondary entry point.\n */\nfunction secondaryEntryPoint(primary: NgEntryPoint, userPackage: UserPackage): NgEntryPoint {\n const { packageJson, ngPackageJson, basePath } = userPackage;\n if (path.resolve(basePath) === path.resolve(primary.basePath)) {\n log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);\n throw new Error(`Secondary entry point is already a primary.`);\n }\n\n const relativeSourcePath = path.relative(primary.basePath, basePath);\n const secondaryModuleId = ensureUnixPath(`${primary.moduleId}/${relativeSourcePath}`);\n\n return new NgEntryPoint(packageJson, ngPackageJson, basePath, {\n moduleId: secondaryModuleId,\n primaryDestinationPath: primary.destinationPath,\n destinationPath: path.join(primary.destinationPath, relativeSourcePath),\n });\n}\n\nexport async function discoverPackages({ project }: { project: string }): Promise<NgPackage> {\n project = path.isAbsolute(project) ? project : path.resolve(project);\n\n const { packageJson, ngPackageJson, basePath } = await resolveUserPackage(project);\n const primary = new NgEntryPoint(packageJson, ngPackageJson, basePath);\n log.debug(`Found primary entry point: ${primary.moduleId}`);\n\n const folderPaths = await findSecondaryPackagesPaths(basePath, primary.$get('dest'));\n const secondaries: NgEntryPoint[] = [];\n\n for (const folderPath of folderPaths) {\n const secondaryPackage = await resolveUserPackage(folderPath, true);\n if (secondaryPackage) {\n secondaries.push(secondaryEntryPoint(primary, secondaryPackage));\n }\n }\n\n if (secondaries.length > 0) {\n log.debug(`Found secondary entry points: ${secondaries.map(e => e.moduleId).join(', ')}`);\n }\n\n return new NgPackage(basePath, primary, secondaries);\n}\n"]}
|
|
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.analyseSourcesTransform = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
|
-
const operators_1 = require("rxjs/operators");
|
|
10
9
|
const typescript_1 = __importDefault(require("typescript"));
|
|
11
10
|
const cache_compiler_host_1 = require("../../ts/cache-compiler-host");
|
|
12
11
|
const log_1 = require("../../utils/log");
|
|
13
12
|
const path_2 = require("../../utils/path");
|
|
14
13
|
const nodes_1 = require("../nodes");
|
|
15
|
-
exports.analyseSourcesTransform = (0, rxjs_1.pipe)((0,
|
|
14
|
+
exports.analyseSourcesTransform = (0, rxjs_1.pipe)((0, rxjs_1.map)(graph => {
|
|
16
15
|
const entryPoints = graph.filter(nodes_1.isEntryPoint);
|
|
17
16
|
const dirtyEntryPoints = entryPoints.filter(x => x.state !== 'done');
|
|
18
17
|
for (const entryPoint of dirtyEntryPoints) {
|
|
@@ -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,+
|
|
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,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C,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"]}
|
|
@@ -32,9 +32,7 @@ const path = __importStar(require("path"));
|
|
|
32
32
|
const typescript_1 = __importDefault(require("typescript"));
|
|
33
33
|
const transform_1 = require("../../graph/transform");
|
|
34
34
|
const compile_source_files_1 = require("../../ngc/compile-source-files");
|
|
35
|
-
const ngcc_processor_1 = require("../../ngc/ngcc-processor");
|
|
36
35
|
const tsconfig_1 = require("../../ts/tsconfig");
|
|
37
|
-
const ng_compiler_cli_1 = require("../../utils/ng-compiler-cli");
|
|
38
36
|
const nodes_1 = require("../nodes");
|
|
39
37
|
const compileNgcTransformFactory = (StylesheetProcessor, options) => {
|
|
40
38
|
return (0, transform_1.transformFromPromise)(async (graph) => {
|
|
@@ -54,20 +52,15 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
|
|
|
54
52
|
// Compile TypeScript sources
|
|
55
53
|
const { esm2020, declarations } = entryPoint.data.destinationFiles;
|
|
56
54
|
const { basePath, cssUrl, styleIncludePaths } = entryPoint.data.entryPoint;
|
|
57
|
-
const { moduleResolutionCache
|
|
55
|
+
const { moduleResolutionCache } = entryPoint.cache;
|
|
58
56
|
spinner.start(`Compiling with Angular sources in Ivy ${tsConfig.options.compilationMode || 'full'} compilation mode.`);
|
|
59
|
-
const ngccProcessor = new ngcc_processor_1.NgccProcessor(await (0, ng_compiler_cli_1.ngccCompilerCli)(), ngccProcessingCache, tsConfig.project, tsConfig.options, entryPoints);
|
|
60
|
-
if (!entryPoint.data.entryPoint.isSecondaryEntryPoint) {
|
|
61
|
-
// Only run the async version of NGCC during the primary entrypoint processing.
|
|
62
|
-
await ngccProcessor.process();
|
|
63
|
-
}
|
|
64
57
|
(_a = (_c = entryPoint.cache).stylesheetProcessor) !== null && _a !== void 0 ? _a : (_c.stylesheetProcessor = new StylesheetProcessor(projectBasePath, basePath, cssUrl, styleIncludePaths, options.cacheEnabled && options.cacheDirectory));
|
|
65
58
|
await (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, {
|
|
66
59
|
outDir: path.dirname(esm2020),
|
|
67
60
|
declarationDir: path.dirname(declarations),
|
|
68
61
|
declaration: true,
|
|
69
62
|
target: typescript_1.default.ScriptTarget.ES2020,
|
|
70
|
-
}, entryPoint.cache.stylesheetProcessor,
|
|
63
|
+
}, entryPoint.cache.stylesheetProcessor, options.watch);
|
|
71
64
|
}
|
|
72
65
|
catch (error) {
|
|
73
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,8CAAsB;AACtB,2CAA6B;AAC7B,4DAA4B;AAC5B,qDAAwE;AACxE,yEAAoE;
|
|
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,IAAA,uCAA4B,EAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAErF,6BAA6B;YAC7B,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GA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 '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 { esm2020, 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 {\n outDir: path.dirname(esm2020),\n declarationDir: path.dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2020,\n },\n entryPoint.cache.stylesheetProcessor,\n options.watch,\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"]}
|
|
@@ -6,7 +6,6 @@ import { ComplexPredicate } from '../graph/build-graph';
|
|
|
6
6
|
import { Node } from '../graph/node';
|
|
7
7
|
import { StylesheetProcessor } from '../styles/stylesheet-processor';
|
|
8
8
|
import { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';
|
|
9
|
-
import { NgccProcessingCache } from './ngcc-cache';
|
|
10
9
|
import { NgPackage } from './package';
|
|
11
10
|
export declare const TYPE_NG_PACKAGE = "application/ng-package";
|
|
12
11
|
export declare const TYPE_NG_ENTRY_POINT = "application/ng-entry-point";
|
|
@@ -32,12 +31,11 @@ export type OutputFileCache = Map<string, {
|
|
|
32
31
|
export declare class EntryPointNode extends Node {
|
|
33
32
|
readonly url: string;
|
|
34
33
|
readonly type = "application/ng-entry-point";
|
|
35
|
-
constructor(url: string, sourcesFileCache: FileCache,
|
|
34
|
+
constructor(url: string, sourcesFileCache: FileCache, moduleResolutionCache: ts.ModuleResolutionCache);
|
|
36
35
|
cache: {
|
|
37
36
|
outputCache: OutputFileCache;
|
|
38
37
|
oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;
|
|
39
38
|
sourcesFileCache: FileCache;
|
|
40
|
-
ngccProcessingCache: NgccProcessingCache;
|
|
41
39
|
analysesSourcesFileCache: FileCache;
|
|
42
40
|
moduleResolutionCache: ts.ModuleResolutionCache;
|
|
43
41
|
rollupFESM2020Cache?: RollupCache;
|
|
@@ -58,7 +56,6 @@ export declare class PackageNode extends Node {
|
|
|
58
56
|
cache: {
|
|
59
57
|
globCache: GlobCache;
|
|
60
58
|
sourcesFileCache: FileCache;
|
|
61
|
-
ngccProcessingCache: NgccProcessingCache;
|
|
62
59
|
moduleResolutionCache: ts.ModuleResolutionCache;
|
|
63
60
|
};
|
|
64
61
|
}
|
package/lib/ng-package/nodes.js
CHANGED
|
@@ -8,7 +8,6 @@ const typescript_1 = __importDefault(require("typescript"));
|
|
|
8
8
|
const file_cache_1 = require("../file-system/file-cache");
|
|
9
9
|
const node_1 = require("../graph/node");
|
|
10
10
|
const select_1 = require("../graph/select");
|
|
11
|
-
const ngcc_cache_1 = require("./ngcc-cache");
|
|
12
11
|
exports.TYPE_NG_PACKAGE = 'application/ng-package';
|
|
13
12
|
exports.TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';
|
|
14
13
|
/** A node that can be read through the `fs` api. */
|
|
@@ -54,13 +53,12 @@ function ngUrl(path) {
|
|
|
54
53
|
}
|
|
55
54
|
exports.ngUrl = ngUrl;
|
|
56
55
|
class EntryPointNode extends node_1.Node {
|
|
57
|
-
constructor(url, sourcesFileCache,
|
|
56
|
+
constructor(url, sourcesFileCache, moduleResolutionCache) {
|
|
58
57
|
super(url);
|
|
59
58
|
this.url = url;
|
|
60
59
|
this.type = exports.TYPE_NG_ENTRY_POINT;
|
|
61
60
|
this.cache = {
|
|
62
61
|
sourcesFileCache,
|
|
63
|
-
ngccProcessingCache,
|
|
64
62
|
analysesSourcesFileCache: new file_cache_1.FileCache(),
|
|
65
63
|
moduleResolutionCache,
|
|
66
64
|
outputCache: new Map(),
|
|
@@ -75,7 +73,6 @@ class PackageNode extends node_1.Node {
|
|
|
75
73
|
this.cache = {
|
|
76
74
|
globCache: {},
|
|
77
75
|
sourcesFileCache: new file_cache_1.FileCache(),
|
|
78
|
-
ngccProcessingCache: new ngcc_cache_1.NgccProcessingCache(),
|
|
79
76
|
moduleResolutionCache: typescript_1.default.createModuleResolutionCache(process.cwd(), s => s),
|
|
80
77
|
};
|
|
81
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA4D;
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAC5B,0DAAsD;AAEtD,w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AG,IAAI,EAAE,CAAC;AACrC,CAAC;AAFD,sBAEC;AAID,MAAa,cAAe,SAAQ,WAAI;IAGtC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QAJK,QAAG,GAAH,GAAG,CAAQ;QAHpB,SAAI,GAAG,2BAAmB,CAAC;QASlC,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,wBAAwB,EAAE,IAAI,sBAAS,EAAE;YACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;CAoBF;AApCD,wCAoCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAArC;;QACW,SAAI,GAAG,uBAAe,CAAC;QAGhC,UAAK,GAAG;YACN,SAAS,EAAE,EAAe;YAC1B,gBAAgB,EAAE,IAAI,sBAAS,EAAE;YACjC,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7E,CAAC;IACJ,CAAC;CAAA;AATD,kCASC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';\nimport { RollupCache } from 'rollup';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isDirty, isInProgress } from '../graph/select';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\n\nexport const TYPE_NG_PACKAGE = 'application/ng-package';\nexport const TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\nexport type GlobCache = Record<string, boolean | 'DIR' | 'FILE' | string[]>;\n\n/** A node that can be read through the `fs` api. */\nexport const URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nexport const URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isInProgress);\n}\n\nexport function isEntryPointDirty(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isDirty);\n}\n\nexport function isFileUrl(value: string): boolean {\n return value.startsWith(URL_PROTOCOL_FILE);\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string {\n if (url.startsWith(URL_PROTOCOL_FILE)) {\n return url.substring(URL_PROTOCOL_FILE.length);\n }\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version: string; content: string; map?: any }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n analysesSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n };\n }\n\n cache: {\n outputCache: OutputFileCache;\n oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;\n sourcesFileCache: FileCache;\n analysesSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n rollupFESM2020Cache?: RollupCache;\n rollupFESM2015Cache?: RollupCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n };\n\n data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n data: NgPackage;\n\n cache = {\n globCache: {} as GlobCache,\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
|
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.packageTransformFactory = void 0;
|
|
27
27
|
const dependency_graph_1 = require("dependency-graph");
|
|
28
28
|
const rxjs_1 = require("rxjs");
|
|
29
|
-
const operators_1 = require("rxjs/operators");
|
|
30
29
|
const file_watcher_1 = require("../file-system/file-watcher");
|
|
31
30
|
const node_1 = require("../graph/node");
|
|
32
31
|
const color_1 = require("../utils/color");
|
|
@@ -61,7 +60,7 @@ const packageTransformFactory = (project, options, initTsConfigTransform, analys
|
|
|
61
60
|
return source$.pipe(
|
|
62
61
|
// Discover packages and entry points
|
|
63
62
|
// Clean the primary dest folder (should clean all secondary sub-directory, as well)
|
|
64
|
-
(0,
|
|
63
|
+
(0, rxjs_1.switchMap)(async (graph) => {
|
|
65
64
|
ngPkg.data = await (0, discover_packages_1.discoverPackages)({ project });
|
|
66
65
|
graph.put(ngPkg);
|
|
67
66
|
const { dest, deleteDestPath } = ngPkg.data;
|
|
@@ -73,7 +72,7 @@ const packageTransformFactory = (project, options, initTsConfigTransform, analys
|
|
|
73
72
|
}
|
|
74
73
|
const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {
|
|
75
74
|
const { destinationFiles, moduleId } = entryPoint;
|
|
76
|
-
const node = new nodes_1.EntryPointNode((0, nodes_1.ngUrl)(moduleId), ngPkg.cache.sourcesFileCache, ngPkg.cache.
|
|
75
|
+
const node = new nodes_1.EntryPointNode((0, nodes_1.ngUrl)(moduleId), ngPkg.cache.sourcesFileCache, ngPkg.cache.moduleResolutionCache);
|
|
77
76
|
node.data = { entryPoint, destinationFiles };
|
|
78
77
|
node.state = 'dirty';
|
|
79
78
|
ngPkg.dependsOn(node);
|
|
@@ -99,11 +98,11 @@ const watchTransformFactory = (project, _options, analyseSourcesTransform, entry
|
|
|
99
98
|
const CompleteWaitingForFileChange = '\nCompilation complete. Watching for file changes...';
|
|
100
99
|
const FileChangeDetected = '\nFile change detected. Starting incremental compilation...';
|
|
101
100
|
const FailedWaitingForFileChange = '\nCompilation failed. Watching for file changes...';
|
|
102
|
-
return source$.pipe((0,
|
|
101
|
+
return source$.pipe((0, rxjs_1.switchMap)(graph => {
|
|
103
102
|
const { data, cache } = graph.find(nodes_1.isPackage);
|
|
104
103
|
const { onFileChange, watcher } = (0, file_watcher_1.createFileWatch)([], [data.dest]);
|
|
105
104
|
graph.watcher = watcher;
|
|
106
|
-
return onFileChange.pipe((0,
|
|
105
|
+
return onFileChange.pipe((0, rxjs_1.tap)(fileChange => {
|
|
107
106
|
const { filePath, event } = fileChange;
|
|
108
107
|
const { sourcesFileCache } = cache;
|
|
109
108
|
const cachedSourceFile = sourcesFileCache.get(filePath);
|
|
@@ -141,9 +140,9 @@ const watchTransformFactory = (project, _options, analyseSourcesTransform, entry
|
|
|
141
140
|
if (event === 'unlink' || event === 'add') {
|
|
142
141
|
cache.globCache = regenerateGlobCache(sourcesFileCache);
|
|
143
142
|
}
|
|
144
|
-
}), (0,
|
|
145
|
-
}), (0,
|
|
146
|
-
return (0, rxjs_1.of)(graph).pipe(buildTransformFactory(project, analyseSourcesTransform, entryPointTransform), (0,
|
|
143
|
+
}), (0, rxjs_1.debounceTime)(200), (0, rxjs_1.tap)(() => log.msg(FileChangeDetected)), (0, rxjs_1.startWith)(undefined), (0, rxjs_1.map)(() => graph));
|
|
144
|
+
}), (0, rxjs_1.switchMap)(graph => {
|
|
145
|
+
return (0, rxjs_1.of)(graph).pipe(buildTransformFactory(project, analyseSourcesTransform, entryPointTransform), (0, rxjs_1.tap)(() => log.msg(CompleteWaitingForFileChange)), (0, rxjs_1.catchError)(error => {
|
|
147
146
|
log.error(error);
|
|
148
147
|
log.msg(FailedWaitingForFileChange);
|
|
149
148
|
return rxjs_1.NEVER;
|
|
@@ -157,7 +156,7 @@ const buildTransformFactory = (project, analyseSourcesTransform, entryPointTrans
|
|
|
157
156
|
// Analyse dependencies and external resources for each entry point
|
|
158
157
|
analyseSourcesTransform,
|
|
159
158
|
// Next, run through the entry point transformation (assets rendering, code compilation)
|
|
160
|
-
scheduleEntryPoints(entryPointTransform), (0,
|
|
159
|
+
scheduleEntryPoints(entryPointTransform), (0, rxjs_1.tap)(graph => {
|
|
161
160
|
const ngPkg = graph.get(pkgUri);
|
|
162
161
|
log.success('\n------------------------------------------------------------------------------');
|
|
163
162
|
log.success(`Built Angular Package
|
|
@@ -169,7 +168,7 @@ const buildTransformFactory = (project, analyseSourcesTransform, entryPointTrans
|
|
|
169
168
|
log.msg(w(`\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\n`));
|
|
170
169
|
}));
|
|
171
170
|
};
|
|
172
|
-
const scheduleEntryPoints = (epTransform) => (0, rxjs_1.pipe)((0,
|
|
171
|
+
const scheduleEntryPoints = (epTransform) => (0, rxjs_1.pipe)((0, rxjs_1.concatMap)(graph => {
|
|
173
172
|
// Calculate node/dependency depth and determine build order
|
|
174
173
|
const depGraph = new dependency_graph_1.DepGraph({ circular: false });
|
|
175
174
|
const entryPoints = graph.filter(nodes_1.isEntryPoint);
|
|
@@ -186,10 +185,10 @@ const scheduleEntryPoints = (epTransform) => (0, rxjs_1.pipe)((0, operators_1.co
|
|
|
186
185
|
// The array index is the depth.
|
|
187
186
|
const groups = depGraph.overallOrder().map(nodes_1.ngUrl);
|
|
188
187
|
// Build entry points with lower depth values first.
|
|
189
|
-
return (0, rxjs_1.from)(groups).pipe((0,
|
|
188
|
+
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 !== 'done'), (0, rxjs_1.concatMap)(ep => (0, rxjs_1.of)(ep).pipe(
|
|
190
189
|
// Mark the entry point as 'in-progress'
|
|
191
|
-
(0,
|
|
192
|
-
(0,
|
|
190
|
+
(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',
|
|
191
|
+
(0, rxjs_1.defaultIfEmpty)(graph));
|
|
193
192
|
}));
|
|
194
193
|
function regenerateGlobCache(sourcesFileCache) {
|
|
195
194
|
const cache = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA4C;AAC5C,+BAAmF;AACnF,8CAWwB;AAExB,8DAA8D;AAE9D,wCAAkD;AAElD,0CAAwC;AACxC,oCAAoC;AACpC,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAuD;AACvD,mCAUiB;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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0BAAc,EAAC,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC;AAEJ,SAAS,mBAAmB,CAAC,gBAA2B;IACtD,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtC,+FAA+F;QAC/F,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YACjD,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport { NEVER, Observable, finalize, from, of as observableOf, pipe } from 'rxjs';\nimport {\n catchError,\n concatMap,\n debounceTime,\n defaultIfEmpty,\n filter,\n map,\n startWith,\n switchMap,\n takeLast,\n tap,\n} from 'rxjs/operators';\nimport { FileCache } from '../file-system/file-cache';\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 GlobCache,\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.ngccProcessingCache,\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, event } = 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 (event === 'unlink' || event === 'add') {\n cache.globCache = regenerateGlobCache(sourcesFileCache);\n }\n\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 // Regenerate glob cache\n if (event === 'unlink' || event === 'add') {\n cache.globCache = regenerateGlobCache(sourcesFileCache);\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\nfunction regenerateGlobCache(sourcesFileCache: FileCache): GlobCache {\n const cache: GlobCache = {};\n sourcesFileCache.forEach((value, key) => {\n // ignore node_modules and file which don't exists as they are not used by globbing in our case\n if (value.exists && !key.includes('node_modules')) {\n cache[key] = 'FILE';\n }\n });\n\n return cache;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA4C;AAC5C,+BAiBc;AAEd,8DAA8D;AAE9D,wCAAkD;AAElD,0CAAwC;AACxC,oCAAoC;AACpC,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAuD;AACvD,mCAUiB;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,EA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GAAG,MAAM,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,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 { FileCache } from '../file-system/file-cache';\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 GlobCache,\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, event } = 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 (event === 'unlink' || event === 'add') {\n cache.globCache = regenerateGlobCache(sourcesFileCache);\n }\n\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 // Regenerate glob cache\n if (event === 'unlink' || event === 'add') {\n cache.globCache = regenerateGlobCache(sourcesFileCache);\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\nfunction regenerateGlobCache(sourcesFileCache: FileCache): GlobCache {\n const cache: GlobCache = {};\n sourcesFileCache.forEach((value, key) => {\n // ignore node_modules and file which don't exists as they are not used by globbing in our case\n if (value.exists && !key.includes('node_modules')) {\n cache[key] = 'FILE';\n }\n });\n\n return cache;\n}\n"]}
|
|
@@ -2,5 +2,4 @@ import type { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli
|
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { BuildGraph } from '../graph/build-graph';
|
|
4
4
|
import { StylesheetProcessor } from '../styles/stylesheet-processor';
|
|
5
|
-
|
|
6
|
-
export declare function compileSourceFiles(graph: BuildGraph, tsConfig: ParsedConfiguration, moduleResolutionCache: ts.ModuleResolutionCache, extraOptions?: Partial<CompilerOptions>, stylesheetProcessor?: StylesheetProcessor, ngccProcessor?: NgccProcessor, watch?: boolean): Promise<void>;
|
|
5
|
+
export declare function compileSourceFiles(graph: BuildGraph, tsConfig: ParsedConfiguration, moduleResolutionCache: ts.ModuleResolutionCache, extraOptions?: Partial<CompilerOptions>, stylesheetProcessor?: StylesheetProcessor, watch?: boolean): Promise<void>;
|
|
@@ -30,16 +30,15 @@ exports.compileSourceFiles = void 0;
|
|
|
30
30
|
const typescript_1 = __importDefault(require("typescript"));
|
|
31
31
|
const nodes_1 = require("../ng-package/nodes");
|
|
32
32
|
const cache_compiler_host_1 = require("../ts/cache-compiler-host");
|
|
33
|
-
const ngcc_transform_compiler_host_1 = require("../ts/ngcc-transform-compiler-host");
|
|
34
33
|
const log = __importStar(require("../utils/log"));
|
|
35
34
|
const ng_compiler_cli_1 = require("../utils/ng-compiler-cli");
|
|
36
|
-
async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraOptions, stylesheetProcessor,
|
|
35
|
+
async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraOptions, stylesheetProcessor, watch) {
|
|
37
36
|
const { NgtscProgram, formatDiagnostics } = await (0, ng_compiler_cli_1.ngCompilerCli)();
|
|
38
37
|
const tsConfigOptions = { ...tsConfig.options, ...extraOptions };
|
|
39
38
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
40
39
|
const ngPackageNode = graph.find(nodes_1.isPackage);
|
|
41
40
|
const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;
|
|
42
|
-
const tsCompilerHost = (0,
|
|
41
|
+
const tsCompilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage);
|
|
43
42
|
const cache = entryPoint.cache;
|
|
44
43
|
const sourceFileCache = cache.sourcesFileCache;
|
|
45
44
|
// Create the Angular specific program that contains the Angular compiler
|
|
@@ -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,qFAA+E;AAC/E,kDAAoC;AACpC,8DAAyD;AAGlD,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,YAAuC,EACvC,mBAAyC,EACzC,aAA6B,EAC7B,KAAe;IAEf,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAA,+BAAa,GAAE,CAAC;IAElE,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC;IAEnE,MAAM,cAAc,GAAG,IAAA,wDAAyB,EAC9C,IAAA,uCAAiB,EACf,KAAK,EACL,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,CACpB,EACD,eAAe,EACf,aAAa,EACb,qBAAqB,CACtB,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,eAAe,GAAG,KAAK,CAAC,gBAAgB,CAAC;IAE/C,yEAAyE;IACzE,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAEpH,MAAM,eAAe,GAAG,cAAc,CAAC,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AE;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;AAtKD,gDAsKC","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 { ngccTransformCompilerHost } from '../ts/ngcc-transform-compiler-host';\nimport * as log from '../utils/log';\nimport { ngCompilerCli } from '../utils/ng-compiler-cli';\nimport { NgccProcessor } from './ngcc-processor';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n ngccProcessor?: NgccProcessor,\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 = ngccTransformCompilerHost(\n cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n ),\n tsConfigOptions,\n ngccProcessor,\n moduleResolutionCache,\n );\n\n const cache = entryPoint.cache;\n const sourceFileCache = cache.sourcesFileCache;\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n cache.oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n // 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.incrementalDriver.safeToSkipEmit(sourceFile)) {\n // If required to emit, diagnostics may have also changed\n if (!ignoreForDiagnostics.has(sourceFile)) {\n affectedFiles.add(sourceFile);\n }\n } else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {\n // Use cached Angular diagnostics for unchanged and unaffected files\n const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);\n if (angularDiagnostics?.length) {\n allDiagnostics.push(...angularDiagnostics);\n }\n }\n }\n\n // Collect new Angular diagnostics for files affected by changes\n for (const affectedFile of affectedFiles) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, /** OptimizeFor.WholeProgram */ 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,4DAA4B;AAE5B,+CAAqG;AAErG,mEAA4F;AAC5F,kDAAoC;AACpC,8DAAyD;AAElD,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,YAAuC,EACvC,mBAAyC,EACzC,KAAe;IAEf,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAA,+BAAa,GAAE,CAAC;IAElE,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC;IAEnE,MAAM,cAAc,GAAG,IAAA,uCAAiB,EACtC,KAAK,EACL,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,CACpB,CAAC;IAEF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,eAAe,GAAG,KAAK,CAAC,gBAAgB,CAAC;IAE/C,yEAAyE;IACzE,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAEpH,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAA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AAI,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.incrementalDriver.safeToSkipEmit(sourceFile)) {\n // If required to emit, diagnostics may have also changed\n if (!ignoreForDiagnostics.has(sourceFile)) {\n affectedFiles.add(sourceFile);\n }\n } else if (sourceFileCache && !affectedFiles.has(sourceFile) && !ignoreForDiagnostics.has(sourceFile)) {\n // Use cached Angular diagnostics for unchanged and unaffected files\n const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);\n if (angularDiagnostics?.length) {\n allDiagnostics.push(...angularDiagnostics);\n }\n }\n }\n\n // Collect new Angular diagnostics for files affected by changes\n for (const affectedFile of affectedFiles) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile, /** OptimizeFor.WholeProgram */ 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"]}
|
package/lib/packagr.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ngPackagr = exports.NgPackagr = void 0;
|
|
4
4
|
const injection_js_1 = require("injection-js");
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
|
-
const operators_1 = require("rxjs/operators");
|
|
7
6
|
const build_graph_1 = require("./graph/build-graph");
|
|
8
7
|
const entry_point_di_1 = require("./ng-package/entry-point/entry-point.di");
|
|
9
8
|
const init_tsconfig_di_1 = require("./ng-package/entry-point/init-tsconfig.di");
|
|
@@ -100,7 +99,7 @@ class NgPackagr {
|
|
|
100
99
|
buildAsObservable() {
|
|
101
100
|
const injector = injection_js_1.ReflectiveInjector.resolveAndCreate(this.providers);
|
|
102
101
|
const buildTransformOperator = injector.get(this.buildTransform);
|
|
103
|
-
return (0, rxjs_1.of)(new build_graph_1.BuildGraph()).pipe(buildTransformOperator, (0,
|
|
102
|
+
return (0, rxjs_1.of)(new build_graph_1.BuildGraph()).pipe(buildTransformOperator, (0, rxjs_1.map)(() => undefined));
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
exports.NgPackagr = NgPackagr;
|
package/lib/packagr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packagr.js","sourceRoot":"","sources":["../../src/lib/packagr.ts"],"names":[],"mappings":";;;AACA,+CAA4E;AAC5E,+
|
|
1
|
+
{"version":3,"file":"packagr.js","sourceRoot":"","sources":["../../src/lib/packagr.ts"],"names":[],"mappings":";;;AACA,+CAA4E;AAC5E,+BAA2D;AAC3D,qDAAiD;AAEjD,4EAAgF;AAChF,gFAA4E;AAC5E,wDAA2E;AAC3E,wDAA+E;AAC/E,6CAA8C;AAE9C;;;;;;GAMG;AACH,MAAa,SAAS;IAGpB,YAAoB,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QAFjC,mBAAc,GAA8B,8BAAiB,CAAC,OAAO,CAAC;IAElC,CAAC;IAE7C;;;;;;OAMG;IACI,WAAW,CAAC,O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CAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrE,MAAM,sBAAsB,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEjE,OAAO,IAAA,SAAY,EAAC,IAAI,wBAAU,EAAE,CAAC,CAAC,IAAI,CACxC,sBAAsB,EACtB,IAAA,UAAG,EAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CACrB,CAAC;IACJ,CAAC;CACF;AAvGD,8BAuGC;AAEM,MAAM,SAAS,GAAG,GAAc,EAAE,CACvC,IAAI,SAAS,CAAC;IACZ,sCAAsC;IACtC,GAAG,8BAAiB;IACpB,GAAG,sCAAqB;CACzB,CAAC,CAAC;AALQ,QAAA,SAAS,aAKjB","sourcesContent":["import type { ParsedConfiguration } from '@angular/compiler-cli';\nimport { InjectionToken, Provider, ReflectiveInjector } from 'injection-js';\nimport { Observable, map, of as observableOf } from 'rxjs';\nimport { BuildGraph } from './graph/build-graph';\nimport { Transform } from './graph/transform';\nimport { ENTRY_POINT_PROVIDERS } from './ng-package/entry-point/entry-point.di';\nimport { provideTsConfig } from './ng-package/entry-point/init-tsconfig.di';\nimport { NgPackagrOptions, provideOptions } from './ng-package/options.di';\nimport { PACKAGE_PROVIDERS, PACKAGE_TRANSFORM } from './ng-package/package.di';\nimport { provideProject } from './project.di';\n\n/**\n * The original ng-packagr implemented on top of a rxjs-ified and di-jectable transformation pipeline.\n *\n * See the `docs/transformations.md` for more prose description.\n *\n * @link https://github.com/ng-packagr/ng-packagr/pull/572\n */\nexport class NgPackagr {\n private buildTransform: InjectionToken<Transform> = PACKAGE_TRANSFORM.provide;\n\n constructor(private providers: Provider[]) {}\n\n /**\n * Adds options to ng-packagr\n *\n * @param options Ng Packagr Options\n * @return Self instance for fluent API\n * @deprecated use the options parameter in 'build' and 'watch' methods\n */\n public withOptions(options: NgPackagrOptions): NgPackagr {\n this.providers.push(provideOptions(options));\n\n return this;\n }\n\n /**\n * Sets the path to the user's \"ng-package\" file (either `package.json`, `ng-package.json`, or `ng-package.js`)\n *\n * @param project File path\n * @return Self instance for fluent API\n */\n public forProject(project: string): NgPackagr {\n this.providers.push(provideProject(project));\n\n return this;\n }\n\n /**\n * Adds dependency injection providers.\n *\n * @param providers\n * @return Self instance for fluent API\n * @link https://github.com/mgechev/injection-js\n */\n public withProviders(providers: Provider[]): NgPackagr {\n this.providers = [...this.providers, ...providers];\n\n return this;\n }\n\n /**\n * Overwrites the default TypeScript configuration.\n *\n * @param defaultValues A tsconfig providing default values to the compilation.\n * @return Self instance for fluent API\n */\n public withTsConfig(defaultValues: ParsedConfiguration | string): NgPackagr {\n this.providers.push(provideTsConfig(defaultValues));\n\n return this;\n }\n\n /**\n * Overwrites the 'build' transform.\n *\n * @param transform\n * @return Self instance for fluent API\n */\n public withBuildTransform(transform: InjectionToken<Transform>): NgPackagr {\n this.buildTransform = transform;\n\n return this;\n }\n\n /**\n * Builds the project by kick-starting the 'build' transform over an (initially) empty `BuildGraph``\n *\n * @return A promisified result of the transformation pipeline.\n */\n public build(options: NgPackagrOptions = {}): Promise<void> {\n this.providers.push(provideOptions(options));\n\n return this.buildAsObservable().toPromise();\n }\n\n /**\n * Builds and watch for changes by kick-starting the 'watch' transform over an (initially) empty `BuildGraph``\n *\n * @return An observable result of the transformation pipeline.\n */\n public watch(options: NgPackagrOptions = {}): Observable<void> {\n this.providers.push(provideOptions({ ...options, watch: true }));\n\n return this.buildAsObservable();\n }\n\n /**\n * Builds the project by kick-starting the 'build' transform over an (initially) empty `BuildGraph``\n *\n * @return An observable result of the transformation pipeline.\n */\n public buildAsObservable(): Observable<void> {\n const injector = ReflectiveInjector.resolveAndCreate(this.providers);\n const buildTransformOperator = injector.get(this.buildTransform);\n\n return observableOf(new BuildGraph()).pipe(\n buildTransformOperator,\n map(() => undefined),\n );\n }\n}\n\nexport const ngPackagr = (): NgPackagr =>\n new NgPackagr([\n // Add default providers to this list.\n ...PACKAGE_PROVIDERS,\n ...ENTRY_POINT_PROVIDERS,\n ]);\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ngCompilerCli = void 0;
|
|
4
4
|
async function ngCompilerCli() {
|
|
5
5
|
// This uses a dynamic import to load `@angular/compiler-cli` which may be ESM.
|
|
6
6
|
// CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript
|
|
@@ -15,9 +15,4 @@ async function ngCompilerCli() {
|
|
|
15
15
|
return compilerCliModule.readConfiguration ? compilerCliModule : compilerCliModule.default;
|
|
16
16
|
}
|
|
17
17
|
exports.ngCompilerCli = ngCompilerCli;
|
|
18
|
-
async function ngccCompilerCli() {
|
|
19
|
-
const compilerCliModule = await new Function(`return import('@angular/compiler-cli/ngcc');`)();
|
|
20
|
-
return compilerCliModule.process ? compilerCliModule : compilerCliModule.default;
|
|
21
|
-
}
|
|
22
|
-
exports.ngccCompilerCli = ngccCompilerCli;
|
|
23
18
|
//# sourceMappingURL=ng-compiler-cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-compiler-cli.js","sourceRoot":"","sources":["../../../src/lib/utils/ng-compiler-cli.ts"],"names":[],"mappings":";;;AAAO,KAAK,UAAU,aAAa;IACjC,+EAA+E;IAC/E,kFAAkF;IAClF,gFAAgF;IAChF,uFAAuF;IACvF,+FAA+F;IAC/F,sFAAsF;IACtF,cAAc;IACd,MAAM,iBAAiB,GAAG,MAAM,IAAI,QAAQ,CAAC,yCAAyC,CAAC,EAAE,CAAC;IAE1F,uFAAuF;IACvF,4EAA4E;IAC5E,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;AAC7F,CAAC;AAbD,sCAaC
|
|
1
|
+
{"version":3,"file":"ng-compiler-cli.js","sourceRoot":"","sources":["../../../src/lib/utils/ng-compiler-cli.ts"],"names":[],"mappings":";;;AAAO,KAAK,UAAU,aAAa;IACjC,+EAA+E;IAC/E,kFAAkF;IAClF,gFAAgF;IAChF,uFAAuF;IACvF,+FAA+F;IAC/F,sFAAsF;IACtF,cAAc;IACd,MAAM,iBAAiB,GAAG,MAAM,IAAI,QAAQ,CAAC,yCAAyC,CAAC,EAAE,CAAC;IAE1F,uFAAuF;IACvF,4EAA4E;IAC5E,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;AAC7F,CAAC;AAbD,sCAaC","sourcesContent":["export async function ngCompilerCli(): Promise<typeof import('@angular/compiler-cli')> {\n // This uses a dynamic import to load `@angular/compiler-cli` which may be ESM.\n // CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript\n // will currently, unconditionally downlevel dynamic import into a require call.\n // require calls cannot load ESM code and will result in a runtime error. To workaround\n // this, a Function constructor is used to prevent TypeScript from changing the dynamic import.\n // Once TypeScript provides support for keeping the dynamic import this workaround can\n // be dropped.\n const compilerCliModule = await new Function(`return import('@angular/compiler-cli');`)();\n\n // If it is not ESM then the functions needed will be stored in the `default` property.\n // This conditional can be removed when `@angular/compiler-cli` is ESM only.\n return compilerCliModule.readConfiguration ? compilerCliModule : compilerCliModule.default;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.0-next.1",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scss"
|
|
15
15
|
],
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": "^
|
|
17
|
+
"node": "^16.13.0 || >=18.10.0"
|
|
18
18
|
},
|
|
19
19
|
"author": "David Herges <david@spektrakel.de>",
|
|
20
20
|
"license": "MIT",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"esbuild": "^0.17.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@angular/compiler-cli": "^
|
|
64
|
+
"@angular/compiler-cli": "^16.0.0-next.0",
|
|
65
65
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
66
66
|
"tslib": "^2.3.0",
|
|
67
|
-
"typescript": ">=4.
|
|
67
|
+
"typescript": ">=4.9.3 <5.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"tailwindcss": {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers the absolute specifiers of libraries that have been processed by ngcc. This cache is
|
|
3
|
-
* reused across all entry-points of a package, so module requests across the entry-points can
|
|
4
|
-
* determine whether invoking ngcc is necessary.
|
|
5
|
-
*
|
|
6
|
-
* The cost of invoking ngcc for an entry-point that has already been processed is limited due to
|
|
7
|
-
* a fast path in ngcc, however even in this fast-path does ngcc scan the entry-point to determine
|
|
8
|
-
* if all dependencies have been processed. This cache allows to avoid that work, as entry-points
|
|
9
|
-
* are processed in batches during which the `node_modules` directory is not mutated.
|
|
10
|
-
*/
|
|
11
|
-
export declare class NgccProcessingCache {
|
|
12
|
-
private readonly processedModuleNames;
|
|
13
|
-
constructor();
|
|
14
|
-
private populate;
|
|
15
|
-
hasProcessed(moduleName: string): boolean;
|
|
16
|
-
markProcessed(moduleName: string): void;
|
|
17
|
-
clear(): void;
|
|
18
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NgccProcessingCache = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Registers the absolute specifiers of libraries that have been processed by ngcc. This cache is
|
|
6
|
-
* reused across all entry-points of a package, so module requests across the entry-points can
|
|
7
|
-
* determine whether invoking ngcc is necessary.
|
|
8
|
-
*
|
|
9
|
-
* The cost of invoking ngcc for an entry-point that has already been processed is limited due to
|
|
10
|
-
* a fast path in ngcc, however even in this fast-path does ngcc scan the entry-point to determine
|
|
11
|
-
* if all dependencies have been processed. This cache allows to avoid that work, as entry-points
|
|
12
|
-
* are processed in batches during which the `node_modules` directory is not mutated.
|
|
13
|
-
*/
|
|
14
|
-
class NgccProcessingCache {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.processedModuleNames = new Set();
|
|
17
|
-
this.populate();
|
|
18
|
-
}
|
|
19
|
-
populate() {
|
|
20
|
-
// Workaround for
|
|
21
|
-
// [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports"
|
|
22
|
-
// field module resolution of the package at /Users/alanagius/git/ng-packagr/node_modules/chai/package.json.
|
|
23
|
-
// Update this package.json to use a subpath pattern like "./*".
|
|
24
|
-
for (const lib of ['chai', 'tslib']) {
|
|
25
|
-
this.processedModuleNames.add(lib);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
hasProcessed(moduleName) {
|
|
29
|
-
return this.processedModuleNames.has(moduleName);
|
|
30
|
-
}
|
|
31
|
-
markProcessed(moduleName) {
|
|
32
|
-
this.processedModuleNames.add(moduleName);
|
|
33
|
-
}
|
|
34
|
-
clear() {
|
|
35
|
-
this.processedModuleNames.clear();
|
|
36
|
-
this.populate();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.NgccProcessingCache = NgccProcessingCache;
|
|
40
|
-
//# sourceMappingURL=ngcc-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngcc-cache.js","sourceRoot":"","sources":["../../../src/lib/ng-package/ngcc-cache.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAG9B;QAFiB,yBAAoB,GAAG,IAAI,GAAG,EAAU,CAAC;QAGxD,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAEO,QAAQ;QACd,iBAAiB;QACjB,uFAAuF;QACvF,4GAA4G;QAC5G,gEAAgE;QAChE,KAAK,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;YACnC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACpC;IACH,CAAC;IACD,YAAY,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,aAAa,CAAC,UAAkB;QAC9B,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK;QACH,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;CACF;AA5BD,kDA4BC","sourcesContent":["/**\n * Registers the absolute specifiers of libraries that have been processed by ngcc. This cache is\n * reused across all entry-points of a package, so module requests across the entry-points can\n * determine whether invoking ngcc is necessary.\n *\n * The cost of invoking ngcc for an entry-point that has already been processed is limited due to\n * a fast path in ngcc, however even in this fast-path does ngcc scan the entry-point to determine\n * if all dependencies have been processed. This cache allows to avoid that work, as entry-points\n * are processed in batches during which the `node_modules` directory is not mutated.\n */\nexport class NgccProcessingCache {\n private readonly processedModuleNames = new Set<string>();\n\n constructor() {\n this.populate();\n }\n\n private populate() {\n // Workaround for\n // [DEP0148] DeprecationWarning: Use of deprecated folder mapping \"./\" in the \"exports\"\n // field module resolution of the package at /Users/alanagius/git/ng-packagr/node_modules/chai/package.json.\n // Update this package.json to use a subpath pattern like \"./*\".\n for (const lib of ['chai', 'tslib']) {\n this.processedModuleNames.add(lib);\n }\n }\n hasProcessed(moduleName: string): boolean {\n return this.processedModuleNames.has(moduleName);\n }\n\n markProcessed(moduleName: string): void {\n this.processedModuleNames.add(moduleName);\n }\n\n clear(): void {\n this.processedModuleNames.clear();\n this.populate();\n }\n}\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { NgccProcessingCache } from '../ng-package/ngcc-cache';
|
|
3
|
-
import { EntryPointNode } from '../ng-package/nodes';
|
|
4
|
-
export declare class NgccProcessor {
|
|
5
|
-
private readonly compilerNgcc;
|
|
6
|
-
private readonly ngccProcessingCache;
|
|
7
|
-
private readonly projectPath;
|
|
8
|
-
private readonly compilerOptions;
|
|
9
|
-
private readonly entryPoints;
|
|
10
|
-
private _logger;
|
|
11
|
-
private _nodeModulesDirectory;
|
|
12
|
-
private _entryPointsUrl;
|
|
13
|
-
private readonly propertiesToConsider;
|
|
14
|
-
private skipProcessing;
|
|
15
|
-
constructor(compilerNgcc: typeof import('@angular/compiler-cli/ngcc'), ngccProcessingCache: NgccProcessingCache, projectPath: string, compilerOptions: ts.CompilerOptions, entryPoints: EntryPointNode[]);
|
|
16
|
-
/** Process the entire node modules tree. */
|
|
17
|
-
process(): Promise<void>;
|
|
18
|
-
/** Process a module and its dependencies. */
|
|
19
|
-
processModule(moduleName: string, resolvedModule: ts.ResolvedModule | ts.ResolvedTypeReferenceDirective): void;
|
|
20
|
-
/**
|
|
21
|
-
* Try resolve a package.json file from the resolved .d.ts file.
|
|
22
|
-
*/
|
|
23
|
-
private tryResolvePackage;
|
|
24
|
-
private findNodeModulesDirectory;
|
|
25
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.NgccProcessor = void 0;
|
|
27
|
-
const child_process_1 = require("child_process");
|
|
28
|
-
const crypto_1 = require("crypto");
|
|
29
|
-
const fs_1 = require("fs");
|
|
30
|
-
const path = __importStar(require("path"));
|
|
31
|
-
const nodes_1 = require("../ng-package/nodes");
|
|
32
|
-
const tsconfig_1 = require("../ts/tsconfig");
|
|
33
|
-
const fs_2 = require("../utils/fs");
|
|
34
|
-
const log = __importStar(require("../utils/log"));
|
|
35
|
-
// Transform a package and its typings when NGTSC is resolving a module.
|
|
36
|
-
class NgccProcessor {
|
|
37
|
-
constructor(compilerNgcc, ngccProcessingCache, projectPath, compilerOptions, entryPoints) {
|
|
38
|
-
this.compilerNgcc = compilerNgcc;
|
|
39
|
-
this.ngccProcessingCache = ngccProcessingCache;
|
|
40
|
-
this.projectPath = projectPath;
|
|
41
|
-
this.compilerOptions = compilerOptions;
|
|
42
|
-
this.entryPoints = entryPoints;
|
|
43
|
-
this.propertiesToConsider = ['es2015', 'browser', 'module', 'main'];
|
|
44
|
-
this.skipProcessing = false;
|
|
45
|
-
this._entryPointsUrl = this.entryPoints.map(({ url }) => (0, nodes_1.ngUrl)(url));
|
|
46
|
-
const { baseUrl } = this.compilerOptions;
|
|
47
|
-
this._nodeModulesDirectory = this.findNodeModulesDirectory(baseUrl);
|
|
48
|
-
}
|
|
49
|
-
/** Process the entire node modules tree. */
|
|
50
|
-
async process() {
|
|
51
|
-
// Under Bazel when running in sandbox mode parts of the filesystem is read-only, or when using
|
|
52
|
-
// Yarn PnP there may not be a node_modules directory. ngcc can't run in those cases, so the
|
|
53
|
-
// processing is skipped.
|
|
54
|
-
if (process.env.BAZEL_TARGET || !this._nodeModulesDirectory) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
// Only allow running this during the first run.
|
|
58
|
-
if (this.skipProcessing) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// Skip if node_modules are read-only
|
|
62
|
-
const corePackage = this.tryResolvePackage('@angular/core', this._nodeModulesDirectory);
|
|
63
|
-
if (corePackage && isReadOnlyFile(corePackage)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
// Perform a ngcc run check to determine if an initial execution is required.
|
|
67
|
-
// If a run hash file exists that matches the current package manager lock file and the
|
|
68
|
-
// project's tsconfig, then an initial ngcc run has already been performed.
|
|
69
|
-
let runHashFilePath;
|
|
70
|
-
const runHashBasePath = path.join(this._nodeModulesDirectory, '.ng-packagr-ngcc');
|
|
71
|
-
const projectBasePath = path.join(this._nodeModulesDirectory, '..');
|
|
72
|
-
try {
|
|
73
|
-
let lockData;
|
|
74
|
-
let lockFile = 'yarn.lock';
|
|
75
|
-
try {
|
|
76
|
-
lockData = await (0, fs_2.readFile)(path.join(projectBasePath, lockFile));
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
lockFile = 'package-lock.json';
|
|
80
|
-
lockData = await (0, fs_2.readFile)(path.join(projectBasePath, lockFile));
|
|
81
|
-
}
|
|
82
|
-
let ngccConfigData;
|
|
83
|
-
try {
|
|
84
|
-
ngccConfigData = await (0, fs_2.readFile)(path.join(projectBasePath, 'ngcc.config.js'));
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
ngccConfigData = '';
|
|
88
|
-
}
|
|
89
|
-
const relativeTsconfigPath = path.relative(projectBasePath, this.projectPath);
|
|
90
|
-
const tsconfigData = await (0, fs_2.readFile)(this.projectPath);
|
|
91
|
-
// Generate a hash that represents the state of the package lock file and used tsconfig
|
|
92
|
-
const runHash = (0, crypto_1.createHash)('sha256')
|
|
93
|
-
.update(lockData)
|
|
94
|
-
.update(lockFile)
|
|
95
|
-
.update(ngccConfigData)
|
|
96
|
-
.update(tsconfigData)
|
|
97
|
-
.update(relativeTsconfigPath)
|
|
98
|
-
.digest('hex');
|
|
99
|
-
// The hash is used directly in the file name to mitigate potential read/write race
|
|
100
|
-
// conditions as well as to only require a file existence check
|
|
101
|
-
runHashFilePath = path.join(runHashBasePath, runHash + '.lock');
|
|
102
|
-
// If the run hash lock file exists, then ngcc was already run against this project state
|
|
103
|
-
if (await (0, fs_2.exists)(runHashFilePath)) {
|
|
104
|
-
this.skipProcessing = true;
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
// Any error means an ngcc execution is needed
|
|
110
|
-
}
|
|
111
|
-
const { status, error } = (0, child_process_1.spawnSync)(process.execPath, [
|
|
112
|
-
this.compilerNgcc.ngccMainFilePath,
|
|
113
|
-
'--source' /** basePath */,
|
|
114
|
-
this._nodeModulesDirectory,
|
|
115
|
-
'--properties' /** propertiesToConsider */,
|
|
116
|
-
...this.propertiesToConsider,
|
|
117
|
-
'--first-only' /** compileAllFormats */,
|
|
118
|
-
'--create-ivy-entry-points' /** createNewEntryPointFormats */,
|
|
119
|
-
'--async',
|
|
120
|
-
'--tsconfig' /** tsConfigPath */,
|
|
121
|
-
path.normalize(this.projectPath) === tsconfig_1.defaultTsConfigPath ? '' : this.projectPath,
|
|
122
|
-
'--use-program-dependencies',
|
|
123
|
-
'--typings-only' /** typingsOnly */,
|
|
124
|
-
], {
|
|
125
|
-
stdio: ['inherit', process.stderr, process.stderr],
|
|
126
|
-
});
|
|
127
|
-
this.skipProcessing = true;
|
|
128
|
-
if (status !== 0) {
|
|
129
|
-
const errorMessage = (error === null || error === void 0 ? void 0 : error.message) || '';
|
|
130
|
-
throw new Error(errorMessage + `NGCC failed${errorMessage ? ', see above' : ''}.`);
|
|
131
|
-
}
|
|
132
|
-
// ngcc was successful so if a run hash was generated, write it for next time
|
|
133
|
-
if (runHashFilePath) {
|
|
134
|
-
try {
|
|
135
|
-
if (!(0, fs_1.existsSync)(runHashBasePath)) {
|
|
136
|
-
await (0, fs_2.mkdir)(runHashBasePath, { recursive: true });
|
|
137
|
-
}
|
|
138
|
-
await (0, fs_2.writeFile)(runHashFilePath, '');
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
// Errors are non-fatal
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/** Process a module and its dependencies. */
|
|
146
|
-
processModule(moduleName, resolvedModule) {
|
|
147
|
-
const resolvedFileName = resolvedModule.resolvedFileName;
|
|
148
|
-
if (!this._nodeModulesDirectory ||
|
|
149
|
-
!resolvedFileName ||
|
|
150
|
-
moduleName.startsWith('.') ||
|
|
151
|
-
this.ngccProcessingCache.hasProcessed(moduleName) ||
|
|
152
|
-
this._entryPointsUrl.includes((0, nodes_1.ngUrl)(moduleName))) {
|
|
153
|
-
// Skip when module_modules directory is not present, module is unknown, relative, an
|
|
154
|
-
// entrypoint or already processed.
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const packageJsonPath = this.tryResolvePackage(moduleName, resolvedFileName);
|
|
158
|
-
if (!packageJsonPath) {
|
|
159
|
-
// add it to processed so the second time round we skip this.
|
|
160
|
-
this.ngccProcessingCache.markProcessed(moduleName);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
// If the package.json is read only we should skip calling NGCC.
|
|
164
|
-
// With Bazel when running under sandbox the filesystem is read-only.
|
|
165
|
-
if (isReadOnlyFile(packageJsonPath)) {
|
|
166
|
-
// add it to processed so the second time round we skip this.
|
|
167
|
-
this.ngccProcessingCache.markProcessed(moduleName);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
this.compilerNgcc.process({
|
|
171
|
-
basePath: this._nodeModulesDirectory,
|
|
172
|
-
targetEntryPointPath: path.dirname(packageJsonPath),
|
|
173
|
-
compileAllFormats: false,
|
|
174
|
-
typingsOnly: true,
|
|
175
|
-
propertiesToConsider: this.propertiesToConsider,
|
|
176
|
-
createNewEntryPointFormats: true,
|
|
177
|
-
logger: this._logger,
|
|
178
|
-
tsConfigPath: this.projectPath === tsconfig_1.defaultTsConfigPath ? undefined : this.projectPath,
|
|
179
|
-
});
|
|
180
|
-
this.ngccProcessingCache.markProcessed(moduleName);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Try resolve a package.json file from the resolved .d.ts file.
|
|
184
|
-
*/
|
|
185
|
-
tryResolvePackage(moduleName, resolvedFileName) {
|
|
186
|
-
try {
|
|
187
|
-
return require.resolve(`${moduleName}/package.json`, {
|
|
188
|
-
paths: [resolvedFileName],
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
// if it fails this might be a deep import which doesn't have a package.json
|
|
193
|
-
// Ex: @angular/compiler/src/i18n/i18n_ast/package.json
|
|
194
|
-
// or local libraries which don't reside in node_modules
|
|
195
|
-
const packageJsonPath = path.resolve(resolvedFileName, '../package.json');
|
|
196
|
-
return (0, fs_1.existsSync)(packageJsonPath) ? packageJsonPath : undefined;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
findNodeModulesDirectory(startPoint) {
|
|
200
|
-
let current = startPoint;
|
|
201
|
-
while (path.dirname(current) !== current) {
|
|
202
|
-
const nodePath = path.join(current, 'node_modules');
|
|
203
|
-
if ((0, fs_1.existsSync)(nodePath)) {
|
|
204
|
-
return nodePath;
|
|
205
|
-
}
|
|
206
|
-
current = path.dirname(current);
|
|
207
|
-
}
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.NgccProcessor = NgccProcessor;
|
|
212
|
-
class NgccLogger {
|
|
213
|
-
constructor() {
|
|
214
|
-
this.level = 1;
|
|
215
|
-
}
|
|
216
|
-
debug(...args) {
|
|
217
|
-
log.debug(args.join(' '));
|
|
218
|
-
}
|
|
219
|
-
info(...args) {
|
|
220
|
-
log.info(args.join(' '));
|
|
221
|
-
}
|
|
222
|
-
warn(...args) {
|
|
223
|
-
log.warn(args.join(' '));
|
|
224
|
-
}
|
|
225
|
-
error(...args) {
|
|
226
|
-
log.error(args.join(' '));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function isReadOnlyFile(fileName) {
|
|
230
|
-
try {
|
|
231
|
-
(0, fs_1.accessSync)(fileName, fs_1.constants.W_OK);
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
catch {
|
|
235
|
-
return true;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
//# sourceMappingURL=ngcc-processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngcc-processor.js","sourceRoot":"","sources":["../../../src/lib/ngc/ngcc-processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAA0C;AAC1C,mCAAoC;AACpC,2BAAuD;AACvD,2CAA6B;AAG7B,+CAA4D;AAC5D,6CAAqD;AACrD,oCAAiE;AACjE,kDAAoC;AAEpC,wEAAwE;AACxE,MAAa,aAAa;IAOxB,YACmB,YAAyD,EACzD,mBAAwC,EACxC,WAAmB,EACnB,eAAmC,EACnC,WAA6B;QAJ7B,iBAAY,GAAZ,YAAY,CAA6C;QACzD,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAoB;QACnC,gBAAW,GA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C,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAG,IAAc;QACrB,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,CAAC;CACF;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI;QACF,IAAA,eAAU,EAAC,QAAQ,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC;QAErC,OAAO,KAAK,CAAC;KACd;IAAC,MAAM;QACN,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["import type { Logger } from '@angular/compiler-cli/ngcc';\nimport { spawnSync } from 'child_process';\nimport { createHash } from 'crypto';\nimport { accessSync, constants, existsSync } from 'fs';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgccProcessingCache } from '../ng-package/ngcc-cache';\nimport { EntryPointNode, ngUrl } from '../ng-package/nodes';\nimport { defaultTsConfigPath } from '../ts/tsconfig';\nimport { exists, mkdir, readFile, writeFile } from '../utils/fs';\nimport * as log from '../utils/log';\n\n// Transform a package and its typings when NGTSC is resolving a module.\nexport class NgccProcessor {\n private _logger: NgccLogger;\n private _nodeModulesDirectory: string | null;\n private _entryPointsUrl: string[];\n private readonly propertiesToConsider = ['es2015', 'browser', 'module', 'main'];\n private skipProcessing = false;\n\n constructor(\n private readonly compilerNgcc: typeof import('@angular/compiler-cli/ngcc'),\n private readonly ngccProcessingCache: NgccProcessingCache,\n private readonly projectPath: string,\n private readonly compilerOptions: ts.CompilerOptions,\n private readonly entryPoints: EntryPointNode[],\n ) {\n this._entryPointsUrl = this.entryPoints.map(({ url }) => ngUrl(url));\n\n const { baseUrl } = this.compilerOptions;\n this._nodeModulesDirectory = this.findNodeModulesDirectory(baseUrl);\n }\n\n /** Process the entire node modules tree. */\n async process(): Promise<void> {\n // Under Bazel when running in sandbox mode parts of the filesystem is read-only, or when using\n // Yarn PnP there may not be a node_modules directory. ngcc can't run in those cases, so the\n // processing is skipped.\n if (process.env.BAZEL_TARGET || !this._nodeModulesDirectory) {\n return;\n }\n\n // Only allow running this during the first run.\n if (this.skipProcessing) {\n return;\n }\n\n // Skip if node_modules are read-only\n const corePackage = this.tryResolvePackage('@angular/core', this._nodeModulesDirectory);\n if (corePackage && isReadOnlyFile(corePackage)) {\n return;\n }\n\n // Perform a ngcc run check to determine if an initial execution is required.\n // If a run hash file exists that matches the current package manager lock file and the\n // project's tsconfig, then an initial ngcc run has already been performed.\n let runHashFilePath: string | undefined;\n const runHashBasePath = path.join(this._nodeModulesDirectory, '.ng-packagr-ngcc');\n const projectBasePath = path.join(this._nodeModulesDirectory, '..');\n try {\n let lockData;\n let lockFile = 'yarn.lock';\n try {\n lockData = await readFile(path.join(projectBasePath, lockFile));\n } catch {\n lockFile = 'package-lock.json';\n lockData = await readFile(path.join(projectBasePath, lockFile));\n }\n\n let ngccConfigData;\n try {\n ngccConfigData = await readFile(path.join(projectBasePath, 'ngcc.config.js'));\n } catch {\n ngccConfigData = '';\n }\n\n const relativeTsconfigPath = path.relative(projectBasePath, this.projectPath);\n const tsconfigData = await readFile(this.projectPath);\n\n // Generate a hash that represents the state of the package lock file and used tsconfig\n const runHash = createHash('sha256')\n .update(lockData)\n .update(lockFile)\n .update(ngccConfigData)\n .update(tsconfigData)\n .update(relativeTsconfigPath)\n .digest('hex');\n\n // The hash is used directly in the file name to mitigate potential read/write race\n // conditions as well as to only require a file existence check\n runHashFilePath = path.join(runHashBasePath, runHash + '.lock');\n\n // If the run hash lock file exists, then ngcc was already run against this project state\n if (await exists(runHashFilePath)) {\n this.skipProcessing = true;\n\n return;\n }\n } catch {\n // Any error means an ngcc execution is needed\n }\n\n const { status, error } = spawnSync(\n process.execPath,\n [\n this.compilerNgcc.ngccMainFilePath,\n '--source' /** basePath */,\n this._nodeModulesDirectory,\n '--properties' /** propertiesToConsider */,\n ...this.propertiesToConsider,\n '--first-only' /** compileAllFormats */,\n '--create-ivy-entry-points' /** createNewEntryPointFormats */,\n '--async',\n '--tsconfig' /** tsConfigPath */,\n path.normalize(this.projectPath) === defaultTsConfigPath ? '' : this.projectPath,\n '--use-program-dependencies',\n '--typings-only' /** typingsOnly */,\n ],\n {\n stdio: ['inherit', process.stderr, process.stderr],\n },\n );\n\n this.skipProcessing = true;\n\n if (status !== 0) {\n const errorMessage = error?.message || '';\n throw new Error(errorMessage + `NGCC failed${errorMessage ? ', see above' : ''}.`);\n }\n\n // ngcc was successful so if a run hash was generated, write it for next time\n if (runHashFilePath) {\n try {\n if (!existsSync(runHashBasePath)) {\n await mkdir(runHashBasePath, { recursive: true });\n }\n await writeFile(runHashFilePath, '');\n } catch {\n // Errors are non-fatal\n }\n }\n }\n\n /** Process a module and its dependencies. */\n processModule(moduleName: string, resolvedModule: ts.ResolvedModule | ts.ResolvedTypeReferenceDirective): void {\n const resolvedFileName = resolvedModule.resolvedFileName;\n if (\n !this._nodeModulesDirectory ||\n !resolvedFileName ||\n moduleName.startsWith('.') ||\n this.ngccProcessingCache.hasProcessed(moduleName) ||\n this._entryPointsUrl.includes(ngUrl(moduleName))\n ) {\n // Skip when module_modules directory is not present, module is unknown, relative, an\n // entrypoint or already processed.\n return;\n }\n\n const packageJsonPath = this.tryResolvePackage(moduleName, resolvedFileName);\n if (!packageJsonPath) {\n // add it to processed so the second time round we skip this.\n this.ngccProcessingCache.markProcessed(moduleName);\n\n return;\n }\n\n // If the package.json is read only we should skip calling NGCC.\n // With Bazel when running under sandbox the filesystem is read-only.\n if (isReadOnlyFile(packageJsonPath)) {\n // add it to processed so the second time round we skip this.\n this.ngccProcessingCache.markProcessed(moduleName);\n\n return;\n }\n\n this.compilerNgcc.process({\n basePath: this._nodeModulesDirectory,\n targetEntryPointPath: path.dirname(packageJsonPath),\n compileAllFormats: false,\n typingsOnly: true,\n propertiesToConsider: this.propertiesToConsider,\n createNewEntryPointFormats: true,\n logger: this._logger,\n tsConfigPath: this.projectPath === defaultTsConfigPath ? undefined : this.projectPath,\n });\n\n this.ngccProcessingCache.markProcessed(moduleName);\n }\n\n /**\n * Try resolve a package.json file from the resolved .d.ts file.\n */\n private tryResolvePackage(moduleName: string, resolvedFileName: string): string | undefined {\n try {\n return require.resolve(`${moduleName}/package.json`, {\n paths: [resolvedFileName],\n });\n } catch {\n // if it fails this might be a deep import which doesn't have a package.json\n // Ex: @angular/compiler/src/i18n/i18n_ast/package.json\n // or local libraries which don't reside in node_modules\n const packageJsonPath = path.resolve(resolvedFileName, '../package.json');\n\n return existsSync(packageJsonPath) ? packageJsonPath : undefined;\n }\n }\n\n private findNodeModulesDirectory(startPoint: string): string | null {\n let current = startPoint;\n while (path.dirname(current) !== current) {\n const nodePath = path.join(current, 'node_modules');\n if (existsSync(nodePath)) {\n return nodePath;\n }\n\n current = path.dirname(current);\n }\n\n return null;\n }\n}\n\nclass NgccLogger implements Logger {\n level = /** LogLevel.info**/ 1;\n\n debug(...args: string[]) {\n log.debug(args.join(' '));\n }\n\n info(...args: string[]) {\n log.info(args.join(' '));\n }\n\n warn(...args: string[]) {\n log.warn(args.join(' '));\n }\n\n error(...args: string[]) {\n log.error(args.join(' '));\n }\n}\n\nfunction isReadOnlyFile(fileName: string): boolean {\n try {\n accessSync(fileName, constants.W_OK);\n\n return false;\n } catch {\n return true;\n }\n}\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
import { NgccProcessor } from '../ngc/ngcc-processor';
|
|
3
|
-
export declare function ngccTransformCompilerHost(compilerHost: ts.CompilerHost, compilerOptions: ts.CompilerOptions, ngccProcessor: NgccProcessor, moduleResolutionCache: ts.ModuleResolutionCache): ts.CompilerHost;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ngccTransformCompilerHost = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
function ngccTransformCompilerHost(compilerHost, compilerOptions, ngccProcessor, moduleResolutionCache) {
|
|
9
|
-
return {
|
|
10
|
-
...compilerHost,
|
|
11
|
-
resolveModuleNames: (moduleNames, containingFile) => {
|
|
12
|
-
return moduleNames.map(moduleName => {
|
|
13
|
-
const { resolvedModule } = typescript_1.default.resolveModuleName(moduleName, containingFile, compilerOptions, compilerHost, moduleResolutionCache);
|
|
14
|
-
if (resolvedModule) {
|
|
15
|
-
ngccProcessor.processModule(moduleName, resolvedModule);
|
|
16
|
-
}
|
|
17
|
-
return resolvedModule;
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
resolveTypeReferenceDirectives: (typeReferenceDirectiveNames, containingFile, redirectedReference) => {
|
|
21
|
-
return typeReferenceDirectiveNames.map(name => {
|
|
22
|
-
const moduleName = typeof name === 'string' ? name : name.fileName;
|
|
23
|
-
const { resolvedTypeReferenceDirective } = typescript_1.default.resolveTypeReferenceDirective(moduleName, containingFile, compilerOptions, compilerHost, redirectedReference);
|
|
24
|
-
if (resolvedTypeReferenceDirective) {
|
|
25
|
-
ngccProcessor.processModule(moduleName, resolvedTypeReferenceDirective);
|
|
26
|
-
}
|
|
27
|
-
return resolvedTypeReferenceDirective;
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.ngccTransformCompilerHost = ngccTransformCompilerHost;
|
|
33
|
-
//# sourceMappingURL=ngcc-transform-compiler-host.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngcc-transform-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/ngcc-transform-compiler-host.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAG5B,SAAgB,yBAAyB,CACvC,YAA6B,EAC7B,eAAmC,EACnC,aAA4B,EAC5B,qBAA+C;IAE/C,OAAO;QACL,GAAG,YAAY;QACf,kBAAkB,EAAE,CAAC,WAAqB,EAAE,cAAsB,EAAE,EAAE;YACpE,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAClC,MAAM,EAAE,cAAc,EAAE,GAAG,oBAAE,CAAC,iBAAiB,CAC7C,UAAU,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,qBAAqB,CACtB,CAAC;gBAEF,IAAI,cAAc,EAAE;oBAClB,aAAa,CAAC,aAAa,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;iBACzD;gBAED,OAAO,cAAc,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,8BAA8B,EAAE,CAC9B,2BAA0D,EAC1D,cAAsB,EACtB,mBAAiD,EACjD,EAAE;YACF,OAAO,2BAA2B,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBAC5C,MAAM,UAAU,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAEnE,MAAM,EAAE,8BAA8B,EAAE,GAAG,oBAAE,CAAC,6BAA6B,CACzE,UAAU,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,mBAAmB,CACpB,CAAC;gBAEF,IAAI,8BAA8B,EAAE;oBAClC,aAAa,CAAC,aAAa,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC;iBACzE;gBAED,OAAO,8BAA8B,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAjDD,8DAiDC","sourcesContent":["import ts from 'typescript';\nimport { NgccProcessor } from '../ngc/ngcc-processor';\n\nexport function ngccTransformCompilerHost(\n compilerHost: ts.CompilerHost,\n compilerOptions: ts.CompilerOptions,\n ngccProcessor: NgccProcessor,\n moduleResolutionCache: ts.ModuleResolutionCache,\n): ts.CompilerHost {\n return {\n ...compilerHost,\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n containingFile,\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n if (resolvedModule) {\n ngccProcessor.processModule(moduleName, resolvedModule);\n }\n\n return resolvedModule;\n });\n },\n resolveTypeReferenceDirectives: (\n typeReferenceDirectiveNames: string[] | ts.FileReference[],\n containingFile: string,\n redirectedReference?: ts.ResolvedProjectReference,\n ) => {\n return typeReferenceDirectiveNames.map(name => {\n const moduleName = typeof name === 'string' ? name : name.fileName;\n\n const { resolvedTypeReferenceDirective } = ts.resolveTypeReferenceDirective(\n moduleName,\n containingFile,\n compilerOptions,\n compilerHost,\n redirectedReference,\n );\n\n if (resolvedTypeReferenceDirective) {\n ngccProcessor.processModule(moduleName, resolvedTypeReferenceDirective);\n }\n\n return resolvedTypeReferenceDirective;\n });\n },\n };\n}\n"]}
|