ng-packagr 22.2.0-next.2 → 22.2.0-next.3

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 (28) hide show
  1. package/package.json +4 -4
  2. package/src/lib/file-system/file-watcher.js +2 -1
  3. package/src/lib/file-system/file-watcher.js.map +1 -1
  4. package/src/lib/flatten/file-loader-plugin.d.ts +1 -1
  5. package/src/lib/flatten/file-loader-plugin.js +48 -22
  6. package/src/lib/flatten/file-loader-plugin.js.map +1 -1
  7. package/src/lib/flatten/rolldown.js +2 -8
  8. package/src/lib/flatten/rolldown.js.map +1 -1
  9. package/src/lib/ng-package/entry-point/analyse-sources.transform.js +169 -61
  10. package/src/lib/ng-package/entry-point/analyse-sources.transform.js.map +1 -1
  11. package/src/lib/ng-package/entry-point/entry-point.d.ts +1 -1
  12. package/src/lib/ng-package/entry-point/entry-point.js.map +1 -1
  13. package/src/lib/ng-package/entry-point/write-bundles.transform.js +23 -12
  14. package/src/lib/ng-package/entry-point/write-bundles.transform.js.map +1 -1
  15. package/src/lib/ng-package/nodes.d.ts +4 -4
  16. package/src/lib/ng-package/nodes.js +3 -2
  17. package/src/lib/ng-package/nodes.js.map +1 -1
  18. package/src/lib/ngc/compile-source-files.js +23 -9
  19. package/src/lib/ngc/compile-source-files.js.map +1 -1
  20. package/src/lib/styles/css-url.enum.d.ts +4 -0
  21. package/src/lib/styles/css-url.enum.js +9 -0
  22. package/src/lib/styles/css-url.enum.js.map +1 -0
  23. package/src/lib/styles/stylesheet-processor.d.ts +1 -4
  24. package/src/lib/styles/stylesheet-processor.js +1 -6
  25. package/src/lib/styles/stylesheet-processor.js.map +1 -1
  26. package/src/lib/styles/stylesheets/css-resource-plugin.d.ts +1 -1
  27. package/src/lib/styles/stylesheets/css-resource-plugin.js +2 -2
  28. package/src/lib/styles/stylesheets/css-resource-plugin.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "22.2.0-next.2",
3
+ "version": "22.2.0-next.3",
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
  "chokidar": "^5.0.0",
39
39
  "commander": "^15.0.0",
40
40
  "dependency-graph": "^1.0.0",
41
- "esbuild": "^0.28.0",
41
+ "esbuild": "^0.28.2",
42
42
  "find-cache-directory": "^6.0.0",
43
43
  "injection-js": "^2.4.0",
44
44
  "jsonc-parser": "^3.3.1",
@@ -47,13 +47,13 @@
47
47
  "piscina": "^5.0.0",
48
48
  "postcss": "^8.4.47",
49
49
  "rolldown": "^1.2.0",
50
- "rolldown-plugin-dts": "^0.27.14",
50
+ "rolldown-plugin-dts": "^0.28.0",
51
51
  "rxjs": "^7.8.1",
52
52
  "sass": "^1.81.0",
53
53
  "tinyglobby": "^0.2.12"
54
54
  },
55
55
  "peerDependencies": {
56
- "@angular/compiler-cli": "^22.0.0 || ^22.1.0-next || ^22.2.0-next",
56
+ "@angular/compiler-cli": "^22.2.0-next",
57
57
  "tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
58
58
  "tslib": "^2.3.0",
59
59
  "typescript": ">=6.0 <6.1"
@@ -134,7 +134,8 @@ function invalidateEntryPointsAndCacheOnFileChange(graph, files, sourcesFileCach
134
134
  continue;
135
135
  }
136
136
  entryPoint.cache.angularDiagnosticCache.delete(filePath);
137
- entryPoint.cache.analysesSourcesFileCache.delete(filePath);
137
+ entryPoint.cache.declarationDiagnosticCache?.delete(filePath);
138
+ entryPoint.cache.analyseSourcesFileCache.delete(filePath);
138
139
  isDirty = true;
139
140
  }
140
141
  if (isDirty) {
@@ -1 +1 @@
1
- {"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0CAyDC;AAOD,8FAoEC;AAvJD,mDAAqC;A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AAC;YACzD,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.angularDiagnosticCache.delete(filePath);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0CAyDC;AAOD,8FAqEC;AAxJD,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,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE;QAC/B,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE;YACP,QAAQ;YACR,eAAe;YACf,IAAI,CAAC,EAAE;gBACL,MAAM,cAAc,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;gBAE5C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC;SACF;QACD,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QACnD,QAAQ,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KACtD,CAAC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B,IAAI,wBAAwB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACtC,OAAO,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,mBAAmB,EAAE,UAAU,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;QACjG,CAAC;QAED,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,eAAe,EAAE,CAAC;YACpD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC1C,SAAS;YACX,CAAC;YAED,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzD,UAAU,CAAC,KAAK,CAAC,0BAA0B,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9D,UAAU,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,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.angularDiagnosticCache.delete(filePath);\n entryPoint.cache.declarationDiagnosticCache?.delete(filePath);\n entryPoint.cache.analyseSourcesFileCache.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,6 +1,6 @@
1
1
  import type { Plugin } from 'rolldown';
2
2
  import { OutputFileCache } from '../ng-package/nodes';
3
3
  /**
4
- * Loads a file and it's map.
4
+ * Loads a file and its map.
5
5
  */
6
6
  export declare function fileLoaderPlugin(fileCache: OutputFileCache, resolutionExtensions: string[], dtsMode: boolean): Plugin;
@@ -38,38 +38,64 @@ const node_path_1 = require("node:path");
38
38
  const log = __importStar(require("../utils/log"));
39
39
  const path_1 = require("../utils/path");
40
40
  /**
41
- * A regex used to strip the file extension from a file path.
42
- */
43
- const FILE_EXT_REGEXP = /\.(c|m)?(t|j)s$/;
44
- /**
45
- * Loads a file and it's map.
41
+ * Loads a file and its map.
46
42
  */
47
43
  function fileLoaderPlugin(fileCache, resolutionExtensions, dtsMode) {
48
44
  return {
49
45
  name: 'file-loader',
50
46
  resolveId: function (id, importer) {
51
- const normalizedId = (0, path_1.ensureUnixPath)(id);
52
- if (fileCache.has(normalizedId)) {
53
- return normalizedId;
54
- }
55
- const potentialId = normalizedId.endsWith('.d.ts')
56
- ? normalizedId
57
- : normalizedId.replace(FILE_EXT_REGEXP, (_match, p1) => {
58
- if (dtsMode) {
59
- return p1 ? `.d.${p1}ts` : '.d.ts';
60
- }
61
- return p1 ? `.${p1}js` : '.js';
62
- });
63
- if (fileCache.has(potentialId)) {
64
- return potentialId;
47
+ let resolved;
48
+ if (importer) {
49
+ if (id[0] !== '.' && id[0] !== '/' && !(0, node_path_1.isAbsolute)(id)) {
50
+ return;
51
+ }
52
+ resolved = (0, path_1.ensureUnixPath)((0, node_path_1.resolve)((0, node_path_1.dirname)(importer), id));
65
53
  }
66
- if (!importer) {
67
- return;
54
+ else {
55
+ resolved = (0, path_1.ensureUnixPath)(id);
68
56
  }
69
- const resolved = (0, path_1.ensureUnixPath)((0, node_path_1.resolve)((0, node_path_1.dirname)(importer), potentialId));
70
57
  if (fileCache.has(resolved)) {
71
58
  return resolved;
72
59
  }
60
+ const ext = (0, node_path_1.extname)(resolved);
61
+ const base = resolved.slice(0, -ext.length);
62
+ if (dtsMode) {
63
+ let potential;
64
+ switch (ext) {
65
+ case '.js':
66
+ case '.ts':
67
+ potential = `${base}.d.ts`;
68
+ break;
69
+ case '.mjs':
70
+ case '.mts':
71
+ potential = `${base}.d.mts`;
72
+ break;
73
+ case '.cjs':
74
+ case '.cts':
75
+ potential = `${base}.d.cts`;
76
+ break;
77
+ }
78
+ if (potential && fileCache.has(potential)) {
79
+ return potential;
80
+ }
81
+ }
82
+ else {
83
+ let potential;
84
+ switch (ext) {
85
+ case '.ts':
86
+ potential = `${base}.js`;
87
+ break;
88
+ case '.mts':
89
+ potential = `${base}.mjs`;
90
+ break;
91
+ case '.cts':
92
+ potential = `${base}.cjs`;
93
+ break;
94
+ }
95
+ if (potential && fileCache.has(potential)) {
96
+ return potential;
97
+ }
98
+ }
73
99
  for (const suffix of resolutionExtensions) {
74
100
  const potential = resolved + suffix;
75
101
  if (fileCache.has(potential)) {
@@ -1 +1 @@
1
- {"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,4CAoDC;AAnED,yCAA6C;AAI7C,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B,EAAE,oBAA8B,EAAE,OAAgB;IAC3G,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ;YAC/B,MAAM,YAAY,GAAG,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC;YACxC,IAAI,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,OAAO,YAAY,CAAC;YACtB,CAAC;YAED,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAChD,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;oBACnD,IAAI,OAAO,EAAE,CAAC;wBACZ,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;oBACrC,CAAC;oBAED,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;gBACjC,CAAC,CAAC,CAAC;YAEP,IAAI,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,OAAO,WAAW,CAAC;YACrB,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,WAAW,CAAC,CAAC,CAAC;YACzE,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,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/B,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,EAAE,MAAM,CAAC,EAAE,OAAO;aACzC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dirname, resolve } from 'node:path';\nimport type { Plugin } from 'rolldown';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * A regex used to strip the file extension from a file path.\n */\nconst FILE_EXT_REGEXP = /\\.(c|m)?(t|j)s$/;\n\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache, resolutionExtensions: string[], dtsMode: boolean): Plugin {\n return {\n name: 'file-loader',\n resolveId: function (id, importer) {\n const normalizedId = ensureUnixPath(id);\n if (fileCache.has(normalizedId)) {\n return normalizedId;\n }\n\n const potentialId = normalizedId.endsWith('.d.ts')\n ? normalizedId\n : normalizedId.replace(FILE_EXT_REGEXP, (_match, p1) => {\n if (dtsMode) {\n return p1 ? `.d.${p1}ts` : '.d.ts';\n }\n\n return p1 ? `.${p1}js` : '.js';\n });\n\n if (fileCache.has(potentialId)) {\n return potentialId;\n }\n\n if (!importer) {\n return;\n }\n\n const resolved = ensureUnixPath(resolve(dirname(importer), potentialId));\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 data = fileCache.get(id);\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(`${id}.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,4CAgFC;AA1FD,yCAAkE;AAIlE,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B,EAAE,oBAA8B,EAAE,OAAgB;IAC3G,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ;YAC/B,IAAI,QAAgB,CAAC;YACrB,IAAI,QAAQ,EAAE,CAAC;gBACb,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAA,sBAAU,EAAC,EAAE,CAAC,EAAE,CAAC;oBACtD,OAAO;gBACT,CAAC;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K,MAAM;wBACT,SAAS,GAAG,GAAG,IAAI,MAAM,CAAC;wBAC1B,MAAM;gBACV,CAAC;gBAED,IAAI,SAAS,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC1C,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,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,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/B,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,EAAE,MAAM,CAAC,EAAE,OAAO;aACzC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dirname, extname, isAbsolute, resolve } from 'node:path';\nimport type { Plugin } from 'rolldown';\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 its map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache, resolutionExtensions: string[], dtsMode: boolean): Plugin {\n return {\n name: 'file-loader',\n resolveId: function (id, importer) {\n let resolved: string;\n if (importer) {\n if (id[0] !== '.' && id[0] !== '/' && !isAbsolute(id)) {\n return;\n }\n\n resolved = ensureUnixPath(resolve(dirname(importer), id));\n } else {\n resolved = ensureUnixPath(id);\n }\n\n if (fileCache.has(resolved)) {\n return resolved;\n }\n\n const ext = extname(resolved);\n const base = resolved.slice(0, -ext.length);\n if (dtsMode) {\n let potential: string | undefined;\n switch (ext) {\n case '.js':\n case '.ts':\n potential = `${base}.d.ts`;\n break;\n case '.mjs':\n case '.mts':\n potential = `${base}.d.mts`;\n break;\n case '.cjs':\n case '.cts':\n potential = `${base}.d.cts`;\n break;\n }\n\n if (potential && fileCache.has(potential)) {\n return potential;\n }\n } else {\n let potential: string | undefined;\n switch (ext) {\n case '.ts':\n potential = `${base}.js`;\n break;\n case '.mts':\n potential = `${base}.mjs`;\n break;\n case '.cts':\n potential = `${base}.cjs`;\n break;\n }\n\n if (potential && fileCache.has(potential)) {\n return potential;\n }\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 data = fileCache.get(id);\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(`${id}.map`)?.content,\n };\n },\n };\n}\n"]}
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.rolldownBundleFile = rolldownBundleFile;
37
- const path = __importStar(require("path"));
37
+ const path = __importStar(require("node:path"));
38
38
  const rolldown_1 = require("rolldown");
39
39
  const rolldown_plugin_dts_1 = require("rolldown-plugin-dts");
40
40
  const log = __importStar(require("../utils/log"));
@@ -104,13 +104,7 @@ async function rolldownBundleFile(opts) {
104
104
  // Close the bundle to let plugins clean up their external processes or services
105
105
  await bundle.close();
106
106
  return {
107
- files: output.output.map(f => {
108
- /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
109
- if (f.type === 'chunk') {
110
- Object.defineProperty(f, 'map', { value: null, configurable: true });
111
- }
112
- return f;
113
- }),
107
+ files: output.output,
114
108
  };
115
109
  }
116
110
  function isExternalDependency(moduleId, parentId, jail) {
@@ -1 +1 @@
1
- {"version":3,"file":"rolldown.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rolldown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,gDA8EC;AApGD,2CAA6B;AAC7B,uCAAmG;AACnG,6DAA0C;AAE1C,kDAAoC;AACpC,6DAAwD;AAgBxD,qEAAqE;AAC9D,KAAK,UAAU,kBAAkB,CAAC,IAAqB;IAC5D,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,YAAoB,CAAC;IACzB,IAAI,OAA+B,CAAC;IACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,OAAO,EAAE,CAAC;QACZ,YAAY,GAAG,OAAO,CAAC;QACvB,OAAO,GAAG;YACR,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC;YACnE,IAAA,yBAAG,EAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;SACrD,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,MAAM,CAAC;QACtB,OAAO,GAAG,CAAC,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC;QAC5B,OAAO,EAAE,MAAM;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C,EAAE;YAC3B,wGAAwG;YACxG,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACvB,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YACvE,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB,EAAE,QAA4B,EAAE,IAAY;IACxF,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,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as path from 'path';\nimport { type OutputAsset, type OutputChunk, type RolldownPluginOption, rolldown } from 'rolldown';\nimport { dts } from 'rolldown-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\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 rolldown.\n */\nexport interface RolldownOptions {\n moduleName: string;\n entry: string;\n entryName: string;\n dir: string;\n fileCache: OutputFileCache;\n sourcemap: boolean;\n}\n\n/** Runs rolldown over the given entry file, writes a bundle file. */\nexport async function rolldownBundleFile(opts: RolldownOptions): Promise<{ files: (OutputChunk | OutputAsset)[] }> {\n log.debug(`rolldown ${opts.entry} to ${opts.dir}`);\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: RolldownPluginOption[];\n const jail = path.dirname(opts.entry);\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [\n fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode),\n dts({ generator: 'oxc', sourcemap: opts.sourcemap }),\n ];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js'], dtsMode)];\n }\n\n // Create the bundle\n const bundle = await rolldown({\n context: 'this',\n external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),\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 experimental: {\n attachDebugInfo: 'none',\n },\n resolve: {\n symlinks: false,\n },\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 hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n comments: {\n legal: true,\n annotation: true,\n jsdoc: dtsMode,\n },\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 Object.defineProperty(f, 'map', { value: null, configurable: true });\n }\n\n return f;\n }),\n };\n}\n\nfunction isExternalDependency(moduleId: string, parentId: string | undefined, 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 !parentId || !path.join(parentId, moduleId).startsWith(jail);\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"rolldown.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rolldown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,gDAuEC;AA7FD,gDAAkC;AAClC,uCAAmG;AACnG,6DAA0C;AAE1C,kDAAoC;AACpC,6DAAwD;AAgBxD,qEAAqE;AAC9D,KAAK,UAAU,kBAAkB,CAAC,IAAqB;IAC5D,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,YAAoB,CAAC;IACzB,IAAI,OAA+B,CAAC;IACpC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAI,OAAO,EAAE,CAAC;QACZ,YAAY,GAAG,OAAO,CAAC;QACvB,OAAO,GAAG;YACR,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC;YACnE,IAAA,yBAAG,EAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;SACrD,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,MAAM,CAAC;QACtB,OAAO,GAAG,CAAC,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC;QAC5B,OAAO,EAAE,MAA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AED,SAAS,oBAAoB,CAAC,QAAgB,EAAE,QAA4B,EAAE,IAAY;IACxF,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,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { type OutputAsset, type OutputChunk, type RolldownPluginOption, rolldown } from 'rolldown';\nimport { dts } from 'rolldown-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\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 rolldown.\n */\nexport interface RolldownOptions {\n moduleName: string;\n entry: string;\n entryName: string;\n dir: string;\n fileCache: OutputFileCache;\n sourcemap: boolean;\n}\n\n/** Runs rolldown over the given entry file, writes a bundle file. */\nexport async function rolldownBundleFile(opts: RolldownOptions): Promise<{ files: (OutputChunk | OutputAsset)[] }> {\n log.debug(`rolldown ${opts.entry} to ${opts.dir}`);\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: RolldownPluginOption[];\n const jail = path.dirname(opts.entry);\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [\n fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode),\n dts({ generator: 'oxc', sourcemap: opts.sourcemap }),\n ];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js'], dtsMode)];\n }\n\n // Create the bundle\n const bundle = await rolldown({\n context: 'this',\n external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),\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 experimental: {\n attachDebugInfo: 'none',\n },\n resolve: {\n symlinks: false,\n },\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 hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n comments: {\n legal: true,\n annotation: true,\n jsdoc: dtsMode,\n },\n });\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n files: output.output,\n };\n}\n\nfunction isExternalDependency(moduleId: string, parentId: string | undefined, 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 !parentId || !path.join(parentId, moduleId).startsWith(jail);\n }\n\n return true;\n}\n"]}
@@ -1,103 +1,211 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.analyseSourcesTransform = void 0;
7
- const path_1 = require("path");
40
+ const fs = __importStar(require("node:fs"));
41
+ const node_path_1 = require("node:path");
8
42
  const rxjs_1 = require("rxjs");
9
43
  const typescript_1 = __importDefault(require("typescript"));
10
44
  const node_1 = require("../../graph/node");
11
- const cache_compiler_host_1 = require("../../ts/cache-compiler-host");
12
45
  const log_1 = require("../../utils/log");
13
- const path_2 = require("../../utils/path");
46
+ const path_1 = require("../../utils/path");
14
47
  const nodes_1 = require("../nodes");
15
48
  exports.analyseSourcesTransform = (0, rxjs_1.pipe)((0, rxjs_1.map)(graph => {
16
49
  const entryPoints = graph.filter(nodes_1.isEntryPoint);
50
+ const entryPointsMapped = new Map(entryPoints.map(ep => [ep.data.entryPoint.moduleId, ep]));
51
+ const packageNode = (0, nodes_1.findPackageNode)(graph);
52
+ const primaryModuleId = packageNode.data.primary.moduleId;
17
53
  for (const entryPoint of entryPoints) {
18
54
  if (entryPoint.state !== node_1.STATE_DONE) {
19
- analyseEntryPoint(graph, entryPoint, entryPoints);
55
+ analyseEntryPoint(entryPoint, entryPointsMapped, primaryModuleId);
20
56
  }
21
57
  }
22
58
  return graph;
23
59
  }));
60
+ const JS_TO_TS_EXTENSIONS = {
61
+ '.js': ['.ts', '.tsx', '.d.ts'],
62
+ '.mjs': ['.mts', '.d.mts'],
63
+ '.cjs': ['.cts', '.d.cts'],
64
+ };
65
+ const RESOLUTION_EXTENSIONS = [
66
+ '.ts',
67
+ '.tsx',
68
+ '.mts',
69
+ '.cts',
70
+ '.d.ts',
71
+ '.d.mts',
72
+ '.d.cts',
73
+ '/index.ts',
74
+ '/index.tsx',
75
+ '/index.mts',
76
+ '/index.cts',
77
+ '/index.d.ts',
78
+ '/index.d.mts',
79
+ '/index.d.cts',
80
+ '.js',
81
+ '.mjs',
82
+ '.cjs',
83
+ '/index.js',
84
+ '/index.mjs',
85
+ '/index.cjs',
86
+ ];
87
+ function checkFile(filePath, fileCache) {
88
+ const entry = fileCache.getOrCreate(filePath);
89
+ if (entry.exists === undefined) {
90
+ const stat = fs.statSync(filePath, { throwIfNoEntry: false });
91
+ if (stat?.isFile()) {
92
+ entry.exists = true;
93
+ }
94
+ else {
95
+ return false;
96
+ }
97
+ }
98
+ return entry.exists;
99
+ }
100
+ function resolveRelativeSourceFile(dir, moduleName, fileCache) {
101
+ const target = (0, node_path_1.resolve)(dir, moduleName);
102
+ if (target.includes('/node_modules/') || target.includes('\\node_modules\\')) {
103
+ return undefined;
104
+ }
105
+ const ext = (0, node_path_1.extname)(target);
106
+ const tsExtensions = JS_TO_TS_EXTENSIONS[ext];
107
+ if (tsExtensions) {
108
+ const base = target.slice(0, -ext.length);
109
+ for (const tsExt of tsExtensions) {
110
+ const candidate = base + tsExt;
111
+ if (checkFile(candidate, fileCache)) {
112
+ return (0, path_1.ensureUnixPath)(candidate);
113
+ }
114
+ }
115
+ }
116
+ if (checkFile(target, fileCache)) {
117
+ return (0, path_1.ensureUnixPath)(target);
118
+ }
119
+ for (const suffix of RESOLUTION_EXTENSIONS) {
120
+ const candidate = target + suffix;
121
+ if (checkFile(candidate, fileCache)) {
122
+ return (0, path_1.ensureUnixPath)(candidate);
123
+ }
124
+ }
125
+ return undefined;
126
+ }
24
127
  /**
25
- * Analyses an entrypoint, searching for TypeScript dependencies and additional resources (Templates and Stylesheets).
128
+ * Analyses an entrypoint, searching for TypeScript dependencies and internal package imports.
26
129
  *
27
- * @param graph Build graph
28
130
  * @param entryPoint Current entry point that should be analysed.
29
- * @param entryPoints List of all entry points.
131
+ * @param entryPointsMapped Map of all entry points by moduleId.
132
+ * @param primaryModuleId The moduleId of the primary entry point.
30
133
  */
31
- function analyseEntryPoint(graph, entryPoint, entryPoints) {
32
- const { oldPrograms, analysesSourcesFileCache, moduleResolutionCache } = entryPoint.cache;
33
- const oldProgram = oldPrograms && oldPrograms['analysis'];
34
- const { moduleId } = entryPoint.data.entryPoint;
35
- const packageNode = (0, nodes_1.findPackageNode)(graph);
36
- const primaryModuleId = packageNode.data.primary.moduleId;
134
+ function analyseEntryPoint(entryPoint, entryPointsMapped, primaryModuleId) {
135
+ const { analyseSourcesFileCache } = entryPoint.cache;
136
+ const { moduleId, entryFilePath } = entryPoint.data.entryPoint;
37
137
  (0, log_1.debug)(`Analysing sources for ${moduleId}`);
38
- const tsConfigOptions = {
39
- // Needed because of `Property 'extendedDiagnostics' is incompatible with index signature.`
40
- ...entryPoint.data.tsConfig.options,
41
- skipLibCheck: true,
42
- noLib: true,
43
- noEmit: true,
44
- types: [],
45
- target: typescript_1.default.ScriptTarget.Latest,
46
- strict: false,
47
- };
48
- const compilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, undefined, undefined, analysesSourcesFileCache);
138
+ // If an index file exists parallel to the entryFilePath it is not valid as index should be reserved as an
139
+ // entry file of an entry-point based on node resolution strategy.
140
+ if ((0, node_path_1.basename)(entryFilePath) !== 'index.ts') {
141
+ const potentialIndexPath = (0, node_path_1.join)((0, node_path_1.dirname)(entryFilePath), 'index.ts');
142
+ if (fs.existsSync(potentialIndexPath)) {
143
+ throw new Error(`Entry point '${moduleId}' has an 'index.ts' parallel to the 'entryFilePath'. ` +
144
+ `The 'entryFilePath' should be updated to point to the 'index.ts' file.\n` +
145
+ `Full path: ${potentialIndexPath}`);
146
+ }
147
+ }
148
+ // Remove previously discovered entry point dependencies in watch mode
149
+ for (const dep of entryPoint.dependents) {
150
+ if ((0, nodes_1.isEntryPoint)(dep)) {
151
+ dep.dependees.delete(entryPoint);
152
+ entryPoint.dependents.delete(dep);
153
+ }
154
+ }
49
155
  const potentialDependencies = new Set();
50
- compilerHost.resolveTypeReferenceDirectives = (moduleNames, containingFile, redirectedReference, options) => {
51
- return moduleNames.map(name => {
52
- const moduleName = typeof name === 'string' ? name : name.fileName;
53
- if (!moduleName.startsWith('.')) {
156
+ const filesToScan = [...(entryPoint.data.tsConfig?.rootNames ?? [entryFilePath])];
157
+ const visited = new Set();
158
+ while (filesToScan.length > 0) {
159
+ const file = filesToScan.pop();
160
+ if (!file) {
161
+ continue;
162
+ }
163
+ const currentFile = (0, path_1.ensureUnixPath)(file);
164
+ if (visited.has(currentFile)) {
165
+ continue;
166
+ }
167
+ visited.add(currentFile);
168
+ const fileEntry = analyseSourcesFileCache.getOrCreate(currentFile);
169
+ if (fileEntry.content === undefined) {
170
+ try {
171
+ fileEntry.content = fs.readFileSync(currentFile, 'utf-8');
172
+ fileEntry.exists = true;
173
+ }
174
+ catch {
175
+ continue;
176
+ }
177
+ }
178
+ const { importedFiles, typeReferenceDirectives, referencedFiles } = typescript_1.default.preProcessFile(fileEntry.content, true, // readImportFiles
179
+ true);
180
+ for (const ref of referencedFiles) {
181
+ const resolvedPath = resolveRelativeSourceFile((0, node_path_1.dirname)(currentFile), ref.fileName, analyseSourcesFileCache);
182
+ if (resolvedPath && !visited.has(resolvedPath)) {
183
+ filesToScan.push(resolvedPath);
184
+ }
185
+ }
186
+ for (const ref of [...importedFiles, ...typeReferenceDirectives]) {
187
+ const moduleName = ref.fileName;
188
+ if (moduleName[0] !== '.') {
54
189
  if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {
55
190
  potentialDependencies.add(moduleName);
56
191
  }
57
- return undefined;
58
192
  }
59
- const result = typescript_1.default.resolveTypeReferenceDirective(moduleName, (0, path_2.ensureUnixPath)(containingFile), options, compilerHost, redirectedReference).resolvedTypeReferenceDirective;
60
- return result;
61
- });
62
- };
63
- compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference, options) => {
64
- return moduleNames.map(moduleName => {
65
- if (!moduleName.startsWith('.')) {
66
- if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {
67
- potentialDependencies.add(moduleName);
193
+ else {
194
+ const resolvedPath = resolveRelativeSourceFile((0, node_path_1.dirname)(currentFile), moduleName, analyseSourcesFileCache);
195
+ if (resolvedPath && !visited.has(resolvedPath)) {
196
+ filesToScan.push(resolvedPath);
68
197
  }
69
- return undefined;
70
198
  }
71
- const { resolvedModule } = typescript_1.default.resolveModuleName(moduleName, (0, path_2.ensureUnixPath)(containingFile), options, compilerHost, moduleResolutionCache, redirectedReference);
72
- return resolvedModule;
73
- });
74
- };
75
- const program = typescript_1.default.createProgram(entryPoint.data.tsConfig.rootNames, tsConfigOptions, compilerHost, oldProgram);
76
- // If an index file exists parallel to the entryFilePath it is not valid as index should be reserved as an
77
- // entry file of an entry-point based on node resolution strategy.
78
- if ((0, path_1.basename)(entryPoint.data.entryPoint.entryFilePath) !== 'index.ts') {
79
- const potentialIndexPath = (0, path_1.join)((0, path_1.dirname)(entryPoint.data.entryPoint.entryFilePath), 'index.ts');
80
- const sf = program.getSourceFile((0, path_2.ensureUnixPath)(potentialIndexPath));
81
- if (sf) {
82
- throw new Error(`Entry point '${moduleId}' has an 'index.ts' parallel to the 'entryFilePath'. ` +
83
- `The 'entryFilePath' should be updated to point to the 'index.ts' file.\n` +
84
- `Full path: ${potentialIndexPath}`);
85
199
  }
86
200
  }
87
- (0, log_1.debug)(`tsc program structure is reused: ${oldProgram ? oldProgram.structureIsReused : 'No old program'}`);
88
- entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };
89
- const entryPointsMapped = {};
90
- for (const dep of entryPoints) {
91
- entryPointsMapped[dep.data.entryPoint.moduleId] = dep;
92
- }
93
201
  for (const moduleName of potentialDependencies) {
94
- const dep = entryPointsMapped[moduleName];
202
+ const dep = entryPointsMapped.get(moduleName);
95
203
  if (dep) {
96
204
  (0, log_1.debug)(`Found entry point dependency: ${moduleId} -> ${moduleName}`);
97
205
  if (moduleId === moduleName) {
98
206
  throw new Error(`Entry point ${moduleName} has a circular dependency on itself.`);
99
207
  }
100
- if (dep.some(n => entryPoint === n)) {
208
+ if (dep.dependents.has(entryPoint)) {
101
209
  throw new Error(`Entry point ${moduleName} has a circular dependency on ${moduleId}.`);
102
210
  }
103
211
  entryPoint.dependsOn(dep);
@@ -1 +1 @@
1
- {"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/analyse-sources.transform.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+C;AAC/C,+BAAiC;AACjC,4DAA4B;AAE5B,2CAA8C;AAE9C,sEAAiE;AACjE,yCAAwC;AACxC,2CAAkD;AAClD,oCAAyE;AAE5D,QAAA,uBAAuB,GAAc,IAAA,WAAI,EACpD,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;IACV,MAAM,WAAW,GAAqB,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IAEjE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,KAAK,KAAK,iBAAU,EAAE,CAAC;YACpC,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QACpD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IAAI,GAAG,EAAE,CAAC;YACR,IAAA,WAAK,EAAC,iCAAiC,QAAQ,OAAO,UAAU,EAAE,CAAC,CAAC;YAEpE,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;YACpF,CAAC;YAED,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,iCAAiC,QAAQ,GAAG,CAAC,CAAC;YACzF,CAAC;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,yBAAyB,QAAQ,iBAAiB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { basename, dirname, join } from 'path';\nimport { map, pipe } from 'rxjs';\nimport ts from 'typescript';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { STATE_DONE } from '../../graph/node';\nimport { Transform } from '../../graph/transform';\nimport { cacheCompilerHost } from '../../ts/cache-compiler-host';\nimport { debug } from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, findPackageNode, isEntryPoint } from '../nodes';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n\n for (const entryPoint of entryPoints) {\n if (entryPoint.state !== STATE_DONE) {\n analyseEntryPoint(graph, entryPoint, entryPoints);\n }\n }\n\n return graph;\n }),\n);\n\n/**\n * Analyses an entrypoint, searching for TypeScript dependencies and additional resources (Templates and Stylesheets).\n *\n * @param graph Build graph\n * @param entryPoint Current entry point that should be analysed.\n * @param entryPoints List of all entry points.\n */\nfunction analyseEntryPoint(graph: BuildGraph, entryPoint: EntryPointNode, entryPoints: EntryPointNode[]) {\n const { oldPrograms, analysesSourcesFileCache, moduleResolutionCache } = entryPoint.cache;\n const oldProgram = oldPrograms && (oldPrograms['analysis'] as ts.Program | undefined);\n const { moduleId } = entryPoint.data.entryPoint;\n const packageNode = findPackageNode(graph);\n const primaryModuleId = packageNode.data.primary.moduleId;\n\n debug(`Analysing sources for ${moduleId}`);\n const tsConfigOptions: ts.CompilerOptions = {\n // Needed because of `Property 'extendedDiagnostics' is incompatible with index signature.`\n ...(entryPoint.data.tsConfig.options as ts.CompilerOptions),\n skipLibCheck: true,\n noLib: true,\n noEmit: true,\n types: [],\n target: ts.ScriptTarget.Latest,\n strict: false,\n };\n\n const compilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n undefined,\n undefined,\n analysesSourcesFileCache,\n );\n\n const potentialDependencies = new Set<string>();\n\n compilerHost.resolveTypeReferenceDirectives = (\n moduleNames: string[] | ts.FileReference[],\n containingFile: string,\n redirectedReference: ts.ResolvedProjectReference | undefined,\n options: ts.CompilerOptions,\n ) => {\n return moduleNames.map(name => {\n const moduleName = typeof name === 'string' ? name : name.fileName;\n\n if (!moduleName.startsWith('.')) {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n\n return undefined;\n }\n\n const result = ts.resolveTypeReferenceDirective(\n moduleName,\n ensureUnixPath(containingFile),\n options,\n compilerHost,\n redirectedReference,\n ).resolvedTypeReferenceDirective;\n\n return result;\n });\n };\n\n compilerHost.resolveModuleNames = (\n moduleNames: string[],\n containingFile: string,\n _reusedNames: string[] | undefined,\n redirectedReference: ts.ResolvedProjectReference | undefined,\n options: ts.CompilerOptions,\n ) => {\n return moduleNames.map(moduleName => {\n if (!moduleName.startsWith('.')) {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n\n return undefined;\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n options,\n compilerHost,\n moduleResolutionCache,\n redirectedReference,\n );\n\n return resolvedModule;\n });\n };\n\n const program: ts.Program = ts.createProgram(\n entryPoint.data.tsConfig.rootNames,\n tsConfigOptions,\n compilerHost,\n oldProgram,\n );\n\n // If an index file exists parallel to the entryFilePath it is not valid as index should be reserved as an\n // entry file of an entry-point based on node resolution strategy.\n if (basename(entryPoint.data.entryPoint.entryFilePath) !== 'index.ts') {\n const potentialIndexPath = join(dirname(entryPoint.data.entryPoint.entryFilePath), 'index.ts');\n const sf = program.getSourceFile(ensureUnixPath(potentialIndexPath));\n\n if (sf) {\n throw new Error(\n `Entry point '${moduleId}' has an 'index.ts' parallel to the 'entryFilePath'. ` +\n `The 'entryFilePath' should be updated to point to the 'index.ts' file.\\n` +\n `Full path: ${potentialIndexPath}`,\n );\n }\n }\n\n debug(`tsc program structure is reused: ${oldProgram ? (oldProgram as any).structureIsReused : 'No old program'}`);\n\n entryPoint.cache.oldPrograms = { ...entryPoint.cache.oldPrograms, ['analysis']: program };\n\n const entryPointsMapped: Record<string, EntryPointNode> = {};\n for (const dep of entryPoints) {\n entryPointsMapped[dep.data.entryPoint.moduleId] = dep;\n }\n\n for (const moduleName of potentialDependencies) {\n const dep = entryPointsMapped[moduleName];\n\n if (dep) {\n debug(`Found entry point dependency: ${moduleId} -> ${moduleName}`);\n\n if (moduleId === moduleName) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on itself.`);\n }\n\n if (dep.some(n => entryPoint === n)) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on ${moduleId}.`);\n }\n\n entryPoint.dependsOn(dep);\n } else {\n throw new Error(`Entry point ${moduleName} which is required by ${moduleId} doesn't exist.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"analyse-sources.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/analyse-sources.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC;YAEpE,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,uCAAuC,CAAC,CAAC;YACpF,CAAC;YAED,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,iCAAiC,QAAQ,GAAG,CAAC,CAAC;YACzF,CAAC;YAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,yBAAyB,QAAQ,iBAAiB,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport { basename, dirname, extname, join, resolve } from 'node:path';\nimport { map, pipe } from 'rxjs';\nimport ts from 'typescript';\nimport { FileCache } from '../../file-system/file-cache';\nimport { STATE_DONE } from '../../graph/node';\nimport { Transform } from '../../graph/transform';\nimport { debug } from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, findPackageNode, isEntryPoint } from '../nodes';\n\nexport const analyseSourcesTransform: Transform = pipe(\n map(graph => {\n const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n const entryPointsMapped = new Map<string, EntryPointNode>(entryPoints.map(ep => [ep.data.entryPoint.moduleId, ep]));\n const packageNode = findPackageNode(graph);\n const primaryModuleId = packageNode.data.primary.moduleId;\n\n for (const entryPoint of entryPoints) {\n if (entryPoint.state !== STATE_DONE) {\n analyseEntryPoint(entryPoint, entryPointsMapped, primaryModuleId);\n }\n }\n\n return graph;\n }),\n);\n\nconst JS_TO_TS_EXTENSIONS: Readonly<Record<string, readonly string[]>> = {\n '.js': ['.ts', '.tsx', '.d.ts'],\n '.mjs': ['.mts', '.d.mts'],\n '.cjs': ['.cts', '.d.cts'],\n};\n\nconst RESOLUTION_EXTENSIONS: readonly string[] = [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.d.ts',\n '.d.mts',\n '.d.cts',\n '/index.ts',\n '/index.tsx',\n '/index.mts',\n '/index.cts',\n '/index.d.ts',\n '/index.d.mts',\n '/index.d.cts',\n '.js',\n '.mjs',\n '.cjs',\n '/index.js',\n '/index.mjs',\n '/index.cjs',\n];\n\nfunction checkFile(filePath: string, fileCache: FileCache): boolean {\n const entry = fileCache.getOrCreate(filePath);\n if (entry.exists === undefined) {\n const stat = fs.statSync(filePath, { throwIfNoEntry: false });\n if (stat?.isFile()) {\n entry.exists = true;\n } else {\n return false;\n }\n }\n\n return entry.exists;\n}\n\nfunction resolveRelativeSourceFile(dir: string, moduleName: string, fileCache: FileCache): string | undefined {\n const target = resolve(dir, moduleName);\n if (target.includes('/node_modules/') || target.includes('\\\\node_modules\\\\')) {\n return undefined;\n }\n\n const ext = extname(target);\n const tsExtensions = JS_TO_TS_EXTENSIONS[ext];\n if (tsExtensions) {\n const base = target.slice(0, -ext.length);\n for (const tsExt of tsExtensions) {\n const candidate = base + tsExt;\n if (checkFile(candidate, fileCache)) {\n return ensureUnixPath(candidate);\n }\n }\n }\n\n if (checkFile(target, fileCache)) {\n return ensureUnixPath(target);\n }\n\n for (const suffix of RESOLUTION_EXTENSIONS) {\n const candidate = target + suffix;\n if (checkFile(candidate, fileCache)) {\n return ensureUnixPath(candidate);\n }\n }\n\n return undefined;\n}\n\n/**\n * Analyses an entrypoint, searching for TypeScript dependencies and internal package imports.\n *\n * @param entryPoint Current entry point that should be analysed.\n * @param entryPointsMapped Map of all entry points by moduleId.\n * @param primaryModuleId The moduleId of the primary entry point.\n */\nfunction analyseEntryPoint(\n entryPoint: EntryPointNode,\n entryPointsMapped: Map<string, EntryPointNode>,\n primaryModuleId: string,\n) {\n const { analyseSourcesFileCache } = entryPoint.cache;\n const { moduleId, entryFilePath } = entryPoint.data.entryPoint;\n\n debug(`Analysing sources for ${moduleId}`);\n\n // If an index file exists parallel to the entryFilePath it is not valid as index should be reserved as an\n // entry file of an entry-point based on node resolution strategy.\n if (basename(entryFilePath) !== 'index.ts') {\n const potentialIndexPath = join(dirname(entryFilePath), 'index.ts');\n if (fs.existsSync(potentialIndexPath)) {\n throw new Error(\n `Entry point '${moduleId}' has an 'index.ts' parallel to the 'entryFilePath'. ` +\n `The 'entryFilePath' should be updated to point to the 'index.ts' file.\\n` +\n `Full path: ${potentialIndexPath}`,\n );\n }\n }\n\n // Remove previously discovered entry point dependencies in watch mode\n for (const dep of entryPoint.dependents) {\n if (isEntryPoint(dep)) {\n dep.dependees.delete(entryPoint);\n entryPoint.dependents.delete(dep);\n }\n }\n\n const potentialDependencies = new Set<string>();\n const filesToScan = [...(entryPoint.data.tsConfig?.rootNames ?? [entryFilePath])];\n const visited = new Set<string>();\n\n while (filesToScan.length > 0) {\n const file = filesToScan.pop();\n if (!file) {\n continue;\n }\n\n const currentFile = ensureUnixPath(file);\n if (visited.has(currentFile)) {\n continue;\n }\n visited.add(currentFile);\n\n const fileEntry = analyseSourcesFileCache.getOrCreate(currentFile);\n if (fileEntry.content === undefined) {\n try {\n fileEntry.content = fs.readFileSync(currentFile, 'utf-8');\n fileEntry.exists = true;\n } catch {\n continue;\n }\n }\n\n const { importedFiles, typeReferenceDirectives, referencedFiles } = ts.preProcessFile(\n fileEntry.content,\n true, // readImportFiles\n true, // detectJavaScriptImports\n );\n\n for (const ref of referencedFiles) {\n const resolvedPath = resolveRelativeSourceFile(dirname(currentFile), ref.fileName, analyseSourcesFileCache);\n if (resolvedPath && !visited.has(resolvedPath)) {\n filesToScan.push(resolvedPath);\n }\n }\n\n for (const ref of [...importedFiles, ...typeReferenceDirectives]) {\n const moduleName = ref.fileName;\n\n if (moduleName[0] !== '.') {\n if (moduleName === primaryModuleId || moduleName.startsWith(`${primaryModuleId}/`)) {\n potentialDependencies.add(moduleName);\n }\n } else {\n const resolvedPath = resolveRelativeSourceFile(dirname(currentFile), moduleName, analyseSourcesFileCache);\n if (resolvedPath && !visited.has(resolvedPath)) {\n filesToScan.push(resolvedPath);\n }\n }\n }\n }\n\n for (const moduleName of potentialDependencies) {\n const dep = entryPointsMapped.get(moduleName);\n\n if (dep) {\n debug(`Found entry point dependency: ${moduleId} -> ${moduleName}`);\n\n if (moduleId === moduleName) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on itself.`);\n }\n\n if (dep.dependents.has(entryPoint)) {\n throw new Error(`Entry point ${moduleName} has a circular dependency on ${moduleId}.`);\n }\n\n entryPoint.dependsOn(dep);\n } else {\n throw new Error(`Entry point ${moduleName} which is required by ${moduleId} doesn't exist.`);\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { NgPackageEntryConfig } from '../../../ng-entrypoint.schema';
2
2
  import { NgPackageConfig } from '../../../ng-package.schema';
3
- import { CssUrl } from '../../styles/stylesheet-processor';
3
+ import { CssUrl } from '../../styles/css-url.enum';
4
4
  /** A list of output absolute paths for various formats */
5
5
  export interface DestinationFiles {
6
6
  /** Absolute path of this entry point `declarations` */
@@ -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;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,CAA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AC;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"],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O,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACtE,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/css-url.enum';\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"]}
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeBundlesTransform = void 0;
7
+ const node_path_1 = require("node:path");
7
8
  const ora_1 = __importDefault(require("ora"));
8
- const path_1 = require("path");
9
9
  const file_watcher_1 = require("../../file-system/file-watcher");
10
10
  const rolldown_1 = require("../../flatten/rolldown");
11
11
  const transform_1 = require("../../graph/transform");
12
12
  const cache_1 = require("../../utils/cache");
13
13
  const fs_1 = require("../../utils/fs");
14
- const path_2 = require("../../utils/path");
14
+ const path_1 = require("../../utils/path");
15
15
  const nodes_1 = require("../nodes");
16
16
  const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
17
17
  const entryPoint = (0, nodes_1.findEntryPointInProgress)(graph);
@@ -31,11 +31,11 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
31
31
  const filesToCopy = [
32
32
  ...cacheResult.fesm2022.map(file => ({
33
33
  ...file,
34
- filePath: (0, path_1.join)(fesm2022Dir, file.fileName),
34
+ filePath: (0, node_path_1.join)(fesm2022Dir, file.fileName),
35
35
  })),
36
36
  ...cacheResult.types.map(file => ({
37
37
  ...file,
38
- filePath: (0, path_1.join)(declarationsDir, file.fileName),
38
+ filePath: (0, node_path_1.join)(declarationsDir, file.fileName),
39
39
  })),
40
40
  ];
41
41
  try {
@@ -81,23 +81,34 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
81
81
  sourcemap: tsConfig.options.declarationMap ?? false,
82
82
  }),
83
83
  ]);
84
+ const mapFile = (file) => file.type === 'chunk'
85
+ ? {
86
+ type: 'chunk',
87
+ fileName: file.fileName,
88
+ code: file.code,
89
+ }
90
+ : {
91
+ type: 'asset',
92
+ fileName: file.fileName,
93
+ source: file.source,
94
+ };
84
95
  return {
85
96
  hash,
86
- types: typesFiles,
87
- fesm2022: fesmFiles,
97
+ types: typesFiles.map(mapFile),
98
+ fesm2022: fesmFiles.map(mapFile),
88
99
  };
89
100
  }
90
- let cacheRollup;
101
+ let bundlesCache;
91
102
  try {
92
- cacheRollup = await generateBundles();
93
- spinner.succeed(`Generating FESM and DTS bundles`);
103
+ bundlesCache = await generateBundles();
104
+ spinner.succeed('Generating FESM and DTS bundles');
94
105
  // Invalidate dependent entry-points
95
106
  const changedDtsFiles = [];
96
- for (const file of cacheRollup.types) {
107
+ for (const file of bundlesCache.types) {
97
108
  if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {
98
109
  continue;
99
110
  }
100
- const dtsFile = (0, path_2.ensureUnixPath)((0, path_1.join)(declarationsDir, file.fileName));
111
+ const dtsFile = (0, path_1.ensureUnixPath)((0, node_path_1.join)(declarationsDir, file.fileName));
101
112
  const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);
102
113
  if (cachedSourceFile?.sourceFile?.text !== file.code) {
103
114
  changedDtsFiles.push(dtsFile);
@@ -112,7 +123,7 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
112
123
  throw error;
113
124
  }
114
125
  if (cacheDirectory) {
115
- await (0, cache_1.saveCacheEntry)(cacheDirectory, cacheKey, cacheRollup);
126
+ await (0, cache_1.saveCacheEntry)(cacheDirectory, cacheKey, bundlesCache);
116
127
  }
117
128
  });
118
129
  exports.writeBundlesTransform = writeBundlesTransform;
@@ -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,qDAA4D;AAC5D,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAAoD;AAS7C,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAG,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,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,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,C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BAwH7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk } from 'rolldown';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rolldownBundleFile } from '../../flatten/rolldown';\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 { findEntryPointInProgress } 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 = findEntryPointInProgress(graph);\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 [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([\n rolldownBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n fileCache: cache.outputCache,\n sourcemap: true,\n }),\n rolldownBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n fileCache: cache.outputCache,\n sourcemap: tsConfig.options.declarationMap ?? false,\n }),\n ]);\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","sour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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,YAAY,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC,CAAC;AArIQ,QAAA,qBAAqB,yBAqI7B","sourcesContent":["import { join } from 'node:path';\nimport ora from 'ora';\nimport type { OutputAsset, OutputChunk } from 'rolldown';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rolldownBundleFile } from '../../flatten/rolldown';\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 { findEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ntype CachedBundleFile =\n | {\n type: 'chunk';\n fileName: string;\n code: string;\n }\n | {\n type: 'asset';\n fileName: string;\n source: string | Uint8Array;\n };\n\ninterface BundlesCache {\n hash: string;\n fesm2022: CachedBundleFile[];\n types: CachedBundleFile[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint = findEntryPointInProgress(graph);\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 [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([\n rolldownBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n fileCache: cache.outputCache,\n sourcemap: true,\n }),\n rolldownBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n fileCache: cache.outputCache,\n sourcemap: tsConfig.options.declarationMap ?? false,\n }),\n ]);\n\n const mapFile = (file: OutputChunk | OutputAsset): CachedBundleFile =>\n file.type === 'chunk'\n ? {\n type: 'chunk',\n fileName: file.fileName,\n code: file.code,\n }\n : {\n type: 'asset',\n fileName: file.fileName,\n source: file.source,\n };\n\n return {\n hash,\n types: typesFiles.map(mapFile),\n fesm2022: fesmFiles.map(mapFile),\n };\n }\n\n let bundlesCache: BundlesCache;\n try {\n bundlesCache = 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 bundlesCache.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, bundlesCache);\n }\n });\n"]}
@@ -1,4 +1,4 @@
1
- import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';
1
+ import type { NgtscProgram, ParsedConfiguration } from '@angular/compiler-cli';
2
2
  import ts from 'typescript';
3
3
  import { FileCache } from '../file-system/file-cache';
4
4
  import { BuildGraph, ComplexPredicate } from '../graph/build-graph';
@@ -25,16 +25,16 @@ export declare class EntryPointNode extends Node {
25
25
  readonly url: string;
26
26
  readonly type = "application/ng-entry-point";
27
27
  constructor(url: string, sourcesFileCache: FileCache, moduleResolutionCache: ts.ModuleResolutionCache);
28
- cache: {
28
+ cache?: {
29
29
  outputCache: OutputFileCache;
30
- oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;
31
30
  sourcesFileCache: FileCache;
32
- analysesSourcesFileCache: FileCache;
31
+ analyseSourcesFileCache: FileCache;
33
32
  moduleResolutionCache: ts.ModuleResolutionCache;
34
33
  stylesheetProcessor?: StylesheetProcessor;
35
34
  oldNgtscProgram?: NgtscProgram;
36
35
  oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
37
36
  angularDiagnosticCache: AngularDiagnosticsCache;
37
+ declarationDiagnosticCache: AngularDiagnosticsCache;
38
38
  };
39
39
  data: {
40
40
  destinationFiles: DestinationFiles;
@@ -71,15 +71,16 @@ class EntryPointNode extends node_1.Node {
71
71
  this.url = url;
72
72
  this.cache = {
73
73
  sourcesFileCache,
74
- analysesSourcesFileCache: new file_cache_1.FileCache(),
74
+ analyseSourcesFileCache: new file_cache_1.FileCache(),
75
75
  moduleResolutionCache,
76
76
  outputCache: new Map(),
77
77
  angularDiagnosticCache: new angular_diagnostics_cache_1.AngularDiagnosticsCache(),
78
+ declarationDiagnosticCache: new angular_diagnostics_cache_1.AngularDiagnosticsCache(),
78
79
  };
79
80
  }
80
81
  cache;
81
82
  dispose() {
82
- this.cache.stylesheetProcessor?.destroy();
83
+ this.cache?.stylesheetProcessor?.destroy();
83
84
  this.cache = undefined;
84
85
  }
85
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAEC;AAED,8BAEC;AAED,oCAEC;AAED,wDAEC;AAED,kDAEC;AAED,4DAOC;AAED,0CAOC;AAED,0BAEC;AAED,kCAEC;AAED,sBAEC;AAnED,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA8D;AAC9D,gFAA2E;AAK3E,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAEzD,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,kCAAkC;AAClC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC,SAAgB,YAAY,CAAC,IAAU;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC;AAC3C,CAAC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC;AACvC,CAAC;AAED,SAAgB,YAAY;IAC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ID,MAAa,cAAe,SAAQ,WAAI;IAIpB;IAHT,IAAI,GAAG,mBAAmB,CAAC;IAEpC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QAJK,QAAG,GAAH,GAAG,CAAQ;QAM3B,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,wBAAwB,EAAE,IAAI,sBAAS,EAAE;YACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;YACtB,sBAAsB,EAAE,IAAI,mDAAuB,EAAE;SACtD,CAAC;IACJ,CAAC;IAED,KAAK,CAUH;IAQF,OAAO;QACL,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AAzCD,wCAyCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAC1B,IAAI,GAAG,eAAe,CAAC;IAGhC,KAAK,GAAG;QACN,gBAAgB,EAAE,IAAI,sBAAS,EAAE;QACjC,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7E,CAAC;CACH;AARD,kCAQC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph, ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isInProgress, isPending } from '../graph/select';\nimport { AngularDiagnosticsCache } from '../ngc/angular-diagnostics-cache';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\n\nconst TYPE_NG_PACKAGE = 'application/ng-package';\nconst TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nconst URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nconst URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isInProgress(n));\n}\n\nexport function isEntryPointPending(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isPending(n));\n}\n\nexport function findEntryPointInProgress(graph: BuildGraph): EntryPointNode {\n const entryPoint = graph.find(isEntryPointInProgress());\n if (!entryPoint) {\n throw new Error('Could not find entry point in progress');\n }\n\n return entryPoint;\n}\n\nexport function findPackageNode(graph: BuildGraph): PackageNode {\n const packageNode: PackageNode | undefined = graph.find(isPackage);\n if (!packageNode) {\n throw new Error('Could not find package node in build graph');\n }\n\n return packageNode;\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string | null {\n return url.startsWith(URL_PROTOCOL_FILE) ? url.slice(URL_PROTOCOL_FILE.length) : null;\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version?: string; content: string }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n analysesSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n angularDiagnosticCache: new AngularDiagnosticsCache(),\n };\n }\n\n cache: {\n outputCache: OutputFileCache;\n oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;\n sourcesFileCache: FileCache;\n analysesSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n angularDiagnosticCache: AngularDiagnosticsCache;\n };\n\n declare data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n\n dispose(): void {\n this.cache.stylesheetProcessor?.destroy();\n this.cache = undefined;\n }\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n declare data: NgPackage;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAEC;AAED,8BAEC;AAED,oCAEC;AAED,wDAEC;AAED,kDAEC;AAED,4DAOC;AAED,0CAOC;AAED,0BAEC;AAED,kCAEC;AAED,sBAEC;AAnED,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA8D;AAC9D,gFAA2E;AAK3E,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAEzD,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,kCAAkC;AAClC,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC,SAAgB,YAAY,CAAC,IAAU;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC;AAC3C,CAAC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC;AACvC,CAAC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,WAAE,EAA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I;IAIpB;IAHT,IAAI,GAAG,mBAAmB,CAAC;IAEpC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QAJK,QAAG,GAAH,GAAG,CAAQ;QAM3B,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,uBAAuB,EAAE,IAAI,sBAAS,EAAE;YACxC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;YACtB,sBAAsB,EAAE,IAAI,mDAAuB,EAAE;YACrD,0BAA0B,EAAE,IAAI,mDAAuB,EAAE;SAC1D,CAAC;IACJ,CAAC;IAED,KAAK,CAUH;IAQF,OAAO;QACL,IAAI,CAAC,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AA1CD,wCA0CC;AAED,MAAa,WAAY,SAAQ,WAAI;IAC1B,IAAI,GAAG,eAAe,CAAC;IAGhC,KAAK,GAAG;QACN,gBAAgB,EAAE,IAAI,sBAAS,EAAE;QACjC,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7E,CAAC;CACH;AARD,kCAQC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration } from '@angular/compiler-cli';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph, ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isInProgress, isPending } from '../graph/select';\nimport { AngularDiagnosticsCache } from '../ngc/angular-diagnostics-cache';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\n\nconst TYPE_NG_PACKAGE = 'application/ng-package';\nconst TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nconst URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nconst URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isInProgress(n));\n}\n\nexport function isEntryPointPending(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isPending(n));\n}\n\nexport function findEntryPointInProgress(graph: BuildGraph): EntryPointNode {\n const entryPoint = graph.find(isEntryPointInProgress());\n if (!entryPoint) {\n throw new Error('Could not find entry point in progress');\n }\n\n return entryPoint;\n}\n\nexport function findPackageNode(graph: BuildGraph): PackageNode {\n const packageNode: PackageNode | undefined = graph.find(isPackage);\n if (!packageNode) {\n throw new Error('Could not find package node in build graph');\n }\n\n return packageNode;\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string | null {\n return url.startsWith(URL_PROTOCOL_FILE) ? url.slice(URL_PROTOCOL_FILE.length) : null;\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version?: string; content: string }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n analyseSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n angularDiagnosticCache: new AngularDiagnosticsCache(),\n declarationDiagnosticCache: new AngularDiagnosticsCache(),\n };\n }\n\n cache?: {\n outputCache: OutputFileCache;\n sourcesFileCache: FileCache;\n analyseSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n angularDiagnosticCache: AngularDiagnosticsCache;\n declarationDiagnosticCache: AngularDiagnosticsCache;\n };\n\n declare data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n\n dispose(): void {\n this.cache?.stylesheetProcessor?.destroy();\n this.cache = undefined;\n }\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n declare data: NgPackage;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
@@ -134,19 +134,24 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, option
134
134
  // Must be done before creating transformers or getting template diagnostics
135
135
  await angularCompiler.analyzeAsync();
136
136
  // Collect source file specific diagnostics
137
- const angularDiagnosticCache = cache.angularDiagnosticCache;
137
+ const { angularDiagnosticCache, declarationDiagnosticCache } = cache;
138
138
  for (const sourceFile of builder.getSourceFiles()) {
139
139
  if (ignoreForDiagnostics.has(sourceFile)) {
140
140
  continue;
141
141
  }
142
- allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile),
143
- // We use the `typeScriptProgram` instead of `builder` here as a
144
- // performance workaround for: https://github.com/microsoft/TypeScript/issues/60970
145
- ...typeScriptProgram.getDeclarationDiagnostics(sourceFile));
146
- // Declaration files cannot have template diagnostics
142
+ allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));
143
+ // Declaration files cannot have declaration or template diagnostics
147
144
  if (sourceFile.isDeclarationFile) {
148
145
  continue;
149
146
  }
147
+ // Only request declaration diagnostics for affected or uncached files
148
+ if (affectedFiles.has(sourceFile) || !declarationDiagnosticCache.has(sourceFile)) {
149
+ // We use the `typeScriptProgram` instead of `builder` here as a
150
+ // performance workaround for: https://github.com/microsoft/TypeScript/issues/60970
151
+ const declarationDiagnostics = typeScriptProgram.getDeclarationDiagnostics(sourceFile);
152
+ declarationDiagnosticCache.update(sourceFile, declarationDiagnostics);
153
+ }
154
+ allDiagnostics.push(...declarationDiagnosticCache.get(sourceFile));
150
155
  // Only request Angular template diagnostics for affected files to avoid
151
156
  // overhead of template diagnostics for unchanged files.
152
157
  if (affectedFiles.has(sourceFile) || !angularDiagnosticCache.has(sourceFile)) {
@@ -172,6 +177,16 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, option
172
177
  throw new Error(formatDiagnostics(errorDiagnostics));
173
178
  }
174
179
  const transformers = angularCompiler.prepareEmit().transformers;
180
+ const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
181
+ if (sourceFiles) {
182
+ for (const sourceFile of sourceFiles) {
183
+ if (!sourceFile.isDeclarationFile) {
184
+ angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
185
+ }
186
+ }
187
+ }
188
+ tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
189
+ };
175
190
  if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {
176
191
  while (builder.emitNextAffectedFile((fileName, data, writeByteOrderMark, onError, sourceFiles) => {
177
192
  if (fileName.endsWith('.tsbuildinfo')) {
@@ -182,14 +197,13 @@ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, option
182
197
  }
183
198
  }
184
199
  for (const sourceFile of builder.getSourceFiles()) {
185
- if (ignoreForEmit.has(sourceFile)) {
200
+ if (sourceFile.isDeclarationFile || ignoreForEmit.has(sourceFile)) {
186
201
  continue;
187
202
  }
188
203
  if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {
189
204
  continue;
190
205
  }
191
- builder.emit(sourceFile, undefined, undefined, undefined, transformers);
192
- angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
206
+ builder.emit(sourceFile, writeFile, undefined, undefined, transformers);
193
207
  }
194
208
  }
195
209
  //# sourceMappingURL=compile-source-files.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":["../../../../src/lib/ngc/compile-source-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gDA+MC;AAxND,yCAAiC;AACjC,4DAA4B;AAE5B,+CAAgF;AAGhF,mEAA4F;AAC5F,kDAAoC;AAE7B,KAAK,UAAU,kBAAkB,CACtC,KAAiB,EACjB,QAA6B,EAC7B,qBAA+C,EAC/C,OAAyB,EACzB,YAAuC,EACvC,mBAAyC;IAEzC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,wDAAa,uBAAuB,GAAC,CAAC;IAClF,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,eAAe,GAAoB,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,YAAY,EAAE,CAAC;IAClF,MAAM,UAAU,GAAG,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,mBAAmB,GAAG,aAAa,CAAC,IAAI,CAAC,mBAAmB,CAAC;IAEnE,MAAM,QAAQ,GAAG,YAAY,IAAI,cAAc,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,eAAe,CAAC,WAAW,KAAK,IAAI,CAAC;QACrC,eAAe,CAAC,eAAe,KAAK,IAAA,gBAAI,EACtC,QAAQ,EACR,eAAe,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,cAAc,CACvE,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,IA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AQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;YACrF,CAAC;QACH,CAAC,CAAC,EACF,CAAC;YACD,QAAQ;QACV,CAAC;IACH,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAClD,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAClC,SAAS;QACX,CAAC;QAED,IAAI,eAAe,CAAC,sBAAsB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;YACtE,SAAS;QACX,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACxE,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC","sourcesContent":["import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { findEntryPointInProgress, findPackageNode } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport * as log from '../utils/log';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { NgtscProgram, formatDiagnostics } = await import('@angular/compiler-cli');\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint = findEntryPointInProgress(graph);\n const ngPackageNode = findPackageNode(graph);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n\n // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n }\n }\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n const angularDiagnosticCache = cache.angularDiagnosticCache;\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile)) {\n continue;\n }\n\n allDiagnostics.push(\n ...builder.getSyntacticDiagnostics(sourceFile),\n ...builder.getSemanticDiagnostics(sourceFile),\n // We use the `typeScriptProgram` instead of `builder` here as a\n // performance workaround for: https://github.com/microsoft/TypeScript/issues/60970\n ...typeScriptProgram.getDeclarationDiagnostics(sourceFile),\n );\n\n // Declaration files cannot have template diagnostics\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile) || !angularDiagnosticCache.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n angularDiagnosticCache.update(sourceFile, angularDiagnostics);\n }\n\n allDiagnostics.push(...angularDiagnosticCache.get(sourceFile));\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(otherDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (\n builder.emitNextAffectedFile((fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (fileName.endsWith('.tsbuildinfo')) {\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n }\n })\n ) {\n // empty\n }\n }\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, undefined, undefined, undefined, transformers);\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n}\n"]}
1
+ {"version":3,"file":"compile-source-files.js","sourceRoot":"","sources":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AAW,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;oBAClC,eAAe,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;gBAC1E,CAAC;YACH,CAAC;QACH,CAAC;QAED,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACrF,CAAC,CAAC;IAEF,IAAI,0CAA0C,IAAI,OAAO,EAAE,CAAC;QAC1D,OACE,OAAO,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE;YACxF,IAAI,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;gBACtC,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;YACrF,CAAC;QACH,CAAC,CAAC,EACF,CAAC;YACD,QAAQ;QACV,CAAC;IACH,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;QAClD,IAAI,UAAU,CAAC,iBAAiB,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAClE,SAAS;QACX,CAAC;QAED,IAAI,eAAe,CAAC,sBAAsB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;YACtE,SAAS;QACX,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC","sourcesContent":["import { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport { join } from 'node:path';\nimport ts from 'typescript';\nimport { BuildGraph } from '../graph/build-graph';\nimport { findEntryPointInProgress, findPackageNode } from '../ng-package/nodes';\nimport { NgPackagrOptions } from '../ng-package/options.di';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { augmentProgramWithVersioning, cacheCompilerHost } from '../ts/cache-compiler-host';\nimport * as log from '../utils/log';\n\nexport async function compileSourceFiles(\n graph: BuildGraph,\n tsConfig: ParsedConfiguration,\n moduleResolutionCache: ts.ModuleResolutionCache,\n options: NgPackagrOptions,\n extraOptions?: Partial<CompilerOptions>,\n stylesheetProcessor?: StylesheetProcessor,\n) {\n const { NgtscProgram, formatDiagnostics } = await import('@angular/compiler-cli');\n const { cacheDirectory, watch, cacheEnabled } = options;\n const tsConfigOptions: CompilerOptions = { ...tsConfig.options, ...extraOptions };\n const entryPoint = findEntryPointInProgress(graph);\n const ngPackageNode = findPackageNode(graph);\n const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;\n\n const cacheDir = cacheEnabled && cacheDirectory;\n if (cacheDir) {\n tsConfigOptions.incremental ??= true;\n tsConfigOptions.tsBuildInfoFile ??= join(\n cacheDir,\n `tsbuildinfo/${entryPoint.data.entryPoint.flatModuleFile}.tsbuildinfo`,\n );\n }\n\n const tsCompilerHost = cacheCompilerHost(\n graph,\n entryPoint,\n tsConfigOptions,\n moduleResolutionCache,\n stylesheetProcessor,\n inlineStyleLanguage,\n );\n\n const cache = entryPoint.cache;\n let usingBuildInfo = false;\n\n let oldBuilder = cache.oldBuilder;\n if (!oldBuilder && cacheDir) {\n oldBuilder = ts.readBuilderProgram(tsConfigOptions, tsCompilerHost);\n usingBuildInfo = true;\n }\n\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);\n\n const angularCompiler = angularProgram.compiler;\n const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;\n\n // SourceFile versions are required for builder programs.\n // The wrapped host inside NgtscProgram adds additional files that will not have versions.\n const typeScriptProgram = angularProgram.getTsProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n let builder: ts.BuilderProgram | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n if (watch || cacheDir) {\n builder = cache.oldBuilder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n tsCompilerHost,\n oldBuilder,\n );\n cache.oldNgtscProgram = angularProgram;\n } else {\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost);\n }\n\n // Update semantic diagnostics cache\n const affectedFiles = new Set<ts.SourceFile>();\n\n // Analyze affected files when in watch mode for incremental type checking\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (true) {\n const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, sourceFile => {\n // If the affected file is a TTC shim, add the shim's original source file.\n // This ensures that changes that affect TTC are typechecked even when the changes\n // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.\n // For example, changing @Input property types of a directive used in another component's\n // template.\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n\n return true;\n }\n\n return false;\n });\n\n if (!result) {\n break;\n }\n\n affectedFiles.add(result.affected as ts.SourceFile);\n }\n\n // Add all files with associated template type checking files.\n // Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.\n // To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build\n // info is present.\n if (usingBuildInfo) {\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {\n // This file name conversion relies on internal compiler logic and should be converted\n // to an official method when available. 15 is length of `.ngtypecheck.ts`\n const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';\n const originalSourceFile = builder.getSourceFile(originalFilename);\n if (originalSourceFile) {\n affectedFiles.add(originalSourceFile);\n }\n }\n }\n }\n }\n\n // Collect program level diagnostics\n const allDiagnostics: ts.Diagnostic[] = [\n ...angularCompiler.getOptionDiagnostics(),\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ];\n\n // Required to support asynchronous resource loading\n // Must be done before creating transformers or getting template diagnostics\n await angularCompiler.analyzeAsync();\n\n // Collect source file specific diagnostics\n const { angularDiagnosticCache, declarationDiagnosticCache } = cache;\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (ignoreForDiagnostics.has(sourceFile)) {\n continue;\n }\n\n allDiagnostics.push(...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));\n\n // Declaration files cannot have declaration or template diagnostics\n if (sourceFile.isDeclarationFile) {\n continue;\n }\n\n // Only request declaration diagnostics for affected or uncached files\n if (affectedFiles.has(sourceFile) || !declarationDiagnosticCache.has(sourceFile)) {\n // We use the `typeScriptProgram` instead of `builder` here as a\n // performance workaround for: https://github.com/microsoft/TypeScript/issues/60970\n const declarationDiagnostics = typeScriptProgram.getDeclarationDiagnostics(sourceFile);\n declarationDiagnosticCache.update(sourceFile, declarationDiagnostics);\n }\n\n allDiagnostics.push(...declarationDiagnosticCache.get(sourceFile));\n\n // Only request Angular template diagnostics for affected files to avoid\n // overhead of template diagnostics for unchanged files.\n if (affectedFiles.has(sourceFile) || !angularDiagnosticCache.has(sourceFile)) {\n const angularDiagnostics = angularCompiler.getDiagnosticsForFile(\n sourceFile,\n affectedFiles.size === 1 ? /** OptimizeFor.SingleFile **/ 0 : /** OptimizeFor.WholeProgram */ 1,\n );\n\n angularDiagnosticCache.update(sourceFile, angularDiagnostics);\n }\n\n allDiagnostics.push(...angularDiagnosticCache.get(sourceFile));\n }\n\n const otherDiagnostics = [];\n const errorDiagnostics = [];\n for (const diagnostic of allDiagnostics) {\n if (diagnostic.category === ts.DiagnosticCategory.Error) {\n errorDiagnostics.push(diagnostic);\n } else {\n otherDiagnostics.push(diagnostic);\n }\n }\n\n if (otherDiagnostics.length) {\n log.msg(formatDiagnostics(otherDiagnostics));\n }\n\n if (errorDiagnostics.length) {\n throw new Error(formatDiagnostics(errorDiagnostics));\n }\n\n const transformers = angularCompiler.prepareEmit().transformers;\n\n const writeFile: ts.WriteFileCallback = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (sourceFiles) {\n for (const sourceFile of sourceFiles) {\n if (!sourceFile.isDeclarationFile) {\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n }\n }\n\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n };\n\n if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {\n while (\n builder.emitNextAffectedFile((fileName, data, writeByteOrderMark, onError, sourceFiles) => {\n if (fileName.endsWith('.tsbuildinfo')) {\n tsCompilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);\n }\n })\n ) {\n // empty\n }\n }\n\n for (const sourceFile of builder.getSourceFiles()) {\n if (sourceFile.isDeclarationFile || ignoreForEmit.has(sourceFile)) {\n continue;\n }\n\n if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {\n continue;\n }\n\n builder.emit(sourceFile, writeFile, undefined, undefined, transformers);\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare enum CssUrl {
2
+ inline = "inline",
3
+ none = "none"
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CssUrl = void 0;
4
+ var CssUrl;
5
+ (function (CssUrl) {
6
+ CssUrl["inline"] = "inline";
7
+ CssUrl["none"] = "none";
8
+ })(CssUrl || (exports.CssUrl = CssUrl = {}));
9
+ //# sourceMappingURL=css-url.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-url.enum.js","sourceRoot":"","sources":["../../../../src/lib/styles/css-url.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB","sourcesContent":["export enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n"]}
@@ -1,9 +1,6 @@
1
1
  import { NgPackageEntryConfig } from '../../ng-entrypoint.schema';
2
2
  import { ComponentStylesheetBundler } from './component-stylesheets';
3
- export declare enum CssUrl {
4
- inline = "inline",
5
- none = "none"
6
- }
3
+ import { CssUrl } from './css-url.enum';
7
4
  export declare class StylesheetProcessor extends ComponentStylesheetBundler {
8
5
  protected readonly projectBasePath: string;
9
6
  protected readonly basePath: string;
@@ -3,15 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StylesheetProcessor = exports.CssUrl = void 0;
6
+ exports.StylesheetProcessor = void 0;
7
7
  const browserslist_1 = __importDefault(require("browserslist"));
8
8
  const component_stylesheets_1 = require("./component-stylesheets");
9
9
  const postcss_configuration_1 = require("./postcss-configuration");
10
- var CssUrl;
11
- (function (CssUrl) {
12
- CssUrl["inline"] = "inline";
13
- CssUrl["none"] = "none";
14
- })(CssUrl || (exports.CssUrl = CssUrl = {}));
15
10
  class StylesheetProcessor extends component_stylesheets_1.ComponentStylesheetBundler {
16
11
  projectBasePath;
17
12
  basePath;
@@ -1 +1 @@
1
- {"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAwC;AAExC,mEAAqE;AACrE,mEAAiH;AAEjH,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAED,MAAa,mBA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AwC;IACxC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzF,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEhD,iFAAiF;QACjF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,WAAW,GAAG,KAAK,CAAC;QACtB,CAAC;QAED,gFAAgF;QAChF,sFAAsF;QACtF,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,wBAAwB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9C,IAAI,WAAW,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACjD,2FAA2F;gBAC3F,0FAA0F;gBAC1F,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;YAED,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC","sourcesContent":["import browserslist from 'browserslist';\nimport { NgPackageEntryConfig } from '../../ng-entrypoint.schema';\nimport { ComponentStylesheetBundler } from './component-stylesheets';\nimport { generateSearchDirectories, getTailwindConfig, loadPostcssConfiguration } from './postcss-configuration';\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\nexport class StylesheetProcessor extends ComponentStylesheetBundler {\n constructor(\n protected readonly projectBasePath: string,\n protected readonly basePath: string,\n protected readonly cssUrl?: CssUrl,\n protected readonly includePaths?: string[],\n protected readonly sass?: NgPackageEntryConfig['lib']['sass'],\n protected readonly cacheDirectory?: string | false,\n protected readonly watch?: boolean,\n ) {\n browserslist.defaults = ['baseline widely available on 2026-05-07']\n const browserslistData = browserslist(undefined, { path: basePath });\n const searchDirs = generateSearchDirectories([projectBasePath]);\n const postcssConfiguration = loadPostcssConfiguration(searchDirs);\n\n super(\n {\n cacheDirectory: cacheDirectory,\n postcssConfiguration: postcssConfiguration,\n tailwindConfiguration: postcssConfiguration ? undefined : getTailwindConfig(searchDirs, projectBasePath),\n sass: sass as any,\n workspaceRoot: projectBasePath,\n cssUrl: cssUrl,\n target: transformSupportedBrowsersToTargets(browserslistData),\n includePaths: includePaths,\n },\n 'css',\n watch,\n );\n }\n\n destroy(): void {\n void super.dispose();\n }\n}\n\nfunction transformSupportedBrowsersToTargets(supportedBrowsers: string[]): string[] {\n const transformed: string[] = [];\n\n // https://esbuild.github.io/api/#target\n const esBuildSupportedBrowsers = new Set(['safari', 'firefox', 'edge', 'chrome', 'ios']);\n\n for (const browser of supportedBrowsers) {\n let [browserName, version] = browser.split(' ');\n\n // browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`\n if (browserName === 'ios_saf') {\n browserName = 'ios';\n }\n\n // browserslist uses ranges `15.2-15.3` versions but only the lowest is required\n // to perform minimum supported feature checks. esbuild also expects a single version.\n [version] = version.split('-');\n\n if (esBuildSupportedBrowsers.has(browserName)) {\n if (browserName === 'safari' && version === 'tp') {\n // esbuild only supports numeric versions so `TP` is converted to a high number (999) since\n // a Technology Preview (TP) of Safari is assumed to support all currently known features.\n version = '999';\n }\n\n transformed.push(browserName + version);\n }\n }\n\n return transformed.length ? transformed : undefined;\n}\n"]}
1
+ {"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAwC;AAExC,mEAAqE;AAErE,mEAAiH;AAEjH,MAAa,mBAAoB,SAAQ,kDAA0B;IAE5C;IACA;IACA;IACA;IACA;IACA;IACA;IAPrB,YACqB,eAAuB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AAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzF,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEhD,iFAAiF;QACjF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,WAAW,GAAG,KAAK,CAAC;QACtB,CAAC;QAED,gFAAgF;QAChF,sFAAsF;QACtF,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,wBAAwB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9C,IAAI,WAAW,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACjD,2FAA2F;gBAC3F,0FAA0F;gBAC1F,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;YAED,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC","sourcesContent":["import browserslist from 'browserslist';\nimport { NgPackageEntryConfig } from '../../ng-entrypoint.schema';\nimport { ComponentStylesheetBundler } from './component-stylesheets';\nimport { CssUrl } from './css-url.enum';\nimport { generateSearchDirectories, getTailwindConfig, loadPostcssConfiguration } from './postcss-configuration';\n\nexport class StylesheetProcessor extends ComponentStylesheetBundler {\n constructor(\n protected readonly projectBasePath: string,\n protected readonly basePath: string,\n protected readonly cssUrl?: CssUrl,\n protected readonly includePaths?: string[],\n protected readonly sass?: NgPackageEntryConfig['lib']['sass'],\n protected readonly cacheDirectory?: string | false,\n protected readonly watch?: boolean,\n ) {\n browserslist.defaults = ['baseline widely available on 2026-05-07'];\n const browserslistData = browserslist(undefined, { path: basePath });\n const searchDirs = generateSearchDirectories([projectBasePath]);\n const postcssConfiguration = loadPostcssConfiguration(searchDirs);\n\n super(\n {\n cacheDirectory: cacheDirectory,\n postcssConfiguration: postcssConfiguration,\n tailwindConfiguration: postcssConfiguration ? undefined : getTailwindConfig(searchDirs, projectBasePath),\n sass: sass as any,\n workspaceRoot: projectBasePath,\n cssUrl: cssUrl,\n target: transformSupportedBrowsersToTargets(browserslistData),\n includePaths: includePaths,\n },\n 'css',\n watch,\n );\n }\n\n destroy(): void {\n void super.dispose();\n }\n}\n\nfunction transformSupportedBrowsersToTargets(supportedBrowsers: string[]): string[] {\n const transformed: string[] = [];\n\n // https://esbuild.github.io/api/#target\n const esBuildSupportedBrowsers = new Set(['safari', 'firefox', 'edge', 'chrome', 'ios']);\n\n for (const browser of supportedBrowsers) {\n let [browserName, version] = browser.split(' ');\n\n // browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`\n if (browserName === 'ios_saf') {\n browserName = 'ios';\n }\n\n // browserslist uses ranges `15.2-15.3` versions but only the lowest is required\n // to perform minimum supported feature checks. esbuild also expects a single version.\n [version] = version.split('-');\n\n if (esBuildSupportedBrowsers.has(browserName)) {\n if (browserName === 'safari' && version === 'tp') {\n // esbuild only supports numeric versions so `TP` is converted to a high number (999) since\n // a Technology Preview (TP) of Safari is assumed to support all currently known features.\n version = '999';\n }\n\n transformed.push(browserName + version);\n }\n }\n\n return transformed.length ? transformed : undefined;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Plugin } from 'esbuild';
2
+ import { CssUrl } from '../css-url.enum';
2
3
  import { LoadResultCache } from '../load-result-cache';
3
- import { CssUrl } from '../stylesheet-processor';
4
4
  /**
5
5
  * Creates an esbuild {@link Plugin} that loads all CSS url token references using the
6
6
  * built-in esbuild `file` loader. A plugin is used to allow for all file extensions
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCssResourcePlugin = createCssResourcePlugin;
4
4
  const promises_1 = require("node:fs/promises");
5
5
  const node_path_1 = require("node:path");
6
+ const css_url_enum_1 = require("../css-url.enum");
6
7
  const load_result_cache_1 = require("../load-result-cache");
7
- const stylesheet_processor_1 = require("../stylesheet-processor");
8
8
  const CSS_RESOURCE_NAMESPACE = 'angular:css-resource';
9
9
  /**
10
10
  * Symbol marker used to indicate CSS resource resolution is being attempted.
@@ -39,7 +39,7 @@ function createCssResourcePlugin(url, cache) {
39
39
  }
40
40
  // If root-relative, absolute or protocol relative url, mark as external to leave the
41
41
  // path/URL in place.
42
- if (url !== stylesheet_processor_1.CssUrl.inline || /^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(resourceUrl)) {
42
+ if (url !== css_url_enum_1.CssUrl.inline || /^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(resourceUrl)) {
43
43
  return {
44
44
  path: resourceUrl,
45
45
  external: true,
@@ -1 +1 @@
1
- {"version":3,"file":"css-resource-plugin.js","sourceRoot":"","sources":["../../../../../src/lib/styles/stylesheets/css-resource-plugin.ts"],"names":[],"mappings":";;AAsBA,0DAiGC;AAtHD,+CAA4C;AAC5C,yCAAoD;AACpD,4DAAyE;AACzE,kEAAiD;AAEjD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,GAAW,EAAE,KAAuB;IAC1E,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,KAAK,CAAC,KAAkB;YACtB,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;gBAC7C,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;gBAE9E,kEAAkE;gBAClE,yEAAyE;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sourcesContent":["import type { Plugin, PluginBuild } from 'esbuild';\nimport { readFile } from 'node:fs/promises';\nimport { extname, join, relative } from 'node:path';\nimport { LoadResultCache, createCachedLoad } from '../load-result-cache';\nimport { CssUrl } from '../stylesheet-processor';\n\nconst CSS_RESOURCE_NAMESPACE = 'angular:css-resource';\n\n/**\n * Symbol marker used to indicate CSS resource resolution is being attempted.\n * This is used to prevent an infinite loop within the plugin's resolve hook.\n */\nconst CSS_RESOURCE_RESOLUTION = Symbol('CSS_RESOURCE_RESOLUTION');\n\n/**\n * Creates an esbuild {@link Plugin} that loads all CSS url token references using the\n * built-in esbuild `file` loader. A plugin is used to allow for all file extensions\n * and types to be supported without needing to manually specify all extensions\n * within the build configuration.\n *\n * @returns An esbuild {@link Plugin} instance.\n */\nexport function createCssResourcePlugin(url: CssUrl, cache?: LoadResultCache): Plugin {\n return {\n name: 'angular-css-resource',\n setup(build: PluginBuild): void {\n build.onResolve({ filter: /.*/ }, async args => {\n const { importer, path, kind, resolveDir, namespace, pluginData = {} } = args;\n\n // Only attempt to resolve url tokens which only exist inside CSS.\n // Also, skip this plugin if already attempting to resolve the url-token.\n if (kind !== 'url-token' || pluginData[CSS_RESOURCE_RESOLUTION]) {\n return null;\n }\n\n let [containingDir, resourceUrl] = path.split('||file:', 2);\n if (resourceUrl === undefined) {\n // This can happen due to early exit checks in rebasing-importer\n // logic such as when the url is an external URL.\n resourceUrl = containingDir;\n containingDir = '';\n }\n\n // If root-relative, absolute or protocol relative url, mark as external to leave the\n // path/URL in place.\n if (url !== CssUrl.inline || /^((?:\\w+:)?\\/\\/|data:|chrome:|#|\\/)/.test(resourceUrl)) {\n return {\n path: resourceUrl,\n external: true,\n };\n }\n\n pluginData[CSS_RESOURCE_RESOLUTION] = true;\n\n const result = await build.resolve(resourceUrl, {\n importer,\n kind,\n namespace,\n pluginData,\n resolveDir: join(resolveDir, containingDir),\n });\n\n if (result.errors.length) {\n const error = result.errors[0];\n if (resourceUrl[0] === '~') {\n error.notes = [\n {\n location: null,\n text: 'You can remove the tilde and use a relative path to reference it, which should remove this error.',\n },\n ];\n } else if (resourceUrl[0] === '^') {\n error.notes = [\n {\n location: null,\n text: 'You can remove the caret and use a relative path to reference it, which should remove this error.',\n },\n ];\n }\n\n const extension = importer && extname(importer);\n if (extension !== '.css') {\n error.notes.push({\n location: null,\n text: 'Preprocessor stylesheets may not show the exact file location of the error.',\n });\n }\n }\n\n // Return results that are not files since these are most likely specific to another plugin\n // and cannot be loaded by this plugin.\n if (result.namespace !== 'file') {\n return result;\n }\n\n // All file results are considered CSS resources and will be loaded via the file loader\n return {\n ...result,\n // Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).\n // This is only necessary for custom namespaces. esbuild will handle the file namespace.\n path: relative(build.initialOptions.absWorkingDir ?? '', result.path),\n namespace: CSS_RESOURCE_NAMESPACE,\n };\n });\n\n build.onLoad(\n { filter: /./, namespace: CSS_RESOURCE_NAMESPACE },\n createCachedLoad(cache, async args => {\n const resourcePath = join(build.initialOptions.absWorkingDir ?? '', args.path);\n\n return {\n contents: await readFile(resourcePath),\n loader: 'dataurl',\n watchFiles: [resourcePath],\n };\n }),\n );\n },\n };\n}\n"]}
1
+ {"version":3,"file":"css-resource-plugin.js","sourceRoot":"","sources":["../../../../../src/lib/styles/stylesheets/css-resource-plugin.ts"],"names":[],"mappings":";;AAsBA,0DAiGC;AAtHD,+CAA4C;AAC5C,yCAAoD;AACpD,kDAAyC;AACzC,4DAAyE;AAEzE,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,GAAW,EAAE,KAAuB;IAC1E,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,KAAK,CAAC,KAAkB;YACtB,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAC,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,IAAA,mBAAQ,EAAC,YAAY,CAAC;oBACtC,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE,CAAC,YAAY,CAAC;iBAC3B,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Plugin, PluginBuild } from 'esbuild';\nimport { readFile } from 'node:fs/promises';\nimport { extname, join, relative } from 'node:path';\nimport { CssUrl } from '../css-url.enum';\nimport { LoadResultCache, createCachedLoad } from '../load-result-cache';\n\nconst CSS_RESOURCE_NAMESPACE = 'angular:css-resource';\n\n/**\n * Symbol marker used to indicate CSS resource resolution is being attempted.\n * This is used to prevent an infinite loop within the plugin's resolve hook.\n */\nconst CSS_RESOURCE_RESOLUTION = Symbol('CSS_RESOURCE_RESOLUTION');\n\n/**\n * Creates an esbuild {@link Plugin} that loads all CSS url token references using the\n * built-in esbuild `file` loader. A plugin is used to allow for all file extensions\n * and types to be supported without needing to manually specify all extensions\n * within the build configuration.\n *\n * @returns An esbuild {@link Plugin} instance.\n */\nexport function createCssResourcePlugin(url: CssUrl, cache?: LoadResultCache): Plugin {\n return {\n name: 'angular-css-resource',\n setup(build: PluginBuild): void {\n build.onResolve({ filter: /.*/ }, async args => {\n const { importer, path, kind, resolveDir, namespace, pluginData = {} } = args;\n\n // Only attempt to resolve url tokens which only exist inside CSS.\n // Also, skip this plugin if already attempting to resolve the url-token.\n if (kind !== 'url-token' || pluginData[CSS_RESOURCE_RESOLUTION]) {\n return null;\n }\n\n let [containingDir, resourceUrl] = path.split('||file:', 2);\n if (resourceUrl === undefined) {\n // This can happen due to early exit checks in rebasing-importer\n // logic such as when the url is an external URL.\n resourceUrl = containingDir;\n containingDir = '';\n }\n\n // If root-relative, absolute or protocol relative url, mark as external to leave the\n // path/URL in place.\n if (url !== CssUrl.inline || /^((?:\\w+:)?\\/\\/|data:|chrome:|#|\\/)/.test(resourceUrl)) {\n return {\n path: resourceUrl,\n external: true,\n };\n }\n\n pluginData[CSS_RESOURCE_RESOLUTION] = true;\n\n const result = await build.resolve(resourceUrl, {\n importer,\n kind,\n namespace,\n pluginData,\n resolveDir: join(resolveDir, containingDir),\n });\n\n if (result.errors.length) {\n const error = result.errors[0];\n if (resourceUrl[0] === '~') {\n error.notes = [\n {\n location: null,\n text: 'You can remove the tilde and use a relative path to reference it, which should remove this error.',\n },\n ];\n } else if (resourceUrl[0] === '^') {\n error.notes = [\n {\n location: null,\n text: 'You can remove the caret and use a relative path to reference it, which should remove this error.',\n },\n ];\n }\n\n const extension = importer && extname(importer);\n if (extension !== '.css') {\n error.notes.push({\n location: null,\n text: 'Preprocessor stylesheets may not show the exact file location of the error.',\n });\n }\n }\n\n // Return results that are not files since these are most likely specific to another plugin\n // and cannot be loaded by this plugin.\n if (result.namespace !== 'file') {\n return result;\n }\n\n // All file results are considered CSS resources and will be loaded via the file loader\n return {\n ...result,\n // Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).\n // This is only necessary for custom namespaces. esbuild will handle the file namespace.\n path: relative(build.initialOptions.absWorkingDir ?? '', result.path),\n namespace: CSS_RESOURCE_NAMESPACE,\n };\n });\n\n build.onLoad(\n { filter: /./, namespace: CSS_RESOURCE_NAMESPACE },\n createCachedLoad(cache, async args => {\n const resourcePath = join(build.initialOptions.absWorkingDir ?? '', args.path);\n\n return {\n contents: await readFile(resourcePath),\n loader: 'dataurl',\n watchFiles: [resourcePath],\n };\n }),\n );\n },\n };\n}\n"]}