ng-packagr 22.1.0 → 22.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "22.1.0",
3
+ "version": "22.2.0-next.1",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -33,8 +33,6 @@
33
33
  "typings": "./src/public_api.d.ts",
34
34
  "dependencies": {
35
35
  "@ampproject/remapping": "^2.3.0",
36
- "@rollup/plugin-json": "^6.1.0",
37
- "@rollup/wasm-node": "^4.24.0",
38
36
  "ajv": "^8.17.1",
39
37
  "browserslist": "^4.26.0",
40
38
  "chokidar": "^5.0.0",
@@ -48,14 +46,12 @@
48
46
  "ora": "^9.0.0",
49
47
  "piscina": "^5.0.0",
50
48
  "postcss": "^8.4.47",
51
- "rollup-plugin-dts": "^6.4.0",
49
+ "rolldown": "^1.2.0",
50
+ "rolldown-plugin-dts": "^0.27.14",
52
51
  "rxjs": "^7.8.1",
53
52
  "sass": "^1.81.0",
54
53
  "tinyglobby": "^0.2.12"
55
54
  },
56
- "optionalDependencies": {
57
- "rollup": "^4.24.0"
58
- },
59
55
  "peerDependencies": {
60
56
  "@angular/compiler-cli": "^22.0.0 || ^22.1.0-next || ^22.2.0-next",
61
57
  "tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
@@ -1,4 +1,4 @@
1
- import type { Plugin } from 'rollup';
1
+ import type { Plugin } from 'rolldown';
2
2
  import { OutputFileCache } from '../ng-package/nodes';
3
3
  /**
4
4
  * Loads a file and it's map.
@@ -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,k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AAC;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 'rollup';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
@@ -0,0 +1,19 @@
1
+ import { type OutputAsset, type OutputChunk } from 'rolldown';
2
+ import { OutputFileCache } from '../ng-package/nodes';
3
+ /**
4
+ * Options used in `ng-packagr` for writing flat bundle files.
5
+ *
6
+ * These options are passed through to rolldown.
7
+ */
8
+ export interface RolldownOptions {
9
+ moduleName: string;
10
+ entry: string;
11
+ entryName: string;
12
+ dir: string;
13
+ fileCache: OutputFileCache;
14
+ sourcemap: boolean;
15
+ }
16
+ /** Runs rolldown over the given entry file, writes a bundle file. */
17
+ export declare function rolldownBundleFile(opts: RolldownOptions): Promise<{
18
+ files: (OutputChunk | OutputAsset)[];
19
+ }>;
@@ -32,40 +32,32 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.rollupBundleFile = rollupBundleFile;
40
- const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
36
+ exports.rolldownBundleFile = rolldownBundleFile;
41
37
  const path = __importStar(require("path"));
42
- const rollup_plugin_dts_1 = require("rollup-plugin-dts");
43
- const cache_1 = require("../utils/cache");
38
+ const rolldown_1 = require("rolldown");
39
+ const rolldown_plugin_dts_1 = require("rolldown-plugin-dts");
44
40
  const log = __importStar(require("../utils/log"));
45
41
  const file_loader_plugin_1 = require("./file-loader-plugin");
46
- let rollup;
47
- /** Runs rollup over the given entry file, writes a bundle file. */
48
- async function rollupBundleFile(opts) {
49
- await ensureRollup();
50
- log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
51
- const cacheDirectory = opts.cacheDirectory;
42
+ /** Runs rolldown over the given entry file, writes a bundle file. */
43
+ async function rolldownBundleFile(opts) {
44
+ log.debug(`rolldown ${opts.entry} to ${opts.dir}`);
52
45
  const dtsMode = opts.entry.endsWith('.d.ts');
53
46
  let outExtension;
54
47
  let plugins;
55
48
  const jail = path.dirname(opts.entry);
56
49
  if (dtsMode) {
57
50
  outExtension = '.d.ts';
58
- plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode), (0, rollup_plugin_dts_1.dts)({ sourcemap: opts.sourcemap })];
51
+ plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode), (0, rolldown_plugin_dts_1.dts)({ sourcemap: opts.sourcemap })];
59
52
  }
60
53
  else {
61
54
  outExtension = '.mjs';
62
- plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.js', '/index.js'], dtsMode), (0, plugin_json_1.default)()];
55
+ plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.js', '/index.js'], dtsMode)];
63
56
  }
64
57
  // Create the bundle
65
- const bundle = await rollup.rollup({
58
+ const bundle = await (0, rolldown_1.rolldown)({
66
59
  context: 'this',
67
60
  external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),
68
- cache: opts.cache ?? (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
69
61
  input: opts.entry,
70
62
  plugins,
71
63
  onwarn: warning => {
@@ -80,7 +72,9 @@ async function rollupBundleFile(opts) {
80
72
  break;
81
73
  }
82
74
  },
83
- preserveSymlinks: true,
75
+ resolve: {
76
+ symlinks: false,
77
+ },
84
78
  // Disable treeshaking when generating bundles
85
79
  // see: https://github.com/angular/angular/pull/32069
86
80
  treeshake: false,
@@ -90,50 +84,38 @@ async function rollupBundleFile(opts) {
90
84
  name: opts.moduleName,
91
85
  format: 'es',
92
86
  dir: opts.dir,
93
- importAttributesKey: 'with',
94
- inlineDynamicImports: false,
95
87
  hoistTransitiveImports: false,
96
88
  chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,
97
89
  entryFileNames: opts.entryName + outExtension,
98
90
  banner: '',
99
91
  sourcemap: opts.sourcemap,
92
+ comments: dtsMode
93
+ ? true
94
+ : {
95
+ legal: true,
96
+ annotation: true,
97
+ jsdoc: false,
98
+ },
100
99
  });
101
- if (cacheDirectory) {
102
- await (0, cache_1.saveCacheEntry)(cacheDirectory, opts.cacheKey, bundle.cache);
103
- }
104
100
  // Close the bundle to let plugins clean up their external processes or services
105
101
  await bundle.close();
106
102
  return {
107
103
  files: output.output.map(f => {
108
104
  /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
109
105
  if (f.type === 'chunk') {
110
- f.map = null;
106
+ Object.defineProperty(f, 'map', { value: null, configurable: true });
111
107
  }
112
108
  return f;
113
109
  }),
114
- cache: bundle.cache,
115
110
  };
116
111
  }
117
- async function ensureRollup() {
118
- if (rollup) {
119
- return;
120
- }
121
- try {
122
- rollup = await Promise.resolve().then(() => __importStar(require('rollup')));
123
- log.debug(`rollup using native version.`);
124
- }
125
- catch {
126
- rollup = await Promise.resolve().then(() => __importStar(require('@rollup/wasm-node')));
127
- log.debug(`rollup using wasm version.`);
128
- }
129
- }
130
112
  function isExternalDependency(moduleId, parentId, jail) {
131
113
  // more information about why we don't check for 'node_modules' path
132
114
  // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632
133
115
  if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {
134
116
  // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib
135
- return !path.join(parentId, moduleId).startsWith(jail);
117
+ return !parentId || !path.join(parentId, moduleId).startsWith(jail);
136
118
  }
137
119
  return true;
138
120
  }
139
- //# sourceMappingURL=rollup.js.map
121
+ //# sourceMappingURL=rolldown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rolldown.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rolldown.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,gDA0EC;AAhGD,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;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;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 = [fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode), dts({ sourcemap: opts.sourcemap })];\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 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: dtsMode\n ? true\n : {\n legal: true,\n annotation: true,\n jsdoc: false,\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"]}
@@ -7,7 +7,7 @@ exports.writeBundlesTransform = void 0;
7
7
  const ora_1 = __importDefault(require("ora"));
8
8
  const path_1 = require("path");
9
9
  const file_watcher_1 = require("../../file-system/file-watcher");
10
- const rollup_1 = require("../../flatten/rollup");
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");
@@ -63,32 +63,24 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
63
63
  }
64
64
  }
65
65
  async function generateBundles() {
66
- const [{ cache: rollupFESM2022Cache, files: fesmFiles }, { cache: rollupTypesCache, files: typesFiles }] = await Promise.all([
67
- (0, rollup_1.rollupBundleFile)({
66
+ const [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([
67
+ (0, rolldown_1.rolldownBundleFile)({
68
68
  entry: esm2022,
69
69
  entryName: ngEntryPoint.flatModuleFile,
70
70
  moduleName: ngEntryPoint.moduleId,
71
71
  dir: fesm2022Dir,
72
- cache: cache.rollupFESM2022Cache,
73
- cacheDirectory,
74
72
  fileCache: cache.outputCache,
75
- cacheKey,
76
73
  sourcemap: true,
77
74
  }),
78
- (0, rollup_1.rollupBundleFile)({
75
+ (0, rolldown_1.rolldownBundleFile)({
79
76
  entry: declarations,
80
77
  entryName: ngEntryPoint.flatModuleFile,
81
78
  moduleName: ngEntryPoint.moduleId,
82
79
  dir: declarationsDir,
83
- cache: cache.rollupTypesCache,
84
- cacheDirectory,
85
80
  fileCache: cache.outputCache,
86
- cacheKey,
87
81
  sourcemap: tsConfig.options.declarationMap ?? false,
88
82
  }),
89
83
  ]);
90
- cache.rollupFESM2022Cache = rollupFESM2022Cache;
91
- cache.rollupTypesCache = rollupTypesCache;
92
84
  return {
93
85
  hash,
94
86
  types: typesFiles,
@@ -1 +1 @@
1
- {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA4B;AAE5B,iEAA2F;AAC3F,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,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;QACj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O,GAAG,IAAA,qBAAc,EAAC,IAAA,WAAI,EAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrE,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7D,IAAI,gBAAgB,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACrD,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;YAC3B,IAAA,wDAAyC,EAAC,KAAK,EAAE,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,CAAC,CAAC;AAlIQ,QAAA,qBAAqB,yBAkI7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk } from 'rollup';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { 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 [{ cache: rollupFESM2022Cache, files: fesmFiles }, { cache: rollupTypesCache, files: typesFiles }] =\n await Promise.all([\n rollupBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n cache: cache.rollupFESM2022Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey,\n sourcemap: true,\n }),\n rollupBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n cache: cache.rollupTypesCache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey,\n sourcemap: tsConfig.options.declarationMap ?? false,\n }),\n ]);\n\n cache.rollupFESM2022Cache = rollupFESM2022Cache;\n cache.rollupTypesCache = rollupTypesCache;\n\n return {\n hash,\n types: typesFiles,\n fesm2022: fesmFiles,\n };\n }\n\n let cacheRollup: BundlesCache;\n try {\n cacheRollup = await generateBundles();\n spinner.succeed(`Generating FESM and DTS bundles`);\n\n // Invalidate dependent entry-points\n const changedDtsFiles: string[] = [];\n for (const file of cacheRollup.types) {\n if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {\n continue;\n }\n\n const dtsFile = ensureUnixPath(join(declarationsDir, file.fileName));\n const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);\n if (cachedSourceFile?.sourceFile?.text !== file.code) {\n changedDtsFiles.push(dtsFile);\n }\n }\n\n if (changedDtsFiles.length) {\n invalidateEntryPointsAndCacheOnFileChange(graph, changedDtsFiles, cache.sourcesFileCache);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, cacheRollup);\n }\n });\n"]}
1
+ {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA4B;AAE5B,iEAA2F;AAC3F,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,E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IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9D,SAAS;YACX,CAAC;YAED,MAAM,OAAO,GAAG,IAAA,qBAAc,EAAC,IAAA,WAAI,EAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrE,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7D,IAAI,gBAAgB,EAAE,UAAU,EAAE,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBACrD,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;YAC3B,IAAA,wDAAyC,EAAC,KAAK,EAAE,eAAe,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,CAAC,CAAC;AAxHQ,QAAA,qBAAqB,yBAwH7B","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,5 +1,4 @@
1
1
  import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';
2
- import type { RollupCache } from 'rollup';
3
2
  import ts from 'typescript';
4
3
  import { FileCache } from '../file-system/file-cache';
5
4
  import { BuildGraph, ComplexPredicate } from '../graph/build-graph';
@@ -32,8 +31,6 @@ export declare class EntryPointNode extends Node {
32
31
  sourcesFileCache: FileCache;
33
32
  analysesSourcesFileCache: FileCache;
34
33
  moduleResolutionCache: ts.ModuleResolutionCache;
35
- rollupFESM2022Cache?: RollupCache;
36
- rollupTypesCache?: RollupCache;
37
34
  stylesheetProcessor?: StylesheetProcessor;
38
35
  oldNgtscProgram?: NgtscProgram;
39
36
  oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAqBA,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,EAAC,YAAY,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,sBAAsB;IACpC,OAAO,IAAA,WAAE,EAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAA,qBAAY,EAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,mBAAmB;IACjC,OAAO,IAAA,WAAE,EAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAA,kBAAS,EAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,wBAAwB,CAAC,KAAiB;IACxD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,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C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AA3CD,wCA2CC;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 type { RollupCache } from 'rollup';\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 rollupFESM2022Cache?: RollupCache;\n rollupTypesCache?: RollupCache;\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,EAAC,YAAY,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,sBAAsB;IACpC,OAAO,IAAA,WAAE,EAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAA,qBAAY,EAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,mBAAmB;IACjC,OAAO,IAAA,WAAE,EAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAA,kBAAS,EAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,wBAAwB,CAAC,KAAiB;IACxD,MAAM,UAAU,GAAG,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,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,23 +0,0 @@
1
- import type { OutputAsset, OutputChunk, RollupCache } from 'rollup';
2
- import { OutputFileCache } from '../ng-package/nodes';
3
- /**
4
- * Options used in `ng-packagr` for writing flat bundle files.
5
- *
6
- * These options are passed through to rollup.
7
- */
8
- export interface RollupOptions {
9
- moduleName: string;
10
- entry: string;
11
- entryName: string;
12
- dir: string;
13
- cache?: RollupCache;
14
- cacheDirectory?: string | false;
15
- fileCache: OutputFileCache;
16
- cacheKey: string;
17
- sourcemap: boolean;
18
- }
19
- /** Runs rollup over the given entry file, writes a bundle file. */
20
- export declare function rollupBundleFile(opts: RollupOptions): Promise<{
21
- cache: RollupCache;
22
- files: (OutputChunk | OutputAsset)[];
23
- }>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,4CA8EC;AA3GD,sEAA6C;AAC7C,2CAA6B;AAE7B,yDAAwC;AAExC,0CAAgE;AAChE,kDAAoC;AACpC,6DAAwD;AAmBxD,IAAI,MAA2C,CAAC;AAEhD,mEAAmE;AAC5D,KAAK,UAAU,gBAAgB,CACpC,IAAmB;IAEnB,MAAM,YAAY,EAAE,CAAC;IAErB,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACtE,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,YAAoB,CAAC;IACzB,IAAI,OAA4B,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC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AC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC3C,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IAC5E,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport * as path from 'path';\nimport type { InputPluginOption, OutputAsset, OutputChunk, RollupCache } from 'rollup';\nimport { dts } from 'rollup-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { fileLoaderPlugin } from './file-loader-plugin';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n entryName: string;\n dir: string;\n cache?: RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n sourcemap: boolean;\n}\n\nlet rollup: typeof import('rollup') | undefined;\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: RollupCache; files: (OutputChunk | OutputAsset)[] }> {\n await ensureRollup();\n\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);\n const cacheDirectory = opts.cacheDirectory;\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: InputPluginOption[];\n const jail = path.dirname(opts.entry);\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode), dts({ sourcemap: opts.sourcemap })];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js'], dtsMode), rollupJson()];\n }\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins,\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n case 'EMPTY_BUNDLE':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n dir: opts.dir,\n importAttributesKey: 'with',\n inlineDynamicImports: false,\n hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, bundle.cache);\n }\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n files: output.output.map(f => {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n cache: bundle.cache,\n };\n}\n\nasync function ensureRollup(): Promise<void> {\n if (rollup) {\n return;\n }\n\n try {\n rollup = await import('rollup');\n log.debug(`rollup using native version.`);\n } catch {\n rollup = await import('@rollup/wasm-node');\n log.debug(`rollup using wasm version.`);\n }\n}\n\nfunction isExternalDependency(moduleId: string, parentId: string, jail: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return !path.join(parentId, moduleId).startsWith(jail);\n }\n\n return true;\n}\n"]}