ng-packagr 21.1.0-next.0 → 21.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.
Files changed (72) hide show
  1. package/package.json +3 -3
  2. package/src/lib/file-system/file-cache.js +3 -5
  3. package/src/lib/file-system/file-cache.js.map +1 -1
  4. package/src/lib/file-system/file-watcher.js +1 -2
  5. package/src/lib/file-system/file-watcher.js.map +1 -1
  6. package/src/lib/flatten/file-loader-plugin.js +1 -2
  7. package/src/lib/flatten/file-loader-plugin.js.map +1 -1
  8. package/src/lib/flatten/rollup.js +6 -5
  9. package/src/lib/flatten/rollup.js.map +1 -1
  10. package/src/lib/graph/build-graph.js +2 -3
  11. package/src/lib/graph/build-graph.js.map +1 -1
  12. package/src/lib/graph/node.js +6 -3
  13. package/src/lib/graph/node.js.map +1 -1
  14. package/src/lib/ng-package/discover-packages.js +1 -2
  15. package/src/lib/ng-package/discover-packages.js.map +1 -1
  16. package/src/lib/ng-package/entry-point/compile-ngc.transform.js +2 -4
  17. package/src/lib/ng-package/entry-point/compile-ngc.transform.js.map +1 -1
  18. package/src/lib/ng-package/entry-point/entry-point.js +4 -0
  19. package/src/lib/ng-package/entry-point/entry-point.js.map +1 -1
  20. package/src/lib/ng-package/entry-point/write-bundles.transform.js +3 -4
  21. package/src/lib/ng-package/entry-point/write-bundles.transform.js.map +1 -1
  22. package/src/lib/ng-package/entry-point/write-package.transform.js +5 -9
  23. package/src/lib/ng-package/entry-point/write-package.transform.js.map +1 -1
  24. package/src/lib/ng-package/nodes.js +9 -11
  25. package/src/lib/ng-package/nodes.js.map +1 -1
  26. package/src/lib/ng-package/options.di.js +1 -1
  27. package/src/lib/ng-package/options.di.js.map +1 -1
  28. package/src/lib/ng-package/package.js +3 -0
  29. package/src/lib/ng-package/package.js.map +1 -1
  30. package/src/lib/ng-package/package.transform.js +1 -2
  31. package/src/lib/ng-package/package.transform.js.map +1 -1
  32. package/src/lib/ng-package/schema.js +2 -2
  33. package/src/lib/ng-package/schema.js.map +1 -1
  34. package/src/lib/ngc/angular-diagnostics-cache.js +3 -13
  35. package/src/lib/ngc/angular-diagnostics-cache.js.map +1 -1
  36. package/src/lib/ngc/compile-source-files.js +2 -3
  37. package/src/lib/ngc/compile-source-files.js.map +1 -1
  38. package/src/lib/packagr.js +2 -1
  39. package/src/lib/packagr.js.map +1 -1
  40. package/src/lib/styles/bundler-context.js +117 -131
  41. package/src/lib/styles/bundler-context.js.map +1 -1
  42. package/src/lib/styles/cache.js +2 -0
  43. package/src/lib/styles/cache.js.map +1 -1
  44. package/src/lib/styles/component-stylesheets.js +16 -21
  45. package/src/lib/styles/component-stylesheets.js.map +1 -1
  46. package/src/lib/styles/load-result-cache.js +11 -21
  47. package/src/lib/styles/load-result-cache.js.map +1 -1
  48. package/src/lib/styles/sass/lexer.js +1 -2
  49. package/src/lib/styles/sass/lexer.js.map +1 -1
  50. package/src/lib/styles/sass/rebasing-importer.js +7 -4
  51. package/src/lib/styles/sass/rebasing-importer.js.map +1 -1
  52. package/src/lib/styles/sass/sass-service.js +49 -63
  53. package/src/lib/styles/sass/sass-service.js.map +1 -1
  54. package/src/lib/styles/sass/worker.js +5 -7
  55. package/src/lib/styles/sass/worker.js.map +1 -1
  56. package/src/lib/styles/stylesheet-processor.js +7 -0
  57. package/src/lib/styles/stylesheet-processor.js.map +1 -1
  58. package/src/lib/styles/stylesheets/bundle-options.js +1 -2
  59. package/src/lib/styles/stylesheets/bundle-options.js.map +1 -1
  60. package/src/lib/styles/stylesheets/css-resource-plugin.js +2 -4
  61. package/src/lib/styles/stylesheets/css-resource-plugin.js.map +1 -1
  62. package/src/lib/styles/stylesheets/less-language.js +1 -1
  63. package/src/lib/styles/stylesheets/less-language.js.map +1 -1
  64. package/src/lib/styles/stylesheets/sass-language.d.ts +1 -1
  65. package/src/lib/styles/stylesheets/sass-language.js +6 -18
  66. package/src/lib/styles/stylesheets/sass-language.js.map +1 -1
  67. package/src/lib/styles/stylesheets/stylesheet-plugin-factory.js +21 -24
  68. package/src/lib/styles/stylesheets/stylesheet-plugin-factory.js.map +1 -1
  69. package/src/lib/styles/worker-pool.js +1 -1
  70. package/src/lib/styles/worker-pool.js.map +1 -1
  71. package/src/lib/ts/cache-compiler-host.js +7 -8
  72. package/src/lib/ts/cache-compiler-host.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "21.1.0-next.0",
3
+ "version": "21.1.0",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -38,7 +38,7 @@
38
38
  "ajv": "^8.17.1",
39
39
  "ansi-colors": "^4.1.3",
40
40
  "browserslist": "^4.26.0",
41
- "chokidar": "^4.0.1",
41
+ "chokidar": "^5.0.0",
42
42
  "commander": "^14.0.0",
43
43
  "dependency-graph": "^1.0.0",
44
44
  "esbuild": "^0.27.0",
@@ -58,7 +58,7 @@
58
58
  "rollup": "^4.24.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@angular/compiler-cli": "^21.1.0-next || ^21.0.0",
61
+ "@angular/compiler-cli": "^21.0.0 || ^21.1.0-next",
62
62
  "tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
63
63
  "tslib": "^2.3.0",
64
64
  "typescript": ">=5.9 <6.0"
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileCache = void 0;
4
4
  const path_1 = require("../utils/path");
5
5
  class FileCache {
6
- constructor() {
7
- this.cache = new Map();
8
- this.forEach = this.cache.forEach.bind(this.cache);
9
- this.clear = this.cache.clear.bind(this.cache);
10
- }
6
+ cache = new Map();
7
+ forEach = this.cache.forEach.bind(this.cache);
8
+ clear = this.cache.clear.bind(this.cache);
11
9
  size() {
12
10
  return this.cache.size;
13
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file-cache.js","sourceRoot":"","sources":["../../../../src/lib/file-system/file-cache.ts"],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8BAsCC","sourcesContent":["import ts from 'typescript';\nimport { ensureUnixPath } from '../utils/path';\n\nexport interface CacheEntry {\n exists?: boolean;\n sourceFile?: ts.SourceFile;\n content?: string;\n}\n\nexport class FileCache {\n private cache: Map<string, CacheEntry> = new Map();\n\n forEach: (callbackfn: (value: CacheEntry, key: string, map: Map<string, CacheEntry>) => void, thisArg?: any) => void =\n this.cache.forEach.bind(this.cache);\n clear: () => void = this.cache.clear.bind(this.cache);\n\n size(): number {\n return this.cache.size;\n }\n\n normalizeKey(fileName: string): string {\n return ensureUnixPath(fileName);\n }\n\n delete(fileName: string): boolean {\n return this.cache.delete(this.normalizeKey(fileName));\n }\n\n has(fileName: string): boolean {\n return this.cache.has(this.normalizeKey(fileName));\n }\n\n get(fileName: string): CacheEntry | undefined {\n return this.cache.get(this.normalizeKey(fileName));\n }\n\n getOrCreate(fileName: string): CacheEntry {\n const normalizedKey = this.normalizeKey(fileName);\n let entry = this.cache.get(normalizedKey);\n\n if (!entry) {\n entry = {};\n this.cache.set(normalizedKey, entry);\n }\n\n return entry;\n }\n}\n"]}
1
+ {"version":3,"file":"file-cache.js","sourceRoot":"","sources":["../../../../src/lib/file-system/file-cache.ts"],"names":[],"mappings":";;;AACA,wCAA+C;AAQ/C,MAAa,SAAS;IACZ,KAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;IAEnD,OAAO,GACL,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,KAAK,GAAe,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEtD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,YAAY,CAAC,QAAgB;QAC3B,OAAO,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,QAAgB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,WAAW,CAAC,QAAgB;QAC1B,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAE1C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtCD,8BAsCC","sourcesContent":["import ts from 'typescript';\nimport { ensureUnixPath } from '../utils/path';\n\nexport interface CacheEntry {\n exists?: boolean;\n sourceFile?: ts.SourceFile;\n content?: string;\n}\n\nexport class FileCache {\n private cache: Map<string, CacheEntry> = new Map();\n\n forEach: (callbackfn: (value: CacheEntry, key: string, map: Map<string, CacheEntry>) => void, thisArg?: any) => void =\n this.cache.forEach.bind(this.cache);\n clear: () => void = this.cache.clear.bind(this.cache);\n\n size(): number {\n return this.cache.size;\n }\n\n normalizeKey(fileName: string): string {\n return ensureUnixPath(fileName);\n }\n\n delete(fileName: string): boolean {\n return this.cache.delete(this.normalizeKey(fileName));\n }\n\n has(fileName: string): boolean {\n return this.cache.has(this.normalizeKey(fileName));\n }\n\n get(fileName: string): CacheEntry | undefined {\n return this.cache.get(this.normalizeKey(fileName));\n }\n\n getOrCreate(fileName: string): CacheEntry {\n const normalizedKey = this.normalizeKey(fileName);\n let entry = this.cache.get(normalizedKey);\n\n if (!entry) {\n entry = {};\n this.cache.set(normalizedKey, entry);\n }\n\n return entry;\n }\n}\n"]}
@@ -92,7 +92,6 @@ function createFileWatch(basePaths, ignoredPaths = [], poll) {
92
92
  * @returns - Returns `true` if any entry point was invalidated, otherwise `false`.
93
93
  */
94
94
  function invalidateEntryPointsAndCacheOnFileChange(graph, files, sourcesFileCache) {
95
- var _a, _b;
96
95
  let invalidatedEntryPoint = false;
97
96
  const allNodesToClean = new Map();
98
97
  for (const filePath of files) {
@@ -128,7 +127,7 @@ function invalidateEntryPointsAndCacheOnFileChange(graph, files, sourcesFileCach
128
127
  for (const entryPoint of entryPoints) {
129
128
  let isDirty = false;
130
129
  if (potentialStylesResources.size > 0) {
131
- isDirty = !!((_b = (_a = entryPoint.cache.stylesheetProcessor) === null || _a === void 0 ? void 0 : _a.invalidate(potentialStylesResources)) === null || _b === void 0 ? void 0 : _b.length);
130
+ isDirty = !!entryPoint.cache.stylesheetProcessor?.invalidate(potentialStylesResources)?.length;
132
131
  }
133
132
  for (const [filePath, dependent] of allNodesToClean) {
134
133
  if (!entryPoint.dependents.has(dependent)) {
@@ -1 +1 @@
1
- {"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0CAyDC;AAOD,8FAmEC;AAtJD,mDAAqC;AACrC,2BAA8B;AAC9B,2CAA6B;AAC7B,+BAA4C;AAE5C,wCAAoD;AACpD,+CAAyE;AACzE,kDAAoC;AACpC,wCAA+C;AAW/C,SAAgB,eAAe,CAC7B,SAA4B,EAC5B,eAAyB,EAAE,EAC3B,IAAa;IAKb,GAAG,CAAC,KAAK,CAAC,mCAAmC,SAAS,mBAAmB,YAAY,EAAE,CAAC,CAAC;IAEzF,MAAM,KAA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okidar';\nimport { platform } from 'os';\nimport * as path from 'path';\nimport { Observable, Observer } from 'rxjs';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node, STATE_PENDING } from '../graph/node';\nimport { fileUrl, fileUrlPath, isEntryPoint } from '../ng-package/nodes';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { FileCache } from './file-cache';\n\ntype AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';\nexport type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;\n\nexport interface FileChangedEvent {\n filePath: string;\n event: FileWatchEvent;\n}\n\nexport function createFileWatch(\n basePaths: string | string[],\n ignoredPaths: string[] = [],\n poll?: number,\n): {\n watcher: chokidar.FSWatcher;\n onFileChange: Observable<FileChangedEvent>;\n} {\n log.debug(`Watching for changes: basePath: ${basePaths}, ignoredPaths: ${ignoredPaths}`);\n\n const watch = chokidar.watch([], {\n ignoreInitial: true,\n ignored: [\n /\\.map$/,\n /.tsbuildinfo$/,\n file => {\n const normalizedPath = ensureUnixPath(file);\n\n return ignoredPaths.some(f => normalizedPath.startsWith(f));\n },\n ],\n persistent: true,\n usePolling: typeof poll === 'number' ? true : false,\n interval: typeof poll === 'number' ? poll : undefined,\n });\n\n const isLinux = platform() === 'linux';\n const handleFileChange = (event: AllFileWatchEvents, filePath: string, observer: Observer<FileChangedEvent>) => {\n log.debug(`Watch: Path changed. Event: ${event}, Path: ${filePath}`);\n\n if (isLinux) {\n // Workaround for Linux where chokidar will not handle future events\n // for files that were unlinked and immediately recreated.\n watch.unwatch(filePath);\n watch.add(filePath);\n }\n\n if (event === 'unlinkDir' || event === 'addDir') {\n // we don't need to trigger on directory removed or renamed as chokidar will fire the changes for each file\n return;\n }\n\n observer.next({\n filePath: ensureUnixPath(path.resolve(filePath)),\n event,\n });\n };\n\n return {\n watcher: watch,\n onFileChange: new Observable(observer => {\n watch.on('all', (event: AllFileWatchEvents, filePath: string) => handleFileChange(event, filePath, observer));\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return () => watch.close();\n }),\n };\n}\n\n/**\n * Invalidates entry points and cache when specified files change.\n *\n * @returns - Returns `true` if any entry point was invalidated, otherwise `false`.\n */\nexport function invalidateEntryPointsAndCacheOnFileChange(\n graph: BuildGraph,\n files: string[],\n sourcesFileCache: FileCache,\n): boolean {\n let invalidatedEntryPoint = false;\n const allNodesToClean: Map<string, Node> = new Map();\n\n for (const filePath of files) {\n const changedFileUrl = fileUrl(filePath);\n const nodeToClean = graph.find(node => changedFileUrl === node.url);\n if (!nodeToClean) {\n continue;\n }\n\n allNodesToClean.set(filePath, nodeToClean);\n }\n\n // delete node that changes\n const potentialStylesResources = new Set<string>();\n for (const [filePath, nodeToClean] of allNodesToClean) {\n sourcesFileCache.delete(filePath);\n\n if (filePath.endsWith('.ts')) {\n continue;\n }\n\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 potentialStylesResources.add(filePath);\n for (const dependees of nodeToClean.dependees) {\n const filePath = fileUrlPath(dependees.url);\n if (!filePath) {\n continue;\n }\n\n allNodesToClean.set(filePath, dependees);\n\n if (!filePath.endsWith('.ts')) {\n potentialStylesResources.add(filePath);\n }\n }\n }\n\n const entryPoints = graph.filter(isEntryPoint);\n for (const entryPoint of entryPoints) {\n let isDirty = false;\n if (potentialStylesResources.size > 0) {\n isDirty = !!entryPoint.cache.stylesheetProcessor?.invalidate(potentialStylesResources)?.length;\n }\n\n for (const [filePath, dependent] of allNodesToClean) {\n if (!entryPoint.dependents.has(dependent)) {\n continue;\n }\n\n entryPoint.cache.analysesSourcesFileCache.delete(filePath);\n isDirty = true;\n }\n\n if (isDirty) {\n entryPoint.state = STATE_PENDING;\n invalidatedEntryPoint = true;\n }\n }\n\n return invalidatedEntryPoint;\n}\n"]}
1
+ {"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;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AAC;YAED,UAAU,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3D,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,KAAK,GAAG,oBAAa,CAAC;YACjC,qBAAqB,GAAG,IAAI,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC","sourcesContent":["import * as chokidar from 'chokidar';\nimport { platform } from 'os';\nimport * as path from 'path';\nimport { Observable, Observer } from 'rxjs';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node, STATE_PENDING } from '../graph/node';\nimport { fileUrl, fileUrlPath, isEntryPoint } from '../ng-package/nodes';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { FileCache } from './file-cache';\n\ntype AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';\nexport type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;\n\nexport interface FileChangedEvent {\n filePath: string;\n event: FileWatchEvent;\n}\n\nexport function createFileWatch(\n basePaths: string | string[],\n ignoredPaths: string[] = [],\n poll?: number,\n): {\n watcher: chokidar.FSWatcher;\n onFileChange: Observable<FileChangedEvent>;\n} {\n log.debug(`Watching for changes: basePath: ${basePaths}, ignoredPaths: ${ignoredPaths}`);\n\n const watch = chokidar.watch([], {\n ignoreInitial: true,\n ignored: [\n /\\.map$/,\n /.tsbuildinfo$/,\n file => {\n const normalizedPath = ensureUnixPath(file);\n\n return ignoredPaths.some(f => normalizedPath.startsWith(f));\n },\n ],\n persistent: true,\n usePolling: typeof poll === 'number' ? true : false,\n interval: typeof poll === 'number' ? poll : undefined,\n });\n\n const isLinux = platform() === 'linux';\n const handleFileChange = (event: AllFileWatchEvents, filePath: string, observer: Observer<FileChangedEvent>) => {\n log.debug(`Watch: Path changed. Event: ${event}, Path: ${filePath}`);\n\n if (isLinux) {\n // Workaround for Linux where chokidar will not handle future events\n // for files that were unlinked and immediately recreated.\n watch.unwatch(filePath);\n watch.add(filePath);\n }\n\n if (event === 'unlinkDir' || event === 'addDir') {\n // we don't need to trigger on directory removed or renamed as chokidar will fire the changes for each file\n return;\n }\n\n observer.next({\n filePath: ensureUnixPath(path.resolve(filePath)),\n event,\n });\n };\n\n return {\n watcher: watch,\n onFileChange: new Observable(observer => {\n watch.on('all', (event: AllFileWatchEvents, filePath: string) => handleFileChange(event, filePath, observer));\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return () => watch.close();\n }),\n };\n}\n\n/**\n * Invalidates entry points and cache when specified files change.\n *\n * @returns - Returns `true` if any entry point was invalidated, otherwise `false`.\n */\nexport function invalidateEntryPointsAndCacheOnFileChange(\n graph: BuildGraph,\n files: string[],\n sourcesFileCache: FileCache,\n): boolean {\n let invalidatedEntryPoint = false;\n const allNodesToClean: Map<string, Node> = new Map();\n\n for (const filePath of files) {\n const changedFileUrl = fileUrl(filePath);\n const nodeToClean = graph.find(node => changedFileUrl === node.url);\n if (!nodeToClean) {\n continue;\n }\n\n allNodesToClean.set(filePath, nodeToClean);\n }\n\n // delete node that changes\n const potentialStylesResources = new Set<string>();\n for (const [filePath, nodeToClean] of allNodesToClean) {\n sourcesFileCache.delete(filePath);\n\n if (filePath.endsWith('.ts')) {\n continue;\n }\n\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 potentialStylesResources.add(filePath);\n for (const dependees of nodeToClean.dependees) {\n const filePath = fileUrlPath(dependees.url);\n if (!filePath) {\n continue;\n }\n\n allNodesToClean.set(filePath, dependees);\n\n if (!filePath.endsWith('.ts')) {\n potentialStylesResources.add(filePath);\n }\n }\n }\n\n const entryPoints = graph.filter(isEntryPoint);\n for (const entryPoint of entryPoints) {\n let isDirty = false;\n if (potentialStylesResources.size > 0) {\n isDirty = !!entryPoint.cache.stylesheetProcessor?.invalidate(potentialStylesResources)?.length;\n }\n\n for (const [filePath, dependent] of allNodesToClean) {\n if (!entryPoint.dependents.has(dependent)) {\n continue;\n }\n\n entryPoint.cache.analysesSourcesFileCache.delete(filePath);\n isDirty = true;\n }\n\n if (isDirty) {\n entryPoint.state = STATE_PENDING;\n invalidatedEntryPoint = true;\n }\n }\n\n return invalidatedEntryPoint;\n}\n"]}
@@ -62,7 +62,6 @@ function fileLoaderPlugin(fileCache, resolutionExtensions) {
62
62
  }
63
63
  },
64
64
  load: function (id) {
65
- var _a;
66
65
  log.debug(`file-loader ${id}`);
67
66
  const idPosix = (0, path_1.ensureUnixPath)(id);
68
67
  const data = fileCache.get(idPosix);
@@ -71,7 +70,7 @@ function fileLoaderPlugin(fileCache, resolutionExtensions) {
71
70
  }
72
71
  return {
73
72
  code: data.content,
74
- map: (_a = fileCache.get(`${idPosix}.map`)) === null || _a === void 0 ? void 0 : _a.content,
73
+ map: fileCache.get(`${idPosix}.map`)?.content,
75
74
  };
76
75
  },
77
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,4CAsCC;AAhDD,yCAA6C;AAI7C,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B,EAAE,oBAA8B;IACzF,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ;YAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACtC,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,MAAM,QAAQ,GAAG,IAAA,qBAAc,EAAC,IAAA,mBAAO,EAAC,IAAA,mBAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAChE,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;gBAC1C,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;gBACpC,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC7B,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,EAAE,UAAU,EAAE;;YAChB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC;YACnC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;YACzD,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,GAAG,EAAE,MAAA,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC,0CAAE,OAAO;aAC9C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dirname, resolve } from 'node:path';\nimport type { Plugin } from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache, resolutionExtensions: string[]): Plugin {\n return {\n name: 'file-loader',\n resolveId: function (id, importer) {\n if (fileCache.has(ensureUnixPath(id))) {\n return id;\n }\n\n if (!importer) {\n return;\n }\n\n const resolved = ensureUnixPath(resolve(dirname(importer), id));\n if (fileCache.has(resolved)) {\n return resolved;\n }\n\n for (const suffix of resolutionExtensions) {\n const potential = resolved + suffix;\n if (fileCache.has(potential)) {\n return potential;\n }\n }\n },\n load: function (id) {\n log.debug(`file-loader ${id}`);\n const idPosix = ensureUnixPath(id);\n const data = fileCache.get(idPosix);\n if (!data) {\n throw new Error(`Could not load '${id}' from memory.`);\n }\n\n return {\n code: data.content,\n map: fileCache.get(`${idPosix}.map`)?.content,\n };\n },\n };\n}\n"]}
1
+ {"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,4CAsCC;AAhDD,yCAA6C;AAI7C,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B,EAAE,oBAA8B;IACzF,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ;YAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACtC,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,MAAM,QAAQ,GAAG,IAAA,qBAAc,EAAC,IAAA,mBAAO,EAAC,IAAA,mBAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAChE,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;gBAC1C,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;gBACpC,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC7B,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,EAAE,UAAU,EAAE;YAChB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC;YACnC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;YACzD,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC,EAAE,OAAO;aAC9C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dirname, resolve } from 'node:path';\nimport type { Plugin } from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache, resolutionExtensions: string[]): Plugin {\n return {\n name: 'file-loader',\n resolveId: function (id, importer) {\n if (fileCache.has(ensureUnixPath(id))) {\n return id;\n }\n\n if (!importer) {\n return;\n }\n\n const resolved = ensureUnixPath(resolve(dirname(importer), id));\n if (fileCache.has(resolved)) {\n return resolved;\n }\n\n for (const suffix of resolutionExtensions) {\n const potential = resolved + suffix;\n if (fileCache.has(potential)) {\n return potential;\n }\n }\n },\n load: function (id) {\n log.debug(`file-loader ${id}`);\n const idPosix = ensureUnixPath(id);\n const data = fileCache.get(idPosix);\n if (!data) {\n throw new Error(`Could not load '${id}' from memory.`);\n }\n\n return {\n code: data.content,\n map: fileCache.get(`${idPosix}.map`)?.content,\n };\n },\n };\n}\n"]}
@@ -46,13 +46,13 @@ const file_loader_plugin_1 = require("./file-loader-plugin");
46
46
  let rollup;
47
47
  /** Runs rollup over the given entry file, writes a bundle file. */
48
48
  async function rollupBundleFile(opts) {
49
- var _a;
50
49
  await ensureRollup();
51
50
  log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
52
51
  const cacheDirectory = opts.cacheDirectory;
53
52
  const dtsMode = opts.entry.endsWith('.d.ts');
54
53
  let outExtension;
55
54
  let plugins;
55
+ const jail = path.dirname(opts.entry);
56
56
  if (dtsMode) {
57
57
  outExtension = '.d.ts';
58
58
  plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.d.ts', '/index.d.ts']), (0, rollup_plugin_dts_1.dts)()];
@@ -64,8 +64,8 @@ async function rollupBundleFile(opts) {
64
64
  // Create the bundle
65
65
  const bundle = await rollup.rollup({
66
66
  context: 'this',
67
- external: moduleId => isExternalDependency(moduleId),
68
- cache: (_a = opts.cache) !== null && _a !== void 0 ? _a : (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
67
+ external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),
68
+ cache: opts.cache ?? (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
69
69
  input: opts.entry,
70
70
  plugins,
71
71
  onwarn: warning => {
@@ -90,6 +90,7 @@ async function rollupBundleFile(opts) {
90
90
  name: opts.moduleName,
91
91
  format: 'es',
92
92
  dir: opts.dir,
93
+ importAttributesKey: 'with',
93
94
  inlineDynamicImports: false,
94
95
  hoistTransitiveImports: false,
95
96
  chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,
@@ -126,12 +127,12 @@ async function ensureRollup() {
126
127
  log.debug(`rollup using wasm version.`);
127
128
  }
128
129
  }
129
- function isExternalDependency(moduleId) {
130
+ function isExternalDependency(moduleId, parentId, jail) {
130
131
  // more information about why we don't check for 'node_modules' path
131
132
  // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632
132
133
  if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {
133
134
  // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib
134
- return false;
135
+ return !path.join(parentId, moduleId).startsWith(jail);
135
136
  }
136
137
  return true;
137
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,4CA4EC;AAzGD,sEAA6C;AAC7C,2CAA6B;AAE7B,yDAAwC;AAExC,0CAAgE;AAChE,kDAAoC;AACpC,6DAAwD;AAmBxD,IAAI,MAA2C,CAAC;AAEhD,mEAAmE;AAC5D,KAAK,UAAU,gBAAgB,CACpC,IAAmB;;IAEnB,MAAM,YAAY,EAAE,CAAC;IAErB,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACtE,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,YAAoB,CAAC;IACzB,IAAI,OAA4B,CAAC;IAEjC,IAAI,OAAO,EAAE,CAAC;QACZ,YAAY,GAAG,OAAO,CAAC;QACvB,OAAO,GAAG,CAAC,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,IAAA,uBAAG,GAAE,CAAC,CAAC;IAChF,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,MAAM,CAAC;QACtB,OAAO,GAAG,CAAC,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,EAAE,IAAA,qBAAU,GAAE,CAAC,CAAC;IACnF,CA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M,IAAA,sBAAc,EAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,gFAAgF;IAChF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC3B,wGAAwG;YACxG,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACvB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;YACf,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,YAAY;IACzB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,wDAAa,QAAQ,GAAC,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC3C,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport * as path from 'path';\nimport type { InputPluginOption, OutputAsset, OutputChunk, RollupCache } from 'rollup';\nimport { dts } from 'rollup-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\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 cache?: RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n sourcemap: boolean;\n}\n\nlet rollup: typeof import('rollup') | undefined;\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: RollupCache; files: (OutputChunk | OutputAsset)[] }> {\n await ensureRollup();\n\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);\n const cacheDirectory = opts.cacheDirectory;\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: InputPluginOption[];\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts']), dts()];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js']), rollupJson()];\n }\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 onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n case 'EMPTY_BUNDLE':\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 hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, 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.map(f => {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n cache: bundle.cache,\n };\n}\n\nasync function ensureRollup(): Promise<void> {\n if (rollup) {\n return;\n }\n\n try {\n rollup = await import('rollup');\n log.debug(`rollup using native version.`);\n } catch {\n rollup = await import('@rollup/wasm-node');\n log.debug(`rollup using wasm version.`);\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[0] === '.' || moduleId[0] === '/' || 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,4CA8EC;AA3GD,sEAA6C;AAC7C,2CAA6B;AAE7B,yDAAwC;AAExC,0CAAgE;AAChE,kDAAoC;AACpC,6DAAwD;AAmBxD,IAAI,MAA2C,CAAC;AAEhD,mEAAmE;AAC5D,KAAK,UAAU,gBAAgB,CACpC,IAAmB;IAEnB,MAAM,YAAY,EAAE,CAAC;IAErB,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACtE,MAA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AC;QACX,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,wDAAa,QAAQ,GAAC,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC3C,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IAC5E,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport * as path from 'path';\nimport type { InputPluginOption, OutputAsset, OutputChunk, RollupCache } from 'rollup';\nimport { dts } from 'rollup-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\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 cache?: RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n sourcemap: boolean;\n}\n\nlet rollup: typeof import('rollup') | undefined;\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: RollupCache; files: (OutputChunk | OutputAsset)[] }> {\n await ensureRollup();\n\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);\n const cacheDirectory = opts.cacheDirectory;\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: InputPluginOption[];\n const jail = path.dirname(opts.entry);\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts']), dts()];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js']), rollupJson()];\n }\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins,\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n case 'EMPTY_BUNDLE':\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 importAttributesKey: 'with',\n inlineDynamicImports: false,\n hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, 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.map(f => {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n cache: bundle.cache,\n };\n}\n\nasync function ensureRollup(): Promise<void> {\n if (rollup) {\n return;\n }\n\n try {\n rollup = await import('rollup');\n log.debug(`rollup using native version.`);\n } catch {\n rollup = await import('@rollup/wasm-node');\n log.debug(`rollup using wasm version.`);\n }\n}\n\nfunction isExternalDependency(moduleId: string, parentId: string, jail: 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[0] === '.' || moduleId[0] === '/' || 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 !path.join(parentId, moduleId).startsWith(jail);\n }\n\n return true;\n}\n"]}
@@ -7,9 +7,8 @@ const nodes_1 = require("../ng-package/nodes");
7
7
  * Technically, it's implemented as a map-like collection with references between map entries.
8
8
  */
9
9
  class BuildGraph {
10
- constructor() {
11
- this.store = new Map();
12
- }
10
+ store = new Map();
11
+ watcher;
13
12
  put(value) {
14
13
  if (value instanceof Array) {
15
14
  for (const node of value) {
@@ -1 +1 @@
1
- {"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAqBlD;;;GAGG;AACH,MAAa,UAAU;IAAvB;QACU,UAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IAmF1C,CAAC;IAhFQ,GAAG,CAAC,KAAoB;QAC7B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,MAAM,CAAC,IAAU;QACvB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,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AAC;QAEvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,IAAS,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,IAAI,CAAwB,EAA6B;QAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACb,OAAO,IAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AApFD,gCAoFC","sourcesContent":["import { FSWatcher } from 'chokidar';\nimport { fileUrlPath } from '../ng-package/nodes';\nimport { Node } from './node';\n\nexport type SimplePredicate<T = Node> = {\n (value: T): boolean;\n and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;\n};\n\nexport type ComplexPredicate<T = Node, R extends T = T> =\n | SimplePredicate<T>\n | {\n (value: T): value is R;\n and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;\n };\n\nexport interface Traversable<T> {\n filter<R extends T = T>(by: ComplexPredicate<T, R>): R[];\n find<R extends T = T>(by: ComplexPredicate<T, R>): R | undefined;\n some(by: SimplePredicate<T>): boolean;\n}\n\n/**\n * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.\n * Technically, it's implemented as a map-like collection with references between map entries.\n */\nexport class BuildGraph implements Traversable<Node> {\n private store = new Map<string, Node>();\n watcher?: FSWatcher;\n\n public put(value: Node | Node[]) {\n if (value instanceof Array) {\n for (const node of value) {\n this.insert(node);\n }\n } else {\n this.insert(value);\n }\n\n return this;\n }\n\n private insert(node: Node) {\n if (this.store.has(node.url)) {\n // Clean up dependee references\n const oldNode = this.store.get(node.url);\n oldNode['_dependees'].delete(oldNode);\n }\n\n if (this.watcher) {\n const fileUrl = fileUrlPath(node.url);\n if (fileUrl) {\n this.watcher.add(fileUrl);\n }\n }\n\n this.store.set(node.url, node);\n }\n\n public get(url: string): Node {\n return this.store.get(url);\n }\n\n public has(url: string): boolean {\n return this.store.has(url);\n }\n\n public entries(): Node[] {\n return Array.from(this.store.values());\n }\n\n public values(): IterableIterator<Node> {\n return this.store.values();\n }\n\n public some<T extends Node = Node>(by: ComplexPredicate<Node, T>): boolean {\n for (const node of this.store.values()) {\n if (by(node)) {\n return true;\n }\n }\n\n return false;\n }\n\n public filter<T extends Node = Node>(by: ComplexPredicate<Node, T>): T[] {\n const result: T[] = [];\n\n for (const node of this.store.values()) {\n if (by(node)) {\n result.push(node as T);\n }\n }\n\n return result;\n }\n\n public find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined {\n for (const node of this.store.values()) {\n if (by(node)) {\n return node as T;\n }\n }\n\n return undefined;\n }\n\n get size(): number {\n return this.store.size;\n }\n}\n"]}
1
+ {"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAqBlD;;;GAGG;AACH,MAAa,UAAU;IACb,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IACxC,OAAO,CAAa;IAEb,GAAG,CAAC,KAAoB;QAC7B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,MAAM,CAAC,IAAU;QACvB,IAAI,IAAI,CA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,MAAM,MAAM,GAAQ,EAAE,CAAC;QAEvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,IAAS,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,IAAI,CAAwB,EAA6B;QAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBACb,OAAO,IAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AApFD,gCAoFC","sourcesContent":["import { FSWatcher } from 'chokidar';\nimport { fileUrlPath } from '../ng-package/nodes';\nimport { Node } from './node';\n\nexport type SimplePredicate<T = Node> = {\n (value: T): boolean;\n and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;\n};\n\nexport type ComplexPredicate<T = Node, R extends T = T> =\n | SimplePredicate<T>\n | {\n (value: T): value is R;\n and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;\n };\n\nexport interface Traversable<T> {\n filter<R extends T = T>(by: ComplexPredicate<T, R>): R[];\n find<R extends T = T>(by: ComplexPredicate<T, R>): R | undefined;\n some(by: SimplePredicate<T>): boolean;\n}\n\n/**\n * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.\n * Technically, it's implemented as a map-like collection with references between map entries.\n */\nexport class BuildGraph implements Traversable<Node> {\n private store = new Map<string, Node>();\n watcher?: FSWatcher;\n\n public put(value: Node | Node[]) {\n if (value instanceof Array) {\n for (const node of value) {\n this.insert(node);\n }\n } else {\n this.insert(value);\n }\n\n return this;\n }\n\n private insert(node: Node) {\n if (this.store.has(node.url)) {\n // Clean up dependee references\n const oldNode = this.store.get(node.url);\n oldNode['_dependees'].delete(oldNode);\n }\n\n if (this.watcher) {\n const fileUrl = fileUrlPath(node.url);\n if (fileUrl) {\n this.watcher.add(fileUrl);\n }\n }\n\n this.store.set(node.url, node);\n }\n\n public get(url: string): Node {\n return this.store.get(url);\n }\n\n public has(url: string): boolean {\n return this.store.has(url);\n }\n\n public entries(): Node[] {\n return Array.from(this.store.values());\n }\n\n public values(): IterableIterator<Node> {\n return this.store.values();\n }\n\n public some<T extends Node = Node>(by: ComplexPredicate<Node, T>): boolean {\n for (const node of this.store.values()) {\n if (by(node)) {\n return true;\n }\n }\n\n return false;\n }\n\n public filter<T extends Node = Node>(by: ComplexPredicate<Node, T>): T[] {\n const result: T[] = [];\n\n for (const node of this.store.values()) {\n if (by(node)) {\n result.push(node as T);\n }\n }\n\n return result;\n }\n\n public find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined {\n for (const node of this.store.values()) {\n if (by(node)) {\n return node as T;\n }\n }\n\n return undefined;\n }\n\n get size(): number {\n return this.store.size;\n }\n}\n"]}
@@ -9,12 +9,13 @@ exports.STATE_DONE = 'done';
9
9
  * A Node in the {@link BuildGraph}.
10
10
  */
11
11
  class Node {
12
+ url;
12
13
  constructor(url) {
13
14
  this.url = url;
14
- this.state = '';
15
- this._dependents = new Set();
16
- this._dependees = new Set();
17
15
  }
16
+ type;
17
+ data;
18
+ state = '';
18
19
  filter(by) {
19
20
  return [...this._dependents].filter(by);
20
21
  }
@@ -30,6 +31,8 @@ class Node {
30
31
  get dependees() {
31
32
  return this._dependees;
32
33
  }
34
+ _dependents = new Set();
35
+ _dependees = new Set();
33
36
  dependsOn(dependent) {
34
37
  const newDeps = Array.isArray(dependent) ? dependent : [dependent];
35
38
  for (const newDep of newDeps) {
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../src/lib/graph/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G,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF;AA7CD,oBA6CC","sourcesContent":["export type NodeState = '' | 'error' | 'in-progress' | 'pending' | 'done';\n\nexport const STATE_ERROR: NodeState = 'error';\nexport const STATE_IN_PROGRESS: NodeState = 'in-progress';\nexport const STATE_PENDING: NodeState = 'pending';\nexport const STATE_DONE: NodeState = 'done';\n\n/**\n * A Node in the {@link BuildGraph}.\n */\nexport class Node {\n constructor(public readonly url: string) {}\n\n public type: string;\n\n public data: any;\n\n public state: NodeState = '';\n\n public filter(by: (value: Node, index: number) => boolean): Node[] {\n return [...this._dependents].filter(by);\n }\n\n public find(by: (value: Node, index: number) => boolean): Node | undefined {\n return [...this._dependents].find(by);\n }\n\n public some(by: (value: Node, index: number) => boolean): boolean {\n return [...this._dependents].some(by);\n }\n\n public get dependents(): Set<Node> {\n return this._dependents;\n }\n\n public get dependees(): Set<Node> {\n return this._dependees;\n }\n\n private _dependents = new Set<Node>();\n private _dependees = new Set<Node>();\n\n public dependsOn(dependent: Node | Node[]) {\n const newDeps = Array.isArray(dependent) ? dependent : [dependent];\n\n for (const newDep of newDeps) {\n if (newDep._dependees.has(this)) {\n // nodes already depends on each other\n continue;\n }\n\n newDep._dependees.add(this);\n this._dependents.add(newDep);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../src/lib/graph/node.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAc,OAAO,CAAC;AACjC,QAAA,iBAAiB,GAAc,aAAa,CAAC;AAC7C,QAAA,aAAa,GAAc,SAAS,CAAC;AACrC,QAAA,UAAU,GAAc,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAa,IAAI;IACa;IAA5B,YAA4B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEpC,IAAI,CAAS;IAEb,IAAI,CAAM;IAEV,KAAK,GAAc,EAAE,CAAC;IAEtB,MAAM,CAAC,EAA2C;QACvD,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEM,IAAI,CAAC,EAA2C;QACrD,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAEM,IAAI,CAAC,EAA2C;QACrD,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,WAAW,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC9B,UAAU,GAAG,IAAI,GAAG,EAAQ,CAAC;IAE9B,SAAS,CAAC,SAAwB;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEnE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChC,sCAAsC;gBACtC,SAAS;YACX,CAAC;YAED,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF;AA7CD,oBA6CC","sourcesContent":["export type NodeState = '' | 'error' | 'in-progress' | 'pending' | 'done';\n\nexport const STATE_ERROR: NodeState = 'error';\nexport const STATE_IN_PROGRESS: NodeState = 'in-progress';\nexport const STATE_PENDING: NodeState = 'pending';\nexport const STATE_DONE: NodeState = 'done';\n\n/**\n * A Node in the {@link BuildGraph}.\n */\nexport class Node {\n constructor(public readonly url: string) {}\n\n public type: string;\n\n public data: any;\n\n public state: NodeState = '';\n\n public filter(by: (value: Node, index: number) => boolean): Node[] {\n return [...this._dependents].filter(by);\n }\n\n public find(by: (value: Node, index: number) => boolean): Node | undefined {\n return [...this._dependents].find(by);\n }\n\n public some(by: (value: Node, index: number) => boolean): boolean {\n return [...this._dependents].some(by);\n }\n\n public get dependents(): Set<Node> {\n return this._dependents;\n }\n\n public get dependees(): Set<Node> {\n return this._dependees;\n }\n\n private _dependents = new Set<Node>();\n private _dependees = new Set<Node>();\n\n public dependsOn(dependent: Node | Node[]) {\n const newDeps = Array.isArray(dependent) ? dependent : [dependent];\n\n for (const newDep of newDeps) {\n if (newDep._dependees.has(this)) {\n // nodes already depends on each other\n continue;\n }\n\n newDep._dependees.add(this);\n this._dependents.add(newDep);\n }\n }\n}\n"]}
@@ -61,7 +61,6 @@ async function readConfigFile(filePath) {
61
61
  * @return The user's package
62
62
  */
63
63
  async function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
64
- var _a;
65
64
  const fullPath = path.resolve(folderPathOrFilePath);
66
65
  const pathStats = await (0, fs_1.stat)(fullPath);
67
66
  const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);
@@ -76,7 +75,7 @@ async function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
76
75
  ngPackageJson = await readConfigFile(fullPath);
77
76
  }
78
77
  if (ngPackageJson) {
79
- ngPackageJson = (_a = ngPackageJson['default']) !== null && _a !== void 0 ? _a : ngPackageJson;
78
+ ngPackageJson = ngPackageJson['default'] ?? ngPackageJson;
80
79
  try {
81
80
  if (isSecondary) {
82
81
  (0, schema_1.validateNgPackageEntryPointSchema)(ngPackageJson);
@@ -1 +1 @@
1
- {"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/discover-packages.ts"],"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AC,iCAAiC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,OAAO,IAAI,mBAAS,CAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { parse as parseJson } from 'jsonc-parser';\nimport * as path from 'path';\nimport { glob } from 'tinyglobby';\nimport { exists, readFile, stat } from '../utils/fs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { validateNgPackageEntryPointSchema, 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 try {\n if (isSecondary) {\n validateNgPackageEntryPointSchema(ngPackageJson);\n } else {\n validateNgPackageSchema(ngPackageJson);\n }\n } catch (e) {\n log.error(`An error has occurred while validating config at ${folderPathOrFilePath}`);\n throw e;\n }\n\n let packageJson: Record<string, unknown> = {};\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 { basePath, packageJson, ngPackageJson };\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 glob(`**/ng-package.json`, { ignore, onlyFiles: true, cwd: directoryPath });\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(ensureUnixPath(basePath), primary, secondaries);\n}\n"]}
1
+ {"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuIA,4CAsBC;AA7JD,+CAAkD;AAClD,2CAA6B;AAC7B,2CAAkC;AAClC,oCAAqD;AACrD,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAyD;AACzD,uCAAsC;AACtC,qCAAsF;AAWtF,KAAK,UAAU,cAAc,CAAC,QAAgB;IAC5C,IAAI,CAAC,CAAC,MAAM,IAAA,WAAM,EAAC,QAAQ,C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\nimport { glob } from 'tinyglobby';\nimport { exists, readFile, stat } from '../utils/fs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { validateNgPackageEntryPointSchema, 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 try {\n if (isSecondary) {\n validateNgPackageEntryPointSchema(ngPackageJson);\n } else {\n validateNgPackageSchema(ngPackageJson);\n }\n } catch (e) {\n log.error(`An error has occurred while validating config at ${folderPathOrFilePath}`);\n throw e;\n }\n\n let packageJson: Record<string, unknown> = {};\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 { basePath, packageJson, ngPackageJson };\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 glob(`**/ng-package.json`, { ignore, onlyFiles: true, cwd: directoryPath });\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(ensureUnixPath(basePath), primary, secondaries);\n}\n"]}
@@ -47,8 +47,6 @@ const tsconfig_1 = require("../../ts/tsconfig");
47
47
  const nodes_1 = require("../nodes");
48
48
  const compileNgcTransformFactory = (StylesheetProcessor, options) => {
49
49
  return (0, transform_1.transformFromPromise)(async (graph) => {
50
- var _a, _b;
51
- var _c;
52
50
  const spinner = (0, ora_1.default)({
53
51
  hideCursor: false,
54
52
  discardStdin: false,
@@ -76,7 +74,7 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
76
74
  const { basePath, cssUrl, styleIncludePaths, sass } = entryPoint.data.entryPoint;
77
75
  const { moduleResolutionCache } = entryPoint.cache;
78
76
  spinner.start(`Compiling with Angular sources in ${tsConfig.options.compilationMode || 'full'} compilation mode.`);
79
- (_a = (_c = entryPoint.cache).stylesheetProcessor) !== null && _a !== void 0 ? _a : (_c.stylesheetProcessor = new StylesheetProcessor(projectBasePath, basePath, cssUrl, styleIncludePaths, sass, options.cacheEnabled && options.cacheDirectory, options.watch));
77
+ entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(projectBasePath, basePath, cssUrl, styleIncludePaths, sass, options.cacheEnabled && options.cacheDirectory, options.watch);
80
78
  await (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, options, {
81
79
  outDir: path.dirname(esm2022),
82
80
  declarationDir: path.dirname(declarations),
@@ -90,7 +88,7 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
90
88
  }
91
89
  finally {
92
90
  if (!options.watch) {
93
- (_b = entryPoint.cache.stylesheetProcessor) === null || _b === void 0 ? void 0 : _b.destroy();
91
+ entryPoint.cache.stylesheetProcessor?.destroy();
94
92
  }
95
93
  }
96
94
  spinner.succeed();
@@ -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,+CAAkD;AAClD,qDAAwE;AACxE,yEAAoE;AAEpE,gDAAiE;AACjE,oCAAgF;AAGzE,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,EAAE,CAAC;QACzC,IAAI,UAA0B,CAAC;QAC/B,IAAI,aAA0B,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAClC,IAAI,IAAA,oBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEvB,IAAI,IAAA,qBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;oBACvB,UAAU,GAAG,IAAI,CAAC;gBACp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EACD,UAAU,CAAC,KAAK,CAAC,mBAAmB,CACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAA,UAAU,CAAC,KAAK,CAAC,mBAAmB,0CAAE,OAAO,EAAE,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA7EW,QAAA,0BAA0B,8BA6ErC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { isInProgress } from '../../graph/select';\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, 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[] = [];\n let entryPoint: EntryPointNode;\n let ngPackageNode: PackageNode;\n\n for (const node of graph.values()) {\n if (isEntryPoint(node)) {\n entryPoints.push(node);\n\n if (isInProgress(node)) {\n entryPoint = node;\n }\n } else if (isPackage(node)) {\n ngPackageNode = node;\n }\n }\n\n const projectBasePath = ngPackageNode.data.primary.basePath;\n\n try {\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2022: esm2022, declarations } = entryPoint.data.destinationFiles;\n const { basePath, cssUrl, styleIncludePaths, sass } = entryPoint.data.entryPoint;\n const { moduleResolutionCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n\n entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(\n projectBasePath,\n basePath,\n cssUrl,\n styleIncludePaths,\n sass,\n options.cacheEnabled && options.cacheDirectory,\n options.watch,\n );\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n options,\n {\n outDir: path.dirname(esm2022),\n declarationDir: path.dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2022,\n },\n entryPoint.cache.stylesheetProcessor,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n } finally {\n if (!options.watch) {\n entryPoint.cache.stylesheetProcessor?.destroy();\n }\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
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,+CAAkD;AAClD,qDAAwE;AACxE,yEAAoE;AAEpE,gDAAiE;AACjE,oCAAgF;AAGzE,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,EAAE,CAAC;QACzC,IAAI,UAA0B,CAAC;QAC/B,IAAI,aAA0B,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM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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,CACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACnB,UAAU,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC;YAClD,CAAC;QACH,CAAC;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA7EW,QAAA,0BAA0B,8BA6ErC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { isInProgress } from '../../graph/select';\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, 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[] = [];\n let entryPoint: EntryPointNode;\n let ngPackageNode: PackageNode;\n\n for (const node of graph.values()) {\n if (isEntryPoint(node)) {\n entryPoints.push(node);\n\n if (isInProgress(node)) {\n entryPoint = node;\n }\n } else if (isPackage(node)) {\n ngPackageNode = node;\n }\n }\n\n const projectBasePath = ngPackageNode.data.primary.basePath;\n\n try {\n // Add paths mappings for dependencies\n const tsConfig = setDependenciesTsConfigPaths(entryPoint.data.tsConfig, entryPoints);\n\n // Compile TypeScript sources\n const { esm2022: esm2022, declarations } = entryPoint.data.destinationFiles;\n const { basePath, cssUrl, styleIncludePaths, sass } = entryPoint.data.entryPoint;\n const { moduleResolutionCache } = entryPoint.cache;\n\n spinner.start(\n `Compiling with Angular sources in ${tsConfig.options.compilationMode || 'full'} compilation mode.`,\n );\n\n entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(\n projectBasePath,\n basePath,\n cssUrl,\n styleIncludePaths,\n sass,\n options.cacheEnabled && options.cacheDirectory,\n options.watch,\n );\n\n await compileSourceFiles(\n graph,\n tsConfig,\n moduleResolutionCache,\n options,\n {\n outDir: path.dirname(esm2022),\n declarationDir: path.dirname(declarations),\n declaration: true,\n target: ts.ScriptTarget.ES2022,\n },\n entryPoint.cache.stylesheetProcessor,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n } finally {\n if (!options.watch) {\n entryPoint.cache.stylesheetProcessor?.destroy();\n }\n }\n\n spinner.succeed();\n\n return graph;\n });\n};\n"]}
@@ -66,6 +66,10 @@ const path_1 = require("../../utils/path");
66
66
  * The parent package of an entry point is reflected by `NgPackage`.
67
67
  */
68
68
  class NgEntryPoint {
69
+ packageJson;
70
+ ngPackageJson;
71
+ basePath;
72
+ secondaryData;
69
73
  constructor(
70
74
  /** Values from the `package.json` file of this entry point. */
71
75
  packageJson,
@@ -1 +1 @@
1
- {"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAI7B,2CAAkD;AAoBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IACv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CAAC;IAED,IAAW,iBAAiB;QAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAC;QAE9D,OAAO,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CACpC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CACtF,CAAC;IACJ,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACrF,CAAC;IAEO,eAAe,CAAC,SAAS,GAAG,GAAG;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAEnF,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACF;AAvGD,oCAuGC","sourcesContent":["import * as path from 'path';\nimport { NgPackageEntryConfig } from '../../../ng-entrypoint.schema';\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 bundled entry point `declarations` */\n declarationsBundled: string;\n /** Absolute path of this entry point `types` directory */\n declarationsDir: string;\n /** Absolute path of this entry point `FESM2022` module */\n fesm2022: string;\n /** Absolute path of this entry point `ESM2022` module */\n esm2022: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n /** Absolute path of this entry point `FESM2022` directory */\n fesm2022Dir: 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?: Record<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 return this.secondaryData ? this.secondaryData.destinationPath : path.resolve(this.basePath, this.$get('dest'));\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('tmp-typings', secondaryDir, `${flatModuleFile}.d.ts`),\n declarationsBundled: pathJoinWithDest('types', `${flatModuleFile}.d.ts`),\n declarationsDir: pathJoinWithDest('types'),\n esm2022: pathJoinWithDest('tmp-esm2022', secondaryDir, `${flatModuleFile}.js`),\n fesm2022: pathJoinWithDest('fesm2022', `${flatModuleFile}.mjs`),\n fesm2022Dir: pathJoinWithDest('fesm2022'),\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 public get sass(): NgPackageEntryConfig['lib']['sass'] {\n return this.$get('lib.sass');\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 return this.secondaryData ? this.secondaryData.moduleId : this.packageJson['name'];\n }\n\n private flattenModuleId(separator = '.'): string {\n const moduleId = this.moduleId[0] === '@' ? this.moduleId.slice(1) : this.moduleId;\n\n return moduleId.split('/').join(separator);\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;AAI7B,2CAAkD;AAoBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IAGL;IAEA;IAEA;IAEC;IARnB;IACE,+DAA+D;IAC/C,WAAgC;IAChD,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,iGAAiG;IAChF,aAAmC;QANpC,gBAAW,GAAX,WAAW,CAAqB;QAEhC,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GAAR,QAAQ,CAAQ;QAEf,kBAAa,GAAb,aAAa,CAAsB;IACnD,CAAC;IAEJ,sEAAsE;IACtE,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,iDAAiD;IACjD,IAAW,qBAAqB;QAC9B,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,oEAAoE;IACpE,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAClH,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C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAEnF,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACF;AAvGD,oCAuGC","sourcesContent":["import * as path from 'path';\nimport { NgPackageEntryConfig } from '../../../ng-entrypoint.schema';\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 bundled entry point `declarations` */\n declarationsBundled: string;\n /** Absolute path of this entry point `types` directory */\n declarationsDir: string;\n /** Absolute path of this entry point `FESM2022` module */\n fesm2022: string;\n /** Absolute path of this entry point `ESM2022` module */\n esm2022: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n /** Absolute path of this entry point `FESM2022` directory */\n fesm2022Dir: 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?: Record<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 return this.secondaryData ? this.secondaryData.destinationPath : path.resolve(this.basePath, this.$get('dest'));\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('tmp-typings', secondaryDir, `${flatModuleFile}.d.ts`),\n declarationsBundled: pathJoinWithDest('types', `${flatModuleFile}.d.ts`),\n declarationsDir: pathJoinWithDest('types'),\n esm2022: pathJoinWithDest('tmp-esm2022', secondaryDir, `${flatModuleFile}.js`),\n fesm2022: pathJoinWithDest('fesm2022', `${flatModuleFile}.mjs`),\n fesm2022Dir: pathJoinWithDest('fesm2022'),\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 public get sass(): NgPackageEntryConfig['lib']['sass'] {\n return this.$get('lib.sass');\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 return this.secondaryData ? this.secondaryData.moduleId : this.packageJson['name'];\n }\n\n private flattenModuleId(separator = '.'): string {\n const moduleId = this.moduleId[0] === '@' ? this.moduleId.slice(1) : this.moduleId;\n\n return moduleId.split('/').join(separator);\n }\n}\n"]}
@@ -14,7 +14,6 @@ const fs_1 = require("../../utils/fs");
14
14
  const path_2 = require("../../utils/path");
15
15
  const nodes_1 = require("../nodes");
16
16
  const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
17
- var _a, _b;
18
17
  const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
19
18
  const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;
20
19
  const cache = entryPoint.cache;
@@ -23,12 +22,12 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
23
22
  hideCursor: false,
24
23
  discardStdin: false,
25
24
  });
26
- const cacheKey = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, declarationsDir, fesm2022Dir, tsConfig.options.compilationMode, ((_a = tsConfig.options.declarationMap) !== null && _a !== void 0 ? _a : false).toString());
25
+ const cacheKey = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, declarationsDir, fesm2022Dir, tsConfig.options.compilationMode, (tsConfig.options.declarationMap ?? false).toString());
27
26
  const hash = await (0, cache_1.generateKey)([...cache.outputCache.values()].map(({ version }) => version).join(':'));
28
27
  const cacheDirectory = options.cacheEnabled && options.cacheDirectory;
29
28
  if (cacheDirectory) {
30
29
  const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory, cacheKey);
31
- if ((cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.hash) === hash) {
30
+ if (cacheResult?.hash === hash) {
32
31
  const filesToCopy = [
33
32
  ...cacheResult.fesm2022.map(file => ({
34
33
  ...file,
@@ -108,7 +107,7 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
108
107
  }
109
108
  const dtsFile = (0, path_2.ensureUnixPath)((0, path_1.join)(declarationsDir, file.fileName));
110
109
  const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);
111
- if (((_b = cachedSourceFile === null || cachedSourceFile === void 0 ? void 0 : cachedSourceFile.sourceFile) === null || _b === void 0 ? void 0 : _b.text) !== file.code) {
110
+ if (cachedSourceFile?.sourceFile?.text !== file.code) {
112
111
  changedDtsFiles.push(dtsFile);
113
112
  }
114
113
  }
@@ -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,+BAA4B;AAE5B,iEAA2F;AAC3F,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAAkE;AAS3D,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;;IACjC,MAAM,UAAU,GAAmB,KAAK,CA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OutputAsset, OutputChunk } from 'rollup';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2022: (OutputChunk | OutputAsset)[];\n types: (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 { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const cacheKey = await generateKey(\n ngEntryPoint.moduleId,\n declarationsDir,\n fesm2022Dir,\n tsConfig.options.compilationMode,\n (tsConfig.options.declarationMap ?? false).toString(),\n );\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, cacheKey);\n if (cacheResult?.hash === hash) {\n const filesToCopy = [\n ...cacheResult.fesm2022.map(file => ({\n ...file,\n filePath: join(fesm2022Dir, file.fileName),\n })),\n ...cacheResult.types.map(file => ({\n ...file,\n filePath: join(declarationsDir, file.fileName),\n })),\n ];\n\n try {\n const writeFilePromises: Promise<void>[] = [];\n for (const file of filesToCopy) {\n if (options.watch && (await exists(file.filePath))) {\n continue;\n }\n\n if (writeFilePromises.length === 0) {\n spinner.start('Writing FESM and DTS bundles');\n await Promise.all([mkdir(fesm2022Dir, { recursive: true }), mkdir(declarationsDir, { recursive: true })]);\n }\n\n writeFilePromises.push(writeFile(file.filePath, file.type === 'asset' ? file.source : file.code));\n }\n\n if (writeFilePromises.length) {\n await Promise.all(writeFilePromises);\n spinner.succeed('Writing FESM and DTS bundles');\n }\n } catch (error) {\n spinner.fail('Writing FESM and DTS bundles');\n throw error;\n }\n\n return;\n }\n }\n\n async function generateBundles(): Promise<BundlesCache> {\n const [{ cache: rollupFESM2022Cache, files: fesmFiles }, { cache: rollupTypesCache, files: typesFiles }] =\n await Promise.all([\n rollupBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n cache: cache.rollupFESM2022Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey,\n sourcemap: true,\n }),\n rollupBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n cache: cache.rollupTypesCache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey,\n sourcemap: tsConfig.options.declarationMap || false,\n }),\n ]);\n\n cache.rollupFESM2022Cache = rollupFESM2022Cache;\n cache.rollupTypesCache = rollupTypesCache;\n\n return {\n hash,\n types: typesFiles,\n fesm2022: fesmFiles,\n };\n }\n\n let cacheRollup: BundlesCache;\n try {\n cacheRollup = await generateBundles();\n spinner.succeed(`Generating FESM and DTS bundles`);\n\n // Invalidate dependent entry-points\n const changedDtsFiles: string[] = [];\n for (const file of cacheRollup.types) {\n if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {\n continue;\n }\n\n const dtsFile = ensureUnixPath(join(declarationsDir, file.fileName));\n const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);\n if (cachedSourceFile?.sourceFile?.text !== file.code) {\n changedDtsFiles.push(dtsFile);\n }\n }\n\n if (changedDtsFiles.length) {\n invalidateEntryPointsAndCacheOnFileChange(graph, changedDtsFiles, cache.sourcesFileCache);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, cacheRollup);\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,iEAA2F;AAC3F,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAAkE;AAS3D,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,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAAC;IACjF,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAChC,YAAY,CAAC,QAAQ,EACrB,eAAe,EACf,WAAW,EACX,QAAQ,CAAC,OAAO,CAAC,eAAe,EAChC,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,CACtD,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAW,EAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CA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B,IAAA,wDAAyC,EAAC,KAAK,EAAE,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,CAAC,CAAC;AAlIQ,QAAA,qBAAqB,yBAkI7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk } from 'rollup';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2022: (OutputChunk | OutputAsset)[];\n types: (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 { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const cacheKey = await generateKey(\n ngEntryPoint.moduleId,\n declarationsDir,\n fesm2022Dir,\n tsConfig.options.compilationMode,\n (tsConfig.options.declarationMap ?? false).toString(),\n );\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, cacheKey);\n if (cacheResult?.hash === hash) {\n const filesToCopy = [\n ...cacheResult.fesm2022.map(file => ({\n ...file,\n filePath: join(fesm2022Dir, file.fileName),\n })),\n ...cacheResult.types.map(file => ({\n ...file,\n filePath: join(declarationsDir, file.fileName),\n })),\n ];\n\n try {\n const writeFilePromises: Promise<void>[] = [];\n for (const file of filesToCopy) {\n if (options.watch && (await exists(file.filePath))) {\n continue;\n }\n\n if (writeFilePromises.length === 0) {\n spinner.start('Writing FESM and DTS bundles');\n await Promise.all([mkdir(fesm2022Dir, { recursive: true }), mkdir(declarationsDir, { recursive: true })]);\n }\n\n writeFilePromises.push(writeFile(file.filePath, file.type === 'asset' ? file.source : file.code));\n }\n\n if (writeFilePromises.length) {\n await Promise.all(writeFilePromises);\n spinner.succeed('Writing FESM and DTS bundles');\n }\n } catch (error) {\n spinner.fail('Writing FESM and DTS bundles');\n throw error;\n }\n\n return;\n }\n }\n\n async function generateBundles(): Promise<BundlesCache> {\n const [{ cache: rollupFESM2022Cache, files: fesmFiles }, { cache: rollupTypesCache, files: typesFiles }] =\n await Promise.all([\n rollupBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n cache: cache.rollupFESM2022Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey,\n sourcemap: true,\n }),\n rollupBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n cache: cache.rollupTypesCache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey,\n sourcemap: tsConfig.options.declarationMap || false,\n }),\n ]);\n\n cache.rollupFESM2022Cache = rollupFESM2022Cache;\n cache.rollupTypesCache = rollupTypesCache;\n\n return {\n hash,\n types: typesFiles,\n fesm2022: fesmFiles,\n };\n }\n\n let cacheRollup: BundlesCache;\n try {\n cacheRollup = await generateBundles();\n spinner.succeed(`Generating FESM and DTS bundles`);\n\n // Invalidate dependent entry-points\n const changedDtsFiles: string[] = [];\n for (const file of cacheRollup.types) {\n if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {\n continue;\n }\n\n const dtsFile = ensureUnixPath(join(declarationsDir, file.fileName));\n const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);\n if (cachedSourceFile?.sourceFile?.text !== file.code) {\n changedDtsFiles.push(dtsFile);\n }\n }\n\n if (changedDtsFiles.length) {\n invalidateEntryPointsAndCacheOnFileChange(graph, changedDtsFiles, cache.sourcesFileCache);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, cacheRollup);\n }\n });\n"]}