ng-packagr 15.0.3 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import * as chokidar from 'chokidar';
2
2
  import { Observable } from 'rxjs';
3
- declare type AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';
4
- export declare type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;
3
+ type AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';
4
+ export type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;
5
5
  export interface FileChangedEvent {
6
6
  filePath: string;
7
7
  event: FileWatchEvent;
@@ -8,7 +8,8 @@ import { OutputFileCache } from '../ng-package/nodes';
8
8
  export interface RollupOptions {
9
9
  moduleName: string;
10
10
  entry: string;
11
- dest: string;
11
+ entryName: string;
12
+ dir: string;
12
13
  sourceRoot: string;
13
14
  downlevel?: boolean;
14
15
  cache?: rollup.RollupCache;
@@ -19,6 +20,5 @@ export interface RollupOptions {
19
20
  /** Runs rollup over the given entry file, writes a bundle file. */
20
21
  export declare function rollupBundleFile(opts: RollupOptions): Promise<{
21
22
  cache: rollup.RollupCache;
22
- code: string;
23
- map: rollup.SourceMap;
23
+ files: (rollup.OutputChunk | rollup.OutputAsset)[];
24
24
  }>;
@@ -38,13 +38,12 @@ const file_loader_plugin_1 = require("./file-loader-plugin");
38
38
  /** Runs rollup over the given entry file, writes a bundle file. */
39
39
  async function rollupBundleFile(opts) {
40
40
  var _a;
41
- log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest}`);
41
+ log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
42
42
  const cacheDirectory = opts.cacheDirectory;
43
43
  // Create the bundle
44
44
  const bundle = await rollup.rollup({
45
45
  context: 'this',
46
46
  external: moduleId => isExternalDependency(moduleId),
47
- inlineDynamicImports: false,
48
47
  cache: (_a = opts.cache) !== null && _a !== void 0 ? _a : (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
49
48
  input: opts.entry,
50
49
  plugins: [
@@ -73,19 +72,20 @@ async function rollupBundleFile(opts) {
73
72
  const output = await bundle.write({
74
73
  name: opts.moduleName,
75
74
  format: 'es',
76
- file: opts.dest,
75
+ dir: opts.dir,
76
+ inlineDynamicImports: false,
77
+ chunkFileNames: opts.entryName + '-[name]-[hash].mjs',
78
+ entryFileNames: opts.entryName + '.mjs',
77
79
  banner: '',
78
80
  sourcemap: true,
79
81
  });
80
82
  if (cacheDirectory) {
81
83
  await (0, cache_1.saveCacheEntry)(cacheDirectory, opts.cacheKey, JSON.stringify(bundle.cache));
82
84
  }
83
- const { code, map } = output.output[0];
84
85
  // Close the bundle to let plugins clean up their external processes or services
85
86
  await bundle.close();
86
87
  return {
87
- code: code + '//# sourceMapping' + `URL=${path.basename(opts.dest)}.map\n`,
88
- map,
88
+ files: output.output,
89
89
  cache: bundle.cache,
90
90
  };
91
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAC7C,sFAAsD;AACtD,2CAA6B;AAC7B,+CAAiC;AAEjC,0CAAgE;AAChE,kDAAoC;AACpC,yDAAgE;AAChE,6DAAwD;AAmBxD,mEAAmE;AAC5D,KAAK,UAAU,gBAAgB,CACpC,IAAmB;;IAEnB,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAEvE,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAE3C,oBAAoB;IACpB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACj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AAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACnF;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEvC,gFAAgF;IAChF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO;QACL,IAAI,EAAE,IAAI,GAAG,mBAAmB,GAAG,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;QAC1E,GAAG;QACH,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AA7DD,4CA6DC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACrF,yGAAyG;QACzG,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as path from 'path';\nimport * as rollup from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { downlevelCodeWithTscPlugin } from './downlevel-plugin';\nimport { fileLoaderPlugin } from './file-loader-plugin';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n dest: string;\n sourceRoot: string;\n downlevel?: boolean;\n cache?: rollup.RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: rollup.RollupCache; code: string; map: rollup.SourceMap }> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest}`);\n\n const cacheDirectory = opts.cacheDirectory;\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => isExternalDependency(moduleId),\n inlineDynamicImports: false,\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins: [\n nodeResolve(),\n rollupJson(),\n fileLoaderPlugin(opts.fileCache),\n opts.downlevel ? downlevelCodeWithTscPlugin() : undefined,\n ],\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n file: opts.dest,\n banner: '',\n sourcemap: true,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, JSON.stringify(bundle.cache));\n }\n\n const { code, map } = output.output[0];\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n code: code + '//# sourceMapping' + `URL=${path.basename(opts.dest)}.map\\n`,\n map,\n cache: bundle.cache,\n };\n}\n\nfunction isExternalDependency(moduleId: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId.startsWith('.') || moduleId.startsWith('/') || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return false;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;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AE,IAAI;QACtB,8CAA8C;QAC9C,qDAAqD;QACrD,SAAS,EAAE,KAAK;KACjB,CAAC,CAAC;IAEH,4BAA4B;IAC5B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;QAChC,IAAI,EAAE,IAAI,CAAC,UAAU;QACrB,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,oBAAoB,EAAE,KAAK;QAC3B,cAAc,EAAE,IAAI,CAAC,SAAS,GAAG,oBAAoB;QACrD,cAAc,EAAE,IAAI,CAAC,SAAS,GAAG,MAAM;QACvC,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACnF;IAED,gFAAgF;IAChF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AA5DD,4CA4DC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACrF,yGAAyG;QACzG,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as path from 'path';\nimport * as rollup from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { downlevelCodeWithTscPlugin } from './downlevel-plugin';\nimport { fileLoaderPlugin } from './file-loader-plugin';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n entryName: string;\n dir: string;\n sourceRoot: string;\n downlevel?: boolean;\n cache?: rollup.RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: rollup.RollupCache; files: (rollup.OutputChunk | rollup.OutputAsset)[] }> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);\n\n const cacheDirectory = opts.cacheDirectory;\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => isExternalDependency(moduleId),\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins: [\n nodeResolve(),\n rollupJson(),\n fileLoaderPlugin(opts.fileCache),\n opts.downlevel ? downlevelCodeWithTscPlugin() : undefined,\n ],\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n dir: opts.dir,\n inlineDynamicImports: false,\n chunkFileNames: opts.entryName + '-[name]-[hash].mjs',\n entryFileNames: opts.entryName + '.mjs',\n banner: '',\n sourcemap: true,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, JSON.stringify(bundle.cache));\n }\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n files: output.output,\n cache: bundle.cache,\n };\n}\n\nfunction isExternalDependency(moduleId: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId.startsWith('.') || moduleId.startsWith('/') || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return false;\n }\n\n return true;\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { FSWatcher } from 'chokidar';
2
2
  import { Node } from './node';
3
- export declare type SimplePredicate<T = Node> = {
3
+ export type SimplePredicate<T = Node> = {
4
4
  (value: T, index: number): boolean;
5
5
  and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;
6
6
  };
7
- export declare type ComplexPredicate<T = Node, R extends T = T> = SimplePredicate<T> | {
7
+ export type ComplexPredicate<T = Node, R extends T = T> = SimplePredicate<T> | {
8
8
  (value: T, index: number): value is R;
9
9
  and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;
10
10
  };
@@ -1,4 +1,4 @@
1
- export declare type NodeState = '' | 'dirty' | 'in-progress' | 'pending' | 'done';
1
+ export type NodeState = '' | 'dirty' | 'in-progress' | 'pending' | 'done';
2
2
  export declare const STATE_DIRTY: NodeState;
3
3
  export declare const STATE_IN_PROGRESS: NodeState;
4
4
  export declare const STATE_PENDING: NodeState;
@@ -34,11 +34,12 @@ 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;
37
38
  if (!(await (0, fs_1.exists)(filePath))) {
38
39
  return undefined;
39
40
  }
40
41
  if (filePath.endsWith('.js')) {
41
- return Promise.resolve().then(() => __importStar(require(filePath)));
42
+ return _a = filePath, Promise.resolve().then(() => __importStar(require(_a)));
42
43
  }
43
44
  const data = await (0, fs_1.readFile)(filePath, 'utf-8');
44
45
  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;IAC5C,IAAI,CAAC,CAAC,MAAM,IAAA,WAAM,EAAC,QAAQ,CAAC,CAAC,EAAE;QAC7B,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,yDAAc,QAAQ,IAAE;KACzB;IAED,MAAM,IAAI,GAAG,MAAM,IAAA,aAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/C,OAAO,IAAA,oBAAS,EAAC,IAAI,EAAE,SAAS,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,kBAAkB,CAAC,oBAA4B,EAAE,WAAW,GAAG,KAAK;;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,IAAA,SAAI,EAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE7E,IAAI,aAAsB,CAAC;IAC3B,IAAI,SAAS,CAAC,WAAW,EAAE,EAAE;QAC3B,aAAa,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE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C,EAAE,OAAO,EAAuB;IACrE,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAErE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnF,MAAM,OAAO,GAAG,IAAI,0BAAY,CAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;IACvE,GAAG,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE5D,MAAM,WAAW,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"]}
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,CAAC;KAClB;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC5B,YAAc,QAAQ,0DAAE;KACzB;IAED,MAAM,IAAI,GAAG,MAAM,IAAA,aAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/C,OAAO,IAAA,oBAAS,EAAC,IAAI,EAAE,SAAS,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,kBAAkB,CAAC,oBAA4B,EAAE,WAAW,GAAG,KAAK;;IACjF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,IAAA,SAAI,EAA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AAE,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"]}
@@ -38,17 +38,17 @@ const ng_compiler_cli_1 = require("../../utils/ng-compiler-cli");
38
38
  const nodes_1 = require("../nodes");
39
39
  const compileNgcTransformFactory = (StylesheetProcessor, options) => {
40
40
  return (0, transform_1.transformFromPromise)(async (graph) => {
41
- var _a;
42
- var _b;
41
+ var _a, _b;
42
+ var _c;
43
43
  const spinner = (0, ora_1.default)({
44
44
  hideCursor: false,
45
45
  discardStdin: false,
46
46
  });
47
+ const entryPoints = graph.filter(nodes_1.isEntryPoint);
48
+ const entryPoint = entryPoints.find((0, nodes_1.isEntryPointInProgress)());
49
+ const ngPackageNode = graph.find(nodes_1.isPackage);
50
+ const projectBasePath = ngPackageNode.data.primary.basePath;
47
51
  try {
48
- const entryPoints = graph.filter(nodes_1.isEntryPoint);
49
- const entryPoint = entryPoints.find((0, nodes_1.isEntryPointInProgress)());
50
- const ngPackageNode = graph.find(nodes_1.isPackage);
51
- const projectBasePath = ngPackageNode.data.primary.basePath;
52
52
  // Add paths mappings for dependencies
53
53
  const tsConfig = (0, tsconfig_1.setDependenciesTsConfigPaths)(entryPoint.data.tsConfig, entryPoints);
54
54
  // Compile TypeScript sources
@@ -61,7 +61,7 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
61
61
  // Only run the async version of NGCC during the primary entrypoint processing.
62
62
  await ngccProcessor.process();
63
63
  }
64
- (_a = (_b = entryPoint.cache).stylesheetProcessor) !== null && _a !== void 0 ? _a : (_b.stylesheetProcessor = new StylesheetProcessor(projectBasePath, basePath, cssUrl, styleIncludePaths, options.cacheEnabled && options.cacheDirectory));
64
+ (_a = (_c = entryPoint.cache).stylesheetProcessor) !== null && _a !== void 0 ? _a : (_c.stylesheetProcessor = new StylesheetProcessor(projectBasePath, basePath, cssUrl, styleIncludePaths, options.cacheEnabled && options.cacheDirectory));
65
65
  await (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, {
66
66
  outDir: path.dirname(esm2020),
67
67
  declarationDir: path.dirname(declarations),
@@ -73,6 +73,11 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
73
73
  spinner.fail();
74
74
  throw error;
75
75
  }
76
+ finally {
77
+ if (!options.watch) {
78
+ (_b = entryPoint.cache.stylesheetProcessor) === null || _b === void 0 ? void 0 : _b.destroy();
79
+ }
80
+ }
76
81
  spinner.succeed();
77
82
  return graph;
78
83
  });
@@ -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;AACpE,6DAAyD;AAEzD,gDAAiE;AACjE,iEAA8D;AAC9D,oCAAwG;AAGjG,MAAM,0BAA0B,GAAG,CACxC,mBAAoD,EACpD,OAAyB,EACd,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M,aAAa,CAAC,OAAO,EAAE,CAAC;aAC/B;YAED,YAAA,UAAU,CAAC,KAAK,EAAC,mBAAmB,uCAAnB,mBAAmB,GAAK,IAAI,mBAAmB,CAC9D,eAAe,EACf,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,cAAc,CAC/C,EAAC;YAEF,MAAM,IAAA,yCAAkB,EACtB,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB;gBACE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC7B,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;gBAC1C,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;aAC/B,EACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,EACpC,aAAa,EACb,OAAO,CAAC,KAAK,CACd,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;SACb;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAtEW,QAAA,0BAA0B,8BAsErC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { NgccProcessor } from '../../ngc/ngcc-processor';\nimport { StylesheetProcessor as StylesheetProcessorClass } from '../../styles/stylesheet-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport { ngccCompilerCli } from '../../utils/ng-compiler-cli';\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 try {\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 // 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, ngccProcessingCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in Ivy ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n const ngccProcessor = new NgccProcessor(\n await ngccCompilerCli(),\n ngccProcessingCache,\n tsConfig.project,\n tsConfig.options,\n entryPoints,\n );\n if (!entryPoint.data.entryPoint.isSecondaryEntryPoint) {\n // Only run the async version of NGCC during the primary entrypoint processing.\n await ngccProcessor.process();\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 ngccProcessor,\n options.watch,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
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;AAC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AAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,OAAO,EAChB,WAAW,CACZ,CAAC;YACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,EAAE;gBACrD,+EAA+E;gBAC/E,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;aAC/B;YAED,YAAA,UAAU,CAAC,KAAK,EAAC,mBAAmB,uCAAnB,mBAAmB,GAAK,IAAI,mBAAmB,CAC9D,eAAe,EACf,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,cAAc,CAC/C,EAAC;YAEF,MAAM,IAAA,yCAAkB,EACtB,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB;gBACE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC7B,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;gBAC1C,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;aAC/B,EACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,EACpC,aAAa,EACb,OAAO,CAAC,KAAK,CACd,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;SACb;gBAAS;YACR,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;gBAClB,MAAA,UAAU,CAAC,KAAK,CAAC,mBAAmB,0CAAE,OAAO,EAAE,CAAC;aACjD;SACF;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA1EW,QAAA,0BAA0B,8BA0ErC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { compileSourceFiles } from '../../ngc/compile-source-files';\nimport { NgccProcessor } from '../../ngc/ngcc-processor';\nimport { StylesheetProcessor as StylesheetProcessorClass } from '../../styles/stylesheet-processor';\nimport { setDependenciesTsConfigPaths } from '../../ts/tsconfig';\nimport { ngccCompilerCli } from '../../utils/ng-compiler-cli';\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, ngccProcessingCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in Ivy ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n const ngccProcessor = new NgccProcessor(\n await ngccCompilerCli(),\n ngccProcessingCache,\n tsConfig.project,\n tsConfig.options,\n entryPoints,\n );\n if (!entryPoint.data.entryPoint.isSecondaryEntryPoint) {\n // Only run the async version of NGCC during the primary entrypoint processing.\n await ngccProcessor.process();\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 ngccProcessor,\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"]}
@@ -12,6 +12,10 @@ export interface DestinationFiles {
12
12
  esm2020: string;
13
13
  /** Sub path of entrypoint distributable. */
14
14
  directory: string;
15
+ /** Absolute path of this entry point `FESM2020` directory */
16
+ fesm2020Dir: string;
17
+ /** Absolute path of this entry point `FESM2015` directory */
18
+ fesm2015Dir: string;
15
19
  }
16
20
  /**
17
21
  * An entry point - quoting Angular Package Format - is:
@@ -102,6 +102,8 @@ class NgEntryPoint {
102
102
  esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),
103
103
  fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),
104
104
  fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.mjs`),
105
+ fesm2020Dir: pathJoinWithDest('fesm2020'),
106
+ fesm2015Dir: pathJoinWithDest('fesm2015'),
105
107
  };
106
108
  }
107
109
  $get(key) {
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,2CAAkD;AAgBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IACvB;IACE,+DAA+D;IAC/C,WAAgC;IAChD,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,iGAAiG;IAChF,aAAsC;QANvC,gBAAW,GAAX,WAAW,CAAqB;QAEhC,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GAAR,QAAQ,CAAQ;QAEf,kBAAa,GAAb,aAAa,CAAyB;IACtD,CAAC;IAEJ,sEAAs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AC,aAAa,CAAC,QAAQ,CAAC;SACpC;aAAM;YACL,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACjC;IACH,CAAC;IAEO,eAAe,CAAC,SAAS,GAAG,GAAG;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9D;aAAM;YACL,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACjD;IACH,CAAC;CACF;AA3GD,oCA2GC","sourcesContent":["import * as path from 'path';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../../utils/path';\n\n/** A list of output absolute paths for various formats */\nexport interface DestinationFiles {\n /** Absolute path of this entry point `declarations` */\n declarations: string;\n /** Absolute path of this entry point `FESM2020` module */\n fesm2020: string;\n /** Absolute path of this entry point `FESM2015` module */\n fesm2015: string;\n /** Absolute path of this entry point `ESM2020` module */\n esm2020: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n}\n\n/**\n * An entry point - quoting Angular Package Format - is:\n *\n * > a module intended to be imported by the user. It is referenced by a unique module ID and\n * > exports the public API referenced by that module ID. An example is `@angular/core` or\n * > `@angular/core/testing`. Both entry points exist in the `@angular/core` package, but they\n * > export different symbols. A package can have many entry points.\n *\n * #### Public API, source file tree and build output\n *\n * An entry point serves as the root of a source tree.\n * The entry point's public API references one TypeScript source file (`*.ts`).\n * That source file, e.g. `public_api.ts`, references other source files who in turn may reference\n * other source files, thus creating a tree of source code files.\n * The source files may be TypeScript (`*.ts`), Templates (`.html`) or Stylesheets\n * (`.css`, `.scss`, ..), or other formats.\n *\n * The compilation process for an entry point is a series of transformations applied to the source\n * files, e.g. TypeScript compilation, Inlining of Stylesheets and Templates, and so on.\n * As a result of the compilation process, an entry point is transpiled to a set of artefacts\n * (the build output) which include a FESM'15 Bundle, a FESM'5 Bundle, AoT metadata, TypeScript\n * type definitions, and so on.\n *\n * #### Representation in the domain\n *\n * The set of artefacts is reflected by `NgArtefacts`;\n * one `NgEntryPoint` relates to one `NgArtefacts`.\n * The parent package of an entry point is reflected by `NgPackage`.\n */\nexport class NgEntryPoint {\n constructor(\n /** Values from the `package.json` file of this entry point. */\n public readonly packageJson: Record<string, any>,\n /** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */\n public readonly ngPackageJson: NgPackageConfig,\n /** Absolute directory path of this entry point's `package.json` location. */\n public readonly basePath: string,\n /** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */\n private readonly secondaryData?: { [key: string]: any },\n ) {}\n\n /** Absolute file path of the entry point's source code entry file. */\n public get entryFilePath(): string {\n return path.resolve(this.basePath, this.entryFile);\n }\n\n /** Whether or not the entrypoint is secondary */\n public get isSecondaryEntryPoint(): boolean {\n return !!this.secondaryData;\n }\n\n /** Absolute directory path of this entry point's 'package.json'. */\n public get destinationPath(): string {\n if (this.secondaryData) {\n return this.secondaryData.destinationPath;\n } else {\n return path.resolve(this.basePath, this.$get('dest'));\n }\n }\n\n public get destinationFiles(): DestinationFiles {\n let primaryDestPath = this.destinationPath;\n let secondaryDir = '';\n\n if (this.secondaryData) {\n primaryDestPath = this.secondaryData.primaryDestinationPath;\n secondaryDir = path.relative(primaryDestPath, this.secondaryData.destinationPath);\n }\n\n const flatModuleFile = this.flatModuleFile;\n const pathJoinWithDest = (...paths: string[]) => path.join(primaryDestPath, ...paths);\n\n return {\n directory: ensureUnixPath(secondaryDir),\n declarations: pathJoinWithDest(secondaryDir, 'index.d.ts'),\n esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),\n fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),\n fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.mjs`),\n };\n }\n\n public $get(key: string): any {\n const parts = key.split('.');\n let value = this.ngPackageJson as unknown;\n for (const key of parts) {\n if (typeof value === 'object' && key in value) {\n value = value[key];\n } else {\n return undefined;\n }\n }\n\n return value;\n }\n\n public get entryFile(): string {\n // `./index.ts` -> `index.ts`\n return path.posix.normalize(this.$get('lib.entryFile'));\n }\n\n public get cssUrl(): CssUrl {\n return this.$get('lib.cssUrl');\n }\n\n public get flatModuleFile(): string {\n return this.$get('lib.flatModuleFile') || this.flattenModuleId('-');\n }\n\n public get styleIncludePaths(): string[] {\n const includePaths = this.$get('lib.styleIncludePaths') || [];\n\n return includePaths.map(includePath =>\n path.isAbsolute(includePath) ? includePath : path.resolve(this.basePath, includePath),\n );\n }\n\n /**\n * The module ID is an \"identifier of a module used in the import statements, e.g.\n * '@angular/core'. The ID often maps directly to a path on the filesystem, but this\n * is not always the case due to various module resolution strategies.\"\n */\n public get moduleId(): string {\n if (this.secondaryData) {\n return this.secondaryData.moduleId;\n } else {\n return this.packageJson['name'];\n }\n }\n\n private flattenModuleId(separator = '.') {\n if (this.moduleId.startsWith('@')) {\n return this.moduleId.substring(1).split('/').join(separator);\n } else {\n return this.moduleId.split('/').join(separator);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,2CAAkD;AAoBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IACvB;IACE,+DAA+D;IAC/C,WAAgC;IAChD,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,iGAAiG;IAChF,aAAsC;QANvC,gBAAW,GAAX,WAAW,CAAqB;QAEhC,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GA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AAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CACtF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,IAAW,QAAQ;QACjB,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;SACpC;aAAM;YACL,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACjC;IACH,CAAC;IAEO,eAAe,CAAC,SAAS,GAAG,GAAG;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9D;aAAM;YACL,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACjD;IACH,CAAC;CACF;AA7GD,oCA6GC","sourcesContent":["import * as path from 'path';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../../utils/path';\n\n/** A list of output absolute paths for various formats */\nexport interface DestinationFiles {\n /** Absolute path of this entry point `declarations` */\n declarations: string;\n /** Absolute path of this entry point `FESM2020` module */\n fesm2020: string;\n /** Absolute path of this entry point `FESM2015` module */\n fesm2015: string;\n /** Absolute path of this entry point `ESM2020` module */\n esm2020: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n /** Absolute path of this entry point `FESM2020` directory */\n fesm2020Dir: string;\n /** Absolute path of this entry point `FESM2015` directory */\n fesm2015Dir: string;\n}\n\n/**\n * An entry point - quoting Angular Package Format - is:\n *\n * > a module intended to be imported by the user. It is referenced by a unique module ID and\n * > exports the public API referenced by that module ID. An example is `@angular/core` or\n * > `@angular/core/testing`. Both entry points exist in the `@angular/core` package, but they\n * > export different symbols. A package can have many entry points.\n *\n * #### Public API, source file tree and build output\n *\n * An entry point serves as the root of a source tree.\n * The entry point's public API references one TypeScript source file (`*.ts`).\n * That source file, e.g. `public_api.ts`, references other source files who in turn may reference\n * other source files, thus creating a tree of source code files.\n * The source files may be TypeScript (`*.ts`), Templates (`.html`) or Stylesheets\n * (`.css`, `.scss`, ..), or other formats.\n *\n * The compilation process for an entry point is a series of transformations applied to the source\n * files, e.g. TypeScript compilation, Inlining of Stylesheets and Templates, and so on.\n * As a result of the compilation process, an entry point is transpiled to a set of artefacts\n * (the build output) which include a FESM'15 Bundle, a FESM'5 Bundle, AoT metadata, TypeScript\n * type definitions, and so on.\n *\n * #### Representation in the domain\n *\n * The set of artefacts is reflected by `NgArtefacts`;\n * one `NgEntryPoint` relates to one `NgArtefacts`.\n * The parent package of an entry point is reflected by `NgPackage`.\n */\nexport class NgEntryPoint {\n constructor(\n /** Values from the `package.json` file of this entry point. */\n public readonly packageJson: Record<string, any>,\n /** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */\n public readonly ngPackageJson: NgPackageConfig,\n /** Absolute directory path of this entry point's `package.json` location. */\n public readonly basePath: string,\n /** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */\n private readonly secondaryData?: { [key: string]: any },\n ) {}\n\n /** Absolute file path of the entry point's source code entry file. */\n public get entryFilePath(): string {\n return path.resolve(this.basePath, this.entryFile);\n }\n\n /** Whether or not the entrypoint is secondary */\n public get isSecondaryEntryPoint(): boolean {\n return !!this.secondaryData;\n }\n\n /** Absolute directory path of this entry point's 'package.json'. */\n public get destinationPath(): string {\n if (this.secondaryData) {\n return this.secondaryData.destinationPath;\n } else {\n return path.resolve(this.basePath, this.$get('dest'));\n }\n }\n\n public get destinationFiles(): DestinationFiles {\n let primaryDestPath = this.destinationPath;\n let secondaryDir = '';\n\n if (this.secondaryData) {\n primaryDestPath = this.secondaryData.primaryDestinationPath;\n secondaryDir = path.relative(primaryDestPath, this.secondaryData.destinationPath);\n }\n\n const flatModuleFile = this.flatModuleFile;\n const pathJoinWithDest = (...paths: string[]) => path.join(primaryDestPath, ...paths);\n\n return {\n directory: ensureUnixPath(secondaryDir),\n declarations: pathJoinWithDest(secondaryDir, 'index.d.ts'),\n esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),\n fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),\n fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.mjs`),\n fesm2020Dir: pathJoinWithDest('fesm2020'),\n fesm2015Dir: pathJoinWithDest('fesm2015'),\n };\n }\n\n public $get(key: string): any {\n const parts = key.split('.');\n let value = this.ngPackageJson as unknown;\n for (const key of parts) {\n if (typeof value === 'object' && key in value) {\n value = value[key];\n } else {\n return undefined;\n }\n }\n\n return value;\n }\n\n public get entryFile(): string {\n // `./index.ts` -> `index.ts`\n return path.posix.normalize(this.$get('lib.entryFile'));\n }\n\n public get cssUrl(): CssUrl {\n return this.$get('lib.cssUrl');\n }\n\n public get flatModuleFile(): string {\n return this.$get('lib.flatModuleFile') || this.flattenModuleId('-');\n }\n\n public get styleIncludePaths(): string[] {\n const includePaths = this.$get('lib.styleIncludePaths') || [];\n\n return includePaths.map(includePath =>\n path.isAbsolute(includePath) ? includePath : path.resolve(this.basePath, includePath),\n );\n }\n\n /**\n * The module ID is an \"identifier of a module used in the import statements, e.g.\n * '@angular/core'. The ID often maps directly to a path on the filesystem, but this\n * is not always the case due to various module resolution strategies.\"\n */\n public get moduleId(): string {\n if (this.secondaryData) {\n return this.secondaryData.moduleId;\n } else {\n return this.packageJson['name'];\n }\n }\n\n private flattenModuleId(separator = '.') {\n if (this.moduleId.startsWith('@')) {\n return this.moduleId.substring(1).split('/').join(separator);\n } else {\n return this.moduleId.split('/').join(separator);\n }\n }\n}\n"]}
@@ -15,29 +15,26 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
15
15
  const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
16
16
  const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;
17
17
  const cache = entryPoint.cache;
18
- const { fesm2020, fesm2015, esm2020 } = destinationFiles;
18
+ const { fesm2020Dir, fesm2015Dir, esm2020 } = destinationFiles;
19
19
  const spinner = (0, ora_1.default)({
20
20
  hideCursor: false,
21
21
  discardStdin: false,
22
22
  });
23
- const key = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, esm2020, 'fesm-bundles', tsConfig.options.compilationMode);
24
- const hash = await (0, cache_1.generateKey)(...[...cache.outputCache.values()].map(({ version }) => version));
23
+ const key = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, esm2020, fesm2020Dir, fesm2015Dir, tsConfig.options.compilationMode);
24
+ const hash = await (0, cache_1.generateKey)([...cache.outputCache.values()].map(({ version }) => version).join(':'));
25
25
  const cacheDirectory = options.cacheEnabled && options.cacheDirectory;
26
26
  if (cacheDirectory) {
27
27
  const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory, key);
28
28
  if ((cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.hash) === hash) {
29
29
  try {
30
30
  spinner.start('Writing FESM bundles');
31
- await Promise.all([
32
- (0, fs_1.mkdir)((0, path_1.dirname)(fesm2020), { recursive: true }),
33
- (0, fs_1.mkdir)((0, path_1.dirname)(fesm2015), { recursive: true }),
34
- ]);
35
- await Promise.all([
36
- (0, fs_1.writeFile)(fesm2020, cacheResult.fesm2020.code),
37
- (0, fs_1.writeFile)(`${fesm2020}.map`, JSON.stringify(cacheResult.fesm2020.map)),
38
- (0, fs_1.writeFile)(fesm2015, cacheResult.fesm2015.code),
39
- (0, fs_1.writeFile)(`${fesm2015}.map`, JSON.stringify(cacheResult.fesm2015.map)),
40
- ]);
31
+ await Promise.all([(0, fs_1.mkdir)(fesm2020Dir, { recursive: true }), (0, fs_1.mkdir)(fesm2015Dir, { recursive: true })]);
32
+ for (const file of cacheResult.fesm2020) {
33
+ await (0, fs_1.writeFile)((0, path_1.join)(fesm2020Dir, file.fileName), file.type === 'asset' ? file.source : file.code);
34
+ }
35
+ for (const file of cacheResult.fesm2015) {
36
+ await (0, fs_1.writeFile)((0, path_1.join)(fesm2015Dir, file.fileName), file.type === 'asset' ? file.source : file.code);
37
+ }
41
38
  spinner.succeed('Writing FESM bundles');
42
39
  }
43
40
  catch (error) {
@@ -47,29 +44,39 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
47
44
  return;
48
45
  }
49
46
  }
50
- const fesmCache = {
51
- hash,
52
- };
53
- try {
54
- spinner.start('Generating FESM2020');
55
- const { cache: rollupFESMCache, code, map, } = await (0, rollup_1.rollupBundleFile)({
47
+ async function generateFESM(rollupCache, dir, downlevel) {
48
+ const { cache: rollupFESMCache, files } = await (0, rollup_1.rollupBundleFile)({
56
49
  sourceRoot: tsConfig.options.sourceRoot,
57
50
  entry: esm2020,
51
+ entryName: ngEntryPoint.flatModuleFile,
58
52
  moduleName: ngEntryPoint.moduleId,
59
- dest: fesm2020,
60
- cache: cache.rollupFESM2020Cache,
53
+ dir,
54
+ downlevel,
55
+ cache: rollupCache,
61
56
  cacheDirectory,
62
57
  fileCache: cache.outputCache,
63
- cacheKey: await (0, cache_1.generateKey)(esm2020, ngEntryPoint.moduleId, fesm2020, tsConfig.options.compilationMode),
58
+ cacheKey: await (0, cache_1.generateKey)(esm2020, dir, ngEntryPoint.moduleId, tsConfig.options.compilationMode),
64
59
  });
65
- fesmCache.fesm2020 = {
66
- code,
67
- map,
60
+ return {
61
+ /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
62
+ files: files.map(f => {
63
+ if (f.type === 'chunk') {
64
+ f.map = null;
65
+ }
66
+ return f;
67
+ }),
68
+ rollupCache: options.watch ? rollupFESMCache : undefined,
68
69
  };
70
+ }
71
+ const fesmCache = {
72
+ hash,
73
+ };
74
+ try {
75
+ spinner.start('Generating FESM2020');
76
+ const { rollupCache, files } = await generateFESM(cache.rollupFESM2020Cache, fesm2020Dir, false);
77
+ cache.rollupFESM2020Cache = rollupCache;
78
+ fesmCache.fesm2020 = files;
69
79
  spinner.succeed();
70
- if (options.watch) {
71
- cache.rollupFESM2020Cache = rollupFESMCache;
72
- }
73
80
  }
74
81
  catch (error) {
75
82
  spinner.fail();
@@ -77,25 +84,10 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
77
84
  }
78
85
  try {
79
86
  spinner.start('Generating FESM2015');
80
- const { cache: rollupFESMCache, code, map, } = await (0, rollup_1.rollupBundleFile)({
81
- sourceRoot: tsConfig.options.sourceRoot,
82
- entry: esm2020,
83
- moduleName: ngEntryPoint.moduleId,
84
- dest: fesm2015,
85
- downlevel: true,
86
- cache: cache.rollupFESM2015Cache,
87
- cacheDirectory,
88
- fileCache: cache.outputCache,
89
- cacheKey: await (0, cache_1.generateKey)(esm2020, ngEntryPoint.moduleId, fesm2015, tsConfig.options.compilationMode),
90
- });
91
- fesmCache.fesm2015 = {
92
- code,
93
- map,
94
- };
87
+ const { rollupCache, files } = await generateFESM(cache.rollupFESM2015Cache, fesm2015Dir, true);
88
+ cache.rollupFESM2015Cache = rollupCache;
89
+ fesmCache.fesm2015 = files;
95
90
  spinner.succeed();
96
- if (options.watch) {
97
- cache.rollupFESM2015Cache = rollupFESMCache;
98
- }
99
91
  }
100
92
  catch (error) {
101
93
  spinner.fail();
@@ -1 +1 @@
1
- {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA+B;AAE/B,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAAkD;AAClD,oCAAkE;AAe3D,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8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,SAAS,CAAC,CAAC,CAAC;KACtE;AACH,CAAC,CAAC,CAAC;AAnHQ,QAAA,qBAAqB,yBAmH7B","sourcesContent":["import ora from 'ora';\nimport { dirname } from 'path';\nimport { SourceMap } from 'rollup';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { mkdir, writeFile } from '../../utils/fs';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2020: {\n code: string;\n map: SourceMap;\n };\n fesm2015: {\n code: string;\n map: SourceMap;\n };\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2020, fesm2015, esm2020 } = destinationFiles;\n\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const key = await generateKey(ngEntryPoint.moduleId, esm2020, 'fesm-bundles', tsConfig.options.compilationMode);\n const hash = await generateKey(...[...cache.outputCache.values()].map(({ version }) => version));\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, key);\n\n if (cacheResult?.hash === hash) {\n try {\n spinner.start('Writing FESM bundles');\n await Promise.all([\n mkdir(dirname(fesm2020), { recursive: true }),\n mkdir(dirname(fesm2015), { recursive: true }),\n ]);\n\n await Promise.all([\n writeFile(fesm2020, cacheResult.fesm2020.code),\n writeFile(`${fesm2020}.map`, JSON.stringify(cacheResult.fesm2020.map)),\n writeFile(fesm2015, cacheResult.fesm2015.code),\n writeFile(`${fesm2015}.map`, JSON.stringify(cacheResult.fesm2015.map)),\n ]);\n\n spinner.succeed('Writing FESM bundles');\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n return;\n }\n }\n\n const fesmCache: Partial<BundlesCache> = {\n hash,\n };\n\n try {\n spinner.start('Generating FESM2020');\n const {\n cache: rollupFESMCache,\n code,\n map,\n } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n moduleName: ngEntryPoint.moduleId,\n dest: fesm2020,\n cache: cache.rollupFESM2020Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, ngEntryPoint.moduleId, fesm2020, tsConfig.options.compilationMode),\n });\n\n fesmCache.fesm2020 = {\n code,\n map,\n };\n\n spinner.succeed();\n\n if (options.watch) {\n cache.rollupFESM2020Cache = rollupFESMCache;\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n try {\n spinner.start('Generating FESM2015');\n const {\n cache: rollupFESMCache,\n code,\n map,\n } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n moduleName: ngEntryPoint.moduleId,\n dest: fesm2015,\n downlevel: true,\n cache: cache.rollupFESM2015Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, ngEntryPoint.moduleId, fesm2015, tsConfig.options.compilationMode),\n });\n\n fesmCache.fesm2015 = {\n code,\n map,\n };\n\n spinner.succeed();\n\n if (options.watch) {\n cache.rollupFESM2015Cache = rollupFESMCache;\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, key, JSON.stringify(fesmCache));\n }\n });\n"]}
1
+ {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA4B;AAE5B,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAAkD;AAClD,oCAAkE;AAS3D,MAAM,qBAAqB,GAAG,CAAC,OAAyB,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CAAC,OAAO,EAAE,CAAC;KACnB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;KACb;IAED,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;KACtE;AACH,CAAC,CAAC,CAAC;AA/GQ,QAAA,qBAAqB,yBA+G7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport { OutputAsset, OutputChunk, RollupCache } from 'rollup';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { mkdir, writeFile } from '../../utils/fs';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2020: (OutputChunk | OutputAsset)[];\n fesm2015: (OutputChunk | OutputAsset)[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2020Dir, fesm2015Dir, esm2020 } = destinationFiles;\n\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const key = await generateKey(\n ngEntryPoint.moduleId,\n esm2020,\n fesm2020Dir,\n fesm2015Dir,\n tsConfig.options.compilationMode,\n );\n const hash = await generateKey([...cache.outputCache.values()].map(({ version }) => version).join(':'));\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, key);\n\n if (cacheResult?.hash === hash) {\n try {\n spinner.start('Writing FESM bundles');\n await Promise.all([mkdir(fesm2020Dir, { recursive: true }), mkdir(fesm2015Dir, { recursive: true })]);\n\n for (const file of cacheResult.fesm2020) {\n await writeFile(join(fesm2020Dir, file.fileName), file.type === 'asset' ? file.source : file.code);\n }\n\n for (const file of cacheResult.fesm2015) {\n await writeFile(join(fesm2015Dir, file.fileName), file.type === 'asset' ? file.source : file.code);\n }\n\n spinner.succeed('Writing FESM bundles');\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n return;\n }\n }\n\n async function generateFESM(\n rollupCache: RollupCache,\n dir: string,\n downlevel: boolean,\n ): Promise<{ files: (OutputChunk | OutputAsset)[]; rollupCache: RollupCache }> {\n const { cache: rollupFESMCache, files } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir,\n downlevel,\n cache: rollupCache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, dir, ngEntryPoint.moduleId, tsConfig.options.compilationMode),\n });\n\n return {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n files: files.map(f => {\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n rollupCache: options.watch ? rollupFESMCache : undefined,\n };\n }\n\n const fesmCache: Partial<BundlesCache> = {\n hash,\n };\n\n try {\n spinner.start('Generating FESM2020');\n const { rollupCache, files } = await generateFESM(cache.rollupFESM2020Cache, fesm2020Dir, false);\n\n cache.rollupFESM2020Cache = rollupCache;\n fesmCache.fesm2020 = files;\n\n spinner.succeed();\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n try {\n spinner.start('Generating FESM2015');\n const { rollupCache, files } = await generateFESM(cache.rollupFESM2015Cache, fesm2015Dir, true);\n\n cache.rollupFESM2015Cache = rollupCache;\n fesmCache.fesm2015 = files;\n\n spinner.succeed();\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, key, JSON.stringify(fesmCache));\n }\n });\n"]}
@@ -10,7 +10,7 @@ import { NgccProcessingCache } from './ngcc-cache';
10
10
  import { NgPackage } from './package';
11
11
  export declare const TYPE_NG_PACKAGE = "application/ng-package";
12
12
  export declare const TYPE_NG_ENTRY_POINT = "application/ng-entry-point";
13
- export declare type GlobCache = Record<string, boolean | 'DIR' | 'FILE' | string[]>;
13
+ export type GlobCache = Record<string, boolean | 'DIR' | 'FILE' | string[]>;
14
14
  /** A node that can be read through the `fs` api. */
15
15
  export declare const URL_PROTOCOL_FILE = "file://";
16
16
  /** A node specific to angular. */
@@ -24,7 +24,7 @@ export declare function isFileUrl(value: string): boolean;
24
24
  export declare function fileUrl(path: string): string;
25
25
  export declare function fileUrlPath(url: string): string;
26
26
  export declare function ngUrl(path: string): string;
27
- export declare type OutputFileCache = Map<string, {
27
+ export type OutputFileCache = Map<string, {
28
28
  version: string;
29
29
  content: string;
30
30
  map?: any;
@@ -52,37 +52,25 @@ const nodes_1 = require("./nodes");
52
52
  * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.
53
53
  */
54
54
  const packageTransformFactory = (project, options, initTsConfigTransform, analyseSourcesTransform, entryPointTransform) => (source$) => {
55
- const pkgUri = (0, nodes_1.ngUrl)(project);
55
+ log.info(`Building Angular Package`);
56
56
  const buildTransform = options.watch
57
57
  ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)
58
58
  : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);
59
- return source$.pipe((0, operators_1.tap)(() => log.info(`Building Angular Package`)),
59
+ const pkgUri = (0, nodes_1.ngUrl)(project);
60
+ const ngPkg = new nodes_1.PackageNode(pkgUri);
61
+ return source$.pipe(
60
62
  // Discover packages and entry points
61
- (0, operators_1.switchMap)(graph => {
62
- const pkg = (0, discover_packages_1.discoverPackages)({ project });
63
- return (0, rxjs_1.from)(pkg).pipe((0, operators_1.map)(value => {
64
- const ngPkg = new nodes_1.PackageNode(pkgUri);
65
- ngPkg.data = value;
66
- return graph.put(ngPkg);
67
- }));
68
- }),
69
63
  // Clean the primary dest folder (should clean all secondary sub-directory, as well)
70
64
  (0, operators_1.switchMap)(async (graph) => {
71
- const { dest, deleteDestPath } = graph.get(pkgUri).data;
65
+ ngPkg.data = await (0, discover_packages_1.discoverPackages)({ project });
66
+ graph.put(ngPkg);
67
+ const { dest, deleteDestPath } = ngPkg.data;
72
68
  if (deleteDestPath) {
73
69
  try {
74
70
  await (0, fs_1.rmdir)(dest, { recursive: true });
75
71
  }
76
72
  catch { }
77
73
  }
78
- }, (graph, _) => graph),
79
- // Add entry points to graph
80
- (0, operators_1.map)(graph => {
81
- const foundNode = graph.get(pkgUri);
82
- if (!(0, nodes_1.isPackage)(foundNode)) {
83
- return graph;
84
- }
85
- const ngPkg = foundNode;
86
74
  const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {
87
75
  const { destinationFiles, moduleId } = entryPoint;
88
76
  const node = new nodes_1.EntryPointNode((0, nodes_1.ngUrl)(moduleId), ngPkg.cache.sourcesFileCache, ngPkg.cache.ngccProcessingCache, ngPkg.cache.moduleResolutionCache);
@@ -91,12 +79,20 @@ const packageTransformFactory = (project, options, initTsConfigTransform, analys
91
79
  ngPkg.dependsOn(node);
92
80
  return node;
93
81
  });
82
+ // Add entry points to graph
94
83
  return graph.put(entryPoints);
95
84
  }),
96
85
  // Initialize the tsconfig for each entry point
97
86
  initTsConfigTransform,
98
87
  // perform build
99
- buildTransform);
88
+ buildTransform, (0, rxjs_1.finalize)(() => {
89
+ var _a;
90
+ for (const node of ngPkg.dependents) {
91
+ if (node instanceof nodes_1.EntryPointNode) {
92
+ (_a = node.cache.stylesheetProcessor) === null || _a === void 0 ? void 0 : _a.destroy();
93
+ }
94
+ }
95
+ }));
100
96
  };
101
97
  exports.packageTransformFactory = packageTransformFactory;
102
98
  const watchTransformFactory = (project, _options, analyseSourcesTransform, entryPointTransform) => (source$) => {
@@ -145,7 +141,7 @@ const watchTransformFactory = (project, _options, analyseSourcesTransform, entry
145
141
  if (event === 'unlink' || event === 'add') {
146
142
  cache.globCache = regenerateGlobCache(sourcesFileCache);
147
143
  }
148
- }), (0, operators_1.debounceTime)(200), (0, operators_1.tap)(() => log.msg(FileChangeDetected)), (0, operators_1.startWith)(undefined), (0, operators_1.mapTo)(graph));
144
+ }), (0, operators_1.debounceTime)(200), (0, operators_1.tap)(() => log.msg(FileChangeDetected)), (0, operators_1.startWith)(undefined), (0, operators_1.map)(() => graph));
149
145
  }), (0, operators_1.switchMap)(graph => {
150
146
  return (0, rxjs_1.of)(graph).pipe(buildTransformFactory(project, analyseSourcesTransform, entryPointTransform), (0, operators_1.tap)(() => log.msg(CompleteWaitingForFileChange)), (0, operators_1.catchError)(error => {
151
147
  log.error(error);
@@ -192,7 +188,7 @@ const scheduleEntryPoints = (epTransform) => (0, rxjs_1.pipe)((0, operators_1.co
192
188
  // Build entry points with lower depth values first.
193
189
  return (0, rxjs_1.from)(groups).pipe((0, operators_1.map)((epUrl) => graph.find((0, nodes_1.byEntryPoint)().and(ep => ep.url === epUrl))), (0, operators_1.filter)((entryPoint) => entryPoint.state !== 'done'), (0, operators_1.concatMap)(ep => (0, rxjs_1.of)(ep).pipe(
194
190
  // Mark the entry point as 'in-progress'
195
- (0, operators_1.tap)(entryPoint => (entryPoint.state = node_1.STATE_IN_PROGRESS)), (0, operators_1.mapTo)(graph), epTransform)), (0, operators_1.takeLast)(1), // don't use last as sometimes it this will cause 'no elements in sequence',
191
+ (0, operators_1.tap)(entryPoint => (entryPoint.state = node_1.STATE_IN_PROGRESS)), (0, operators_1.map)(() => graph), epTransform)), (0, operators_1.takeLast)(1), // don't use last as sometimes it this will cause 'no elements in sequence',
196
192
  (0, operators_1.defaultIfEmpty)(graph));
197
193
  }));
198
194
  function regenerateGlobCache(sourcesFileCache) {