ng-packagr 20.0.0-next.2 → 20.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/file-system/file-cache.d.ts +0 -1
- package/lib/file-system/file-cache.js.map +1 -1
- package/lib/flatten/file-loader-plugin.js +5 -3
- package/lib/flatten/file-loader-plugin.js.map +1 -1
- package/lib/flatten/rollup.d.ts +1 -0
- package/lib/flatten/rollup.js +14 -5
- package/lib/flatten/rollup.js.map +1 -1
- package/lib/graph/build-graph.js +5 -2
- package/lib/graph/build-graph.js.map +1 -1
- package/lib/graph/node.d.ts +2 -2
- package/lib/graph/node.js +2 -2
- package/lib/graph/node.js.map +1 -1
- package/lib/graph/select.d.ts +0 -1
- package/lib/graph/select.js +0 -4
- package/lib/graph/select.js.map +1 -1
- package/lib/ng-package/entry-point/entry-point.d.ts +4 -0
- package/lib/ng-package/entry-point/entry-point.js +5 -4
- package/lib/ng-package/entry-point/entry-point.js.map +1 -1
- package/lib/ng-package/entry-point/write-bundles.transform.js +89 -38
- package/lib/ng-package/entry-point/write-bundles.transform.js.map +1 -1
- package/lib/ng-package/entry-point/write-package.transform.js +2 -2
- package/lib/ng-package/entry-point/write-package.transform.js.map +1 -1
- package/lib/ng-package/nodes.d.ts +3 -10
- package/lib/ng-package/nodes.js +16 -22
- package/lib/ng-package/nodes.js.map +1 -1
- package/lib/ng-package/package.transform.js +62 -46
- package/lib/ng-package/package.transform.js.map +1 -1
- package/lib/styles/stylesheets/css-resource-plugin.js +17 -10
- package/lib/styles/stylesheets/css-resource-plugin.js.map +1 -1
- package/lib/ts/cache-compiler-host.js +7 -57
- package/lib/ts/cache-compiler-host.js.map +1 -1
- package/lib/ts/conf/tsconfig.ngc.json +3 -2
- package/lib/ts/tsconfig.js +3 -3
- package/lib/ts/tsconfig.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-cache.js","sourceRoot":"","sources":["../../../src/lib/file-system/file-cache.ts"],"names":[],"mappings":";;;AACA,wCAA+C;
|
|
1
|
+
{"version":3,"file":"file-cache.js","sourceRoot":"","sources":["../../../src/lib/file-system/file-cache.ts"],"names":[],"mappings":";;;AACA,wCAA+C;AAQ/C,MAAa,SAAS;IAAtB;QACU,UAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;QAEnD,YAAO,GACL,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,UAAK,GAAe,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAiCxD,CAAC;IA/BC,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,YAAY,CAAC,QAAgB;QAC3B,OAAO,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,QAAgB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,WAAW,CAAC,QAAgB;QAC1B,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAE1C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtCD,8BAsCC","sourcesContent":["import ts from 'typescript';\nimport { ensureUnixPath } from '../utils/path';\n\nexport interface CacheEntry {\n exists?: boolean;\n sourceFile?: ts.SourceFile;\n content?: string;\n}\n\nexport class FileCache {\n private cache: Map<string, CacheEntry> = new Map();\n\n forEach: (callbackfn: (value: CacheEntry, key: string, map: Map<string, CacheEntry>) => void, thisArg?: any) => void =\n this.cache.forEach.bind(this.cache);\n clear: () => void = this.cache.clear.bind(this.cache);\n\n size(): number {\n return this.cache.size;\n }\n\n normalizeKey(fileName: string): string {\n return ensureUnixPath(fileName);\n }\n\n delete(fileName: string): boolean {\n return this.cache.delete(this.normalizeKey(fileName));\n }\n\n has(fileName: string): boolean {\n return this.cache.has(this.normalizeKey(fileName));\n }\n\n get(fileName: string): CacheEntry | undefined {\n return this.cache.get(this.normalizeKey(fileName));\n }\n\n getOrCreate(fileName: string): CacheEntry {\n const normalizedKey = this.normalizeKey(fileName);\n let entry = this.cache.get(normalizedKey);\n\n if (!entry) {\n entry = {};\n this.cache.set(normalizedKey, entry);\n }\n\n return entry;\n }\n}\n"]}
|
|
@@ -37,7 +37,7 @@ exports.fileLoaderPlugin = fileLoaderPlugin;
|
|
|
37
37
|
const node_path_1 = require("node:path");
|
|
38
38
|
const log = __importStar(require("../utils/log"));
|
|
39
39
|
const path_1 = require("../utils/path");
|
|
40
|
-
const POTENTIAL_MATCHES = ['', '.
|
|
40
|
+
const POTENTIAL_MATCHES = ['', '.js', '/index.js', '.d.ts', '/index.d.ts'];
|
|
41
41
|
/**
|
|
42
42
|
* Loads a file and it's map.
|
|
43
43
|
*/
|
|
@@ -59,14 +59,16 @@ function fileLoaderPlugin(fileCache) {
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
load: function (id) {
|
|
62
|
+
var _a;
|
|
62
63
|
log.debug(`file-loader ${id}`);
|
|
63
|
-
const
|
|
64
|
+
const idPosix = (0, path_1.ensureUnixPath)(id);
|
|
65
|
+
const data = fileCache.get(idPosix);
|
|
64
66
|
if (!data) {
|
|
65
67
|
throw new Error(`Could not load '${id}' from memory.`);
|
|
66
68
|
}
|
|
67
69
|
return {
|
|
68
70
|
code: data.content,
|
|
69
|
-
map:
|
|
71
|
+
map: (_a = fileCache.get(`${idPosix}.map`)) === null || _a === void 0 ? void 0 : _a.content,
|
|
70
72
|
};
|
|
71
73
|
},
|
|
72
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,
|
|
1
|
+
{"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,4CAgCC;AA3CD,yCAA6C;AAI7C,kDAAoC;AACpC,wCAA+C;AAE/C,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;AAC3E;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B;IACzD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ;YAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACtC,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,QAAQ,GAAG,IAAA,qBAAc,EAAC,IAAA,mBAAO,EAAC,IAAA,mBAAO,EAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;gBAChE,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE,CAAC;oBACvC,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;oBACpC,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;wBAC7B,OAAO,SAAS,CAAC;oBACnB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,EAAE,UAAU,EAAE;;YAChB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC;YACnC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;YACzD,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,GAAG,EAAE,MAAA,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC,0CAAE,OAAO;aAC9C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dirname, resolve } from 'node:path';\nimport type { Plugin } from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\nconst POTENTIAL_MATCHES = ['', '.js', '/index.js', '.d.ts', '/index.d.ts'];\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache): Plugin {\n return {\n name: 'file-loader',\n resolveId: function (id, importer) {\n if (fileCache.has(ensureUnixPath(id))) {\n return id;\n }\n\n if (importer) {\n const resolved = ensureUnixPath(resolve(dirname(importer), id));\n for (const suffix of POTENTIAL_MATCHES) {\n const potential = resolved + suffix;\n if (fileCache.has(potential)) {\n return potential;\n }\n }\n }\n },\n load: function (id) {\n log.debug(`file-loader ${id}`);\n const idPosix = ensureUnixPath(id);\n const data = fileCache.get(idPosix);\n if (!data) {\n throw new Error(`Could not load '${id}' from memory.`);\n }\n\n return {\n code: data.content,\n map: fileCache.get(`${idPosix}.map`)?.content,\n };\n },\n };\n}\n"]}
|
package/lib/flatten/rollup.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface RollupOptions {
|
|
|
14
14
|
cacheDirectory?: string | false;
|
|
15
15
|
fileCache: OutputFileCache;
|
|
16
16
|
cacheKey: string;
|
|
17
|
+
sourcemap: boolean;
|
|
17
18
|
}
|
|
18
19
|
/** Runs rollup over the given entry file, writes a bundle file. */
|
|
19
20
|
export declare function rollupBundleFile(opts: RollupOptions): Promise<{
|
package/lib/flatten/rollup.js
CHANGED
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.rollupBundleFile = rollupBundleFile;
|
|
40
40
|
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
|
+
const rollup_plugin_dts_1 = require("rollup-plugin-dts");
|
|
42
43
|
const cache_1 = require("../utils/cache");
|
|
43
44
|
const log = __importStar(require("../utils/log"));
|
|
44
45
|
const file_loader_plugin_1 = require("./file-loader-plugin");
|
|
@@ -48,6 +49,8 @@ async function rollupBundleFile(opts) {
|
|
|
48
49
|
var _a;
|
|
49
50
|
await ensureRollup();
|
|
50
51
|
log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
|
|
52
|
+
const dtsMode = opts.entry.endsWith('.d.ts');
|
|
53
|
+
const outExtension = dtsMode ? '.d.ts' : '.mjs';
|
|
51
54
|
const cacheDirectory = opts.cacheDirectory;
|
|
52
55
|
// Create the bundle
|
|
53
56
|
const bundle = await rollup.rollup({
|
|
@@ -55,7 +58,7 @@ async function rollupBundleFile(opts) {
|
|
|
55
58
|
external: moduleId => isExternalDependency(moduleId),
|
|
56
59
|
cache: (_a = opts.cache) !== null && _a !== void 0 ? _a : (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
|
|
57
60
|
input: opts.entry,
|
|
58
|
-
plugins: [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache), (0, plugin_json_1.default)()],
|
|
61
|
+
plugins: [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache), dtsMode ? (0, rollup_plugin_dts_1.dts)() : (0, plugin_json_1.default)()],
|
|
59
62
|
onwarn: warning => {
|
|
60
63
|
switch (warning.code) {
|
|
61
64
|
case 'CIRCULAR_DEPENDENCY':
|
|
@@ -79,10 +82,10 @@ async function rollupBundleFile(opts) {
|
|
|
79
82
|
dir: opts.dir,
|
|
80
83
|
inlineDynamicImports: false,
|
|
81
84
|
hoistTransitiveImports: false,
|
|
82
|
-
chunkFileNames: opts.entryName
|
|
83
|
-
entryFileNames: opts.entryName +
|
|
85
|
+
chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,
|
|
86
|
+
entryFileNames: opts.entryName + outExtension,
|
|
84
87
|
banner: '',
|
|
85
|
-
sourcemap:
|
|
88
|
+
sourcemap: opts.sourcemap,
|
|
86
89
|
});
|
|
87
90
|
if (cacheDirectory) {
|
|
88
91
|
await (0, cache_1.saveCacheEntry)(cacheDirectory, opts.cacheKey, bundle.cache);
|
|
@@ -90,7 +93,13 @@ async function rollupBundleFile(opts) {
|
|
|
90
93
|
// Close the bundle to let plugins clean up their external processes or services
|
|
91
94
|
await bundle.close();
|
|
92
95
|
return {
|
|
93
|
-
files: output.output
|
|
96
|
+
files: output.output.map(f => {
|
|
97
|
+
/** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
|
|
98
|
+
if (f.type === 'chunk') {
|
|
99
|
+
f.map = null;
|
|
100
|
+
}
|
|
101
|
+
return f;
|
|
102
|
+
}),
|
|
94
103
|
cache: bundle.cache,
|
|
95
104
|
};
|
|
96
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,4CAkEC;AA/FD,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,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAChD,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAE3C,oBAAoB;IACpB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;QACpD,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACvG,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,CAAC,IAAA,qCAAgB,EAAC,I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AO,EAAE,CAAC;gBACvB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;YACf,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,YAAY;IACzB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,wDAAa,QAAQ,GAAC,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC3C,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport * as path from 'path';\nimport type { 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 dtsMode = opts.entry.endsWith('.d.ts');\n const outExtension = dtsMode ? '.d.ts' : '.mjs';\n const cacheDirectory = opts.cacheDirectory;\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => isExternalDependency(moduleId),\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins: [fileLoaderPlugin(opts.fileCache), dtsMode ? dts() : rollupJson()],\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n dir: opts.dir,\n inlineDynamicImports: false,\n hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, bundle.cache);\n }\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n files: output.output.map(f => {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n cache: bundle.cache,\n };\n}\n\nasync function ensureRollup(): Promise<void> {\n if (rollup) {\n return;\n }\n\n try {\n rollup = await import('rollup');\n log.debug(`rollup using native version.`);\n } catch {\n rollup = await import('@rollup/wasm-node');\n log.debug(`rollup using wasm version.`);\n }\n}\n\nfunction isExternalDependency(moduleId: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return false;\n }\n\n return true;\n}\n"]}
|
package/lib/graph/build-graph.js
CHANGED
|
@@ -27,8 +27,11 @@ class BuildGraph {
|
|
|
27
27
|
const oldNode = this.store.get(node.url);
|
|
28
28
|
oldNode['_dependees'].delete(oldNode);
|
|
29
29
|
}
|
|
30
|
-
if (this.watcher
|
|
31
|
-
|
|
30
|
+
if (this.watcher) {
|
|
31
|
+
const fileUrl = (0, nodes_1.fileUrlPath)(node.url);
|
|
32
|
+
if (fileUrl) {
|
|
33
|
+
this.watcher.add(fileUrl);
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
this.store.set(node.url, node);
|
|
34
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AACA,+
|
|
1
|
+
{"version":3,"file":"build-graph.js","sourceRoot":"","sources":["../../../src/lib/graph/build-graph.ts"],"names":[],"mappings":";;;AACA,+CAAkD;AAqBlD;;;GAGG;AACH,MAAa,UAAU;IAAvB;QACU,UAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IAiE1C,CAAC;IA9DQ,GAAG,CAAC,KAAoB;QAC7B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,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IAEM,MAAM,CAAwB,EAA6B;QAChE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,CAAQ,CAAC;IAC1C,CAAC;IAEM,IAAI,CAAwB,EAA6B;QAC9D,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,CAAkB,CAAC;IAClD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAlED,gCAkEC","sourcesContent":["import { FSWatcher } from 'chokidar';\nimport { fileUrlPath } from '../ng-package/nodes';\nimport { Node } from './node';\n\nexport type SimplePredicate<T = Node> = {\n (value: T, index: number): boolean;\n and?: (criteria: SimplePredicate<T>) => SimplePredicate<T>;\n};\n\nexport type ComplexPredicate<T = Node, R extends T = T> =\n | SimplePredicate<T>\n | {\n (value: T, index: number): value is R;\n and?: (criteria: ComplexPredicate<T, R>) => ComplexPredicate<T, R>;\n };\n\nexport interface Traversable<T> {\n filter<R extends T = T>(by: ComplexPredicate<T, R>): R[];\n find<R extends T = T>(by: ComplexPredicate<T, R>): R | undefined;\n some(by: SimplePredicate<T>): boolean;\n}\n\n/**\n * A tree of source files. Eventually, it's a graph. Ideally, it's an acyclic directed graph.\n * Technically, it's implemented as a map-like collection with references between map entries.\n */\nexport class BuildGraph implements Traversable<Node> {\n private store = new Map<string, Node>();\n watcher?: FSWatcher;\n\n public put(value: Node | Node[]) {\n if (value instanceof Array) {\n for (const node of value) {\n this.insert(node);\n }\n } else {\n this.insert(value);\n }\n\n return this;\n }\n\n private insert(node: Node) {\n if (this.store.has(node.url)) {\n // Clean up dependee references\n const oldNode = this.store.get(node.url);\n oldNode['_dependees'].delete(oldNode);\n }\n\n if (this.watcher) {\n const fileUrl = fileUrlPath(node.url);\n if (fileUrl) {\n this.watcher.add(fileUrl);\n }\n }\n\n this.store.set(node.url, node);\n }\n\n public get(url: string): Node {\n return this.store.get(url);\n }\n\n public has(url: string): boolean {\n return this.store.has(url);\n }\n\n public entries(): Node[] {\n const values = this.store.values();\n\n return Array.from(values);\n }\n\n public values(): IterableIterator<Node> {\n return this.store.values();\n }\n\n public some<T extends Node = Node>(by: ComplexPredicate<Node, T>): boolean {\n return this.entries().some(by);\n }\n\n public filter<T extends Node = Node>(by: ComplexPredicate<Node, T>): T[] {\n return this.entries().filter(by) as T[];\n }\n\n public find<T extends Node = Node>(by: ComplexPredicate<Node, T>): T | undefined {\n return this.entries().find(by) as T | undefined;\n }\n\n get size(): number {\n return this.store.size;\n }\n}\n"]}
|
package/lib/graph/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type NodeState = '' | '
|
|
2
|
-
export declare const
|
|
1
|
+
export type NodeState = '' | 'error' | 'in-progress' | 'pending' | 'done';
|
|
2
|
+
export declare const STATE_ERROR: NodeState;
|
|
3
3
|
export declare const STATE_IN_PROGRESS: NodeState;
|
|
4
4
|
export declare const STATE_PENDING: NodeState;
|
|
5
5
|
export declare const STATE_DONE: NodeState;
|
package/lib/graph/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Node = exports.STATE_DONE = exports.STATE_PENDING = exports.STATE_IN_PROGRESS = exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.Node = exports.STATE_DONE = exports.STATE_PENDING = exports.STATE_IN_PROGRESS = exports.STATE_ERROR = void 0;
|
|
4
|
+
exports.STATE_ERROR = 'error';
|
|
5
5
|
exports.STATE_IN_PROGRESS = 'in-progress';
|
|
6
6
|
exports.STATE_PENDING = 'pending';
|
|
7
7
|
exports.STATE_DONE = 'done';
|
package/lib/graph/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/lib/graph/node.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAc,OAAO,CAAC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GAAG,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF;AA7CD,oBA6CC","sourcesContent":["export type NodeState = '' | '
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/lib/graph/node.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAc,OAAO,CAAC;AACjC,QAAA,iBAAiB,GAAc,aAAa,CAAC;AAC7C,QAAA,aAAa,GAAc,SAAS,CAAC;AACrC,QAAA,UAAU,GAAc,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAa,IAAI;IACf,YAA4B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAMhC,UAAK,GAAc,EAAE,CAAC;QAsBrB,gBAAW,GAAG,IAAI,GAAG,EAAQ,CAAC;QAC9B,eAAU,GAAG,IAAI,GAAG,EAAQ,CAAC;IA7BK,CAAC;IAQpC,MAAM,CAAC,EAA2C;QACvD,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEM,IAAI,CAAC,EAA2C;QACrD,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAEM,IAAI,CAAC,EAA2C;QACrD,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAKM,SAAS,CAAC,SAAwB;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEnE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChC,sCAAsC;gBACtC,SAAS;YACX,CAAC;YAED,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF;AA7CD,oBA6CC","sourcesContent":["export type NodeState = '' | 'error' | 'in-progress' | 'pending' | 'done';\n\nexport const STATE_ERROR: NodeState = 'error';\nexport const STATE_IN_PROGRESS: NodeState = 'in-progress';\nexport const STATE_PENDING: NodeState = 'pending';\nexport const STATE_DONE: NodeState = 'done';\n\n/**\n * A Node in the {@link BuildGraph}.\n */\nexport class Node {\n constructor(public readonly url: string) {}\n\n public type: string;\n\n public data: any;\n\n public state: NodeState = '';\n\n public filter(by: (value: Node, index: number) => boolean): Node[] {\n return [...this._dependents].filter(by);\n }\n\n public find(by: (value: Node, index: number) => boolean): Node | undefined {\n return [...this._dependents].find(by);\n }\n\n public some(by: (value: Node, index: number) => boolean): boolean {\n return [...this._dependents].some(by);\n }\n\n public get dependents(): Set<Node> {\n return this._dependents;\n }\n\n public get dependees(): Set<Node> {\n return this._dependees;\n }\n\n private _dependents = new Set<Node>();\n private _dependees = new Set<Node>();\n\n public dependsOn(dependent: Node | Node[]) {\n const newDeps = Array.isArray(dependent) ? dependent : [dependent];\n\n for (const newDep of newDeps) {\n if (newDep._dependees.has(this)) {\n // nodes already depends on each other\n continue;\n }\n\n newDep._dependees.add(this);\n this._dependents.add(newDep);\n }\n }\n}\n"]}
|
package/lib/graph/select.d.ts
CHANGED
|
@@ -6,5 +6,4 @@ export declare function by(criteria: (node: Node) => boolean): {
|
|
|
6
6
|
};
|
|
7
7
|
export declare function isInProgress(node: Node): boolean;
|
|
8
8
|
export declare function isPending(node: Node): boolean;
|
|
9
|
-
export declare function isDirty(node: Node): boolean;
|
|
10
9
|
export declare function isDone(node: Node): boolean;
|
package/lib/graph/select.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.and = and;
|
|
|
4
4
|
exports.by = by;
|
|
5
5
|
exports.isInProgress = isInProgress;
|
|
6
6
|
exports.isPending = isPending;
|
|
7
|
-
exports.isDirty = isDirty;
|
|
8
7
|
exports.isDone = isDone;
|
|
9
8
|
const node_1 = require("./node");
|
|
10
9
|
function and(...criteria) {
|
|
@@ -25,9 +24,6 @@ function isInProgress(node) {
|
|
|
25
24
|
function isPending(node) {
|
|
26
25
|
return node.state === node_1.STATE_PENDING;
|
|
27
26
|
}
|
|
28
|
-
function isDirty(node) {
|
|
29
|
-
return node.state === node_1.STATE_DIRTY;
|
|
30
|
-
}
|
|
31
27
|
function isDone(node) {
|
|
32
28
|
return node.state === node_1.STATE_DONE;
|
|
33
29
|
}
|
package/lib/graph/select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/lib/graph/select.ts"],"names":[],"mappings":";;AAEA,kBAEC;AAED,gBAcC;AAED,oCAEC;AAED,8BAEC;AAED,
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/lib/graph/select.ts"],"names":[],"mappings":";;AAEA,kBAEC;AAED,gBAcC;AAED,oCAEC;AAED,8BAEC;AAED,wBAEC;AAhCD,iCAA6E;AAE7E,SAAgB,GAAG,CAAC,GAAG,QAAqC;IAC1D,OAAO,CAAC,IAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAgB,EAAE,CAChB,QAAiC;IAKjC,SAAS,EAAE,CAAC,IAAI;QACd,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,EAAE,CAAC,KAAK,CAAC,GAAG,UAAU,IAAI;QACxB,OAAO,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,OAAO,EAAS,CAAC;AACnB,CAAC;AAED,SAAgB,YAAY,CAAC,IAAU;IACrC,OAAO,IAAI,CAAC,KAAK,KAAK,wBAAiB,CAAC;AAC1C,CAAC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,KAAK,KAAK,oBAAa,CAAC;AACtC,CAAC;AAED,SAAgB,MAAM,CAAC,IAAU;IAC/B,OAAO,IAAI,CAAC,KAAK,KAAK,iBAAU,CAAC;AACnC,CAAC","sourcesContent":["import { Node, STATE_DONE, STATE_IN_PROGRESS, STATE_PENDING } from './node';\n\nexport function and(...criteria: ((node: Node) => boolean)[]) {\n return (node: Node) => criteria.every(c => c(node));\n}\n\nexport function by(\n criteria: (node: Node) => boolean,\n): {\n (node: Node): boolean;\n and: (criteria: (node: Node) => boolean) => (node: Node) => boolean;\n} {\n function fn(args) {\n return criteria(args);\n }\n fn['and'] = function (args) {\n return and(criteria, args);\n };\n\n return fn as any;\n}\n\nexport function isInProgress(node: Node): boolean {\n return node.state === STATE_IN_PROGRESS;\n}\n\nexport function isPending(node: Node): boolean {\n return node.state === STATE_PENDING;\n}\n\nexport function isDone(node: Node): boolean {\n return node.state === STATE_DONE;\n}\n"]}
|
|
@@ -5,6 +5,10 @@ import { CssUrl } from '../../styles/stylesheet-processor';
|
|
|
5
5
|
export interface DestinationFiles {
|
|
6
6
|
/** Absolute path of this entry point `declarations` */
|
|
7
7
|
declarations: string;
|
|
8
|
+
/** Absolute path of this bundled entry point `declarations` */
|
|
9
|
+
declarationsBundled: string;
|
|
10
|
+
/** Absolute path of this entry point `types` directory */
|
|
11
|
+
declarationsDir: string;
|
|
8
12
|
/** Absolute path of this entry point `FESM2022` module */
|
|
9
13
|
fesm2022: string;
|
|
10
14
|
/** Absolute path of this entry point `ESM2022` module */
|
|
@@ -93,7 +93,6 @@ class NgEntryPoint {
|
|
|
93
93
|
return this.secondaryData ? this.secondaryData.destinationPath : path.resolve(this.basePath, this.$get('dest'));
|
|
94
94
|
}
|
|
95
95
|
get destinationFiles() {
|
|
96
|
-
var _a;
|
|
97
96
|
let primaryDestPath = this.destinationPath;
|
|
98
97
|
let secondaryDir = '';
|
|
99
98
|
if (this.secondaryData) {
|
|
@@ -103,9 +102,11 @@ class NgEntryPoint {
|
|
|
103
102
|
const flatModuleFile = this.flatModuleFile;
|
|
104
103
|
const pathJoinWithDest = (...paths) => path.join(primaryDestPath, ...paths);
|
|
105
104
|
return {
|
|
106
|
-
directory: (
|
|
107
|
-
declarations: pathJoinWithDest(secondaryDir,
|
|
108
|
-
|
|
105
|
+
directory: (0, path_1.ensureUnixPath)(secondaryDir),
|
|
106
|
+
declarations: pathJoinWithDest('tmp-typings', secondaryDir, `${flatModuleFile}.d.ts`),
|
|
107
|
+
declarationsBundled: pathJoinWithDest(secondaryDir, 'index.d.ts'),
|
|
108
|
+
declarationsDir: pathJoinWithDest(secondaryDir),
|
|
109
|
+
esm2022: pathJoinWithDest('tmp-esm2022', secondaryDir, `${flatModuleFile}.js`),
|
|
109
110
|
fesm2022: pathJoinWithDest('fesm2022', `${flatModuleFile}.mjs`),
|
|
110
111
|
fesm2022Dir: pathJoinWithDest('fesm2022'),
|
|
111
112
|
};
|
|
@@ -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;
|
|
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;IAC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IAAW,iBAAiB;QAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAC;QAE9D,OAAO,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CACpC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CACtF,CAAC;IACJ,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACrF,CAAC;IAEO,eAAe,CAAC,SAAS,GAAG,GAAG;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAEnF,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACF;AAvGD,oCAuGC","sourcesContent":["import * as path from 'path';\nimport { NgPackageEntryConfig } from '../../../ng-entrypoint.schema';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../../utils/path';\n\n/** A list of output absolute paths for various formats */\nexport interface DestinationFiles {\n /** Absolute path of this entry point `declarations` */\n declarations: string;\n /** Absolute path of this bundled entry point `declarations` */\n declarationsBundled: string;\n /** Absolute path of this entry point `types` directory */\n declarationsDir: string;\n /** Absolute path of this entry point `FESM2022` module */\n fesm2022: string;\n /** Absolute path of this entry point `ESM2022` module */\n esm2022: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n /** Absolute path of this entry point `FESM2022` directory */\n fesm2022Dir: string;\n}\n\n/**\n * An entry point - quoting Angular Package Format - is:\n *\n * > a module intended to be imported by the user. It is referenced by a unique module ID and\n * > exports the public API referenced by that module ID. An example is `@angular/core` or\n * > `@angular/core/testing`. Both entry points exist in the `@angular/core` package, but they\n * > export different symbols. A package can have many entry points.\n *\n * #### Public API, source file tree and build output\n *\n * An entry point serves as the root of a source tree.\n * The entry point's public API references one TypeScript source file (`*.ts`).\n * That source file, e.g. `public_api.ts`, references other source files who in turn may reference\n * other source files, thus creating a tree of source code files.\n * The source files may be TypeScript (`*.ts`), Templates (`.html`) or Stylesheets\n * (`.css`, `.scss`, ..), or other formats.\n *\n * The compilation process for an entry point is a series of transformations applied to the source\n * files, e.g. TypeScript compilation, Inlining of Stylesheets and Templates, and so on.\n * As a result of the compilation process, an entry point is transpiled to a set of artefacts\n * (the build output) which include a FESM'15 Bundle, a FESM'5 Bundle, AoT metadata, TypeScript\n * type definitions, and so on.\n *\n * #### Representation in the domain\n *\n * The set of artefacts is reflected by `NgArtefacts`;\n * one `NgEntryPoint` relates to one `NgArtefacts`.\n * The parent package of an entry point is reflected by `NgPackage`.\n */\nexport class NgEntryPoint {\n constructor(\n /** Values from the `package.json` file of this entry point. */\n public readonly packageJson: Record<string, any>,\n /** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */\n public readonly ngPackageJson: NgPackageConfig,\n /** Absolute directory path of this entry point's `package.json` location. */\n public readonly basePath: string,\n /** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */\n private readonly secondaryData?: Record<string, any>,\n ) {}\n\n /** Absolute file path of the entry point's source code entry file. */\n public get entryFilePath(): string {\n return path.resolve(this.basePath, this.entryFile);\n }\n\n /** Whether or not the entrypoint is secondary */\n public get isSecondaryEntryPoint(): boolean {\n return !!this.secondaryData;\n }\n\n /** Absolute directory path of this entry point's 'package.json'. */\n public get destinationPath(): string {\n return this.secondaryData ? this.secondaryData.destinationPath : path.resolve(this.basePath, this.$get('dest'));\n }\n\n public get destinationFiles(): DestinationFiles {\n let primaryDestPath = this.destinationPath;\n let secondaryDir = '';\n\n if (this.secondaryData) {\n primaryDestPath = this.secondaryData.primaryDestinationPath;\n secondaryDir = path.relative(primaryDestPath, this.secondaryData.destinationPath);\n }\n\n const flatModuleFile = this.flatModuleFile;\n const pathJoinWithDest = (...paths: string[]) => path.join(primaryDestPath, ...paths);\n\n return {\n directory: ensureUnixPath(secondaryDir),\n declarations: pathJoinWithDest('tmp-typings', secondaryDir, `${flatModuleFile}.d.ts`),\n declarationsBundled: pathJoinWithDest(secondaryDir, 'index.d.ts'),\n declarationsDir: pathJoinWithDest(secondaryDir),\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"]}
|
|
@@ -7,46 +7,61 @@ exports.writeBundlesTransform = void 0;
|
|
|
7
7
|
const ora_1 = __importDefault(require("ora"));
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const rollup_1 = require("../../flatten/rollup");
|
|
10
|
+
const node_1 = require("../../graph/node");
|
|
11
|
+
const select_1 = require("../../graph/select");
|
|
10
12
|
const transform_1 = require("../../graph/transform");
|
|
11
13
|
const cache_1 = require("../../utils/cache");
|
|
12
14
|
const fs_1 = require("../../utils/fs");
|
|
15
|
+
const path_2 = require("../../utils/path");
|
|
13
16
|
const nodes_1 = require("../nodes");
|
|
14
17
|
const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
|
|
18
|
+
var _a;
|
|
15
19
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
16
20
|
const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;
|
|
17
21
|
const cache = entryPoint.cache;
|
|
18
|
-
const { fesm2022Dir, esm2022 } = destinationFiles;
|
|
22
|
+
const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;
|
|
19
23
|
const spinner = (0, ora_1.default)({
|
|
20
24
|
hideCursor: false,
|
|
21
25
|
discardStdin: false,
|
|
22
26
|
});
|
|
23
|
-
const
|
|
27
|
+
const cacheKey = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, esm2022, fesm2022Dir, tsConfig.options.compilationMode, declarations, declarationsDir);
|
|
24
28
|
const hash = await (0, cache_1.generateKey)([...cache.outputCache.values()].map(({ version }) => version).join(':'));
|
|
25
29
|
const cacheDirectory = options.cacheEnabled && options.cacheDirectory;
|
|
26
30
|
if (cacheDirectory) {
|
|
27
|
-
const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory,
|
|
31
|
+
const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory, cacheKey);
|
|
28
32
|
let writing = false;
|
|
29
33
|
if ((cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.hash) === hash) {
|
|
34
|
+
const filesToCopy = [
|
|
35
|
+
...cacheResult.fesm2022.map(file => ({
|
|
36
|
+
...file,
|
|
37
|
+
filePath: (0, path_1.join)(fesm2022Dir, file.fileName),
|
|
38
|
+
})),
|
|
39
|
+
...cacheResult.types.map(file => ({
|
|
40
|
+
...file,
|
|
41
|
+
filePath: (0, path_1.join)(declarationsDir, file.fileName),
|
|
42
|
+
})),
|
|
43
|
+
];
|
|
30
44
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (options.watch && (await (0, fs_1.exists)(filePath))) {
|
|
45
|
+
const writeFilePromises = [];
|
|
46
|
+
for (const file of filesToCopy) {
|
|
47
|
+
if (options.watch && (await (0, fs_1.exists)(file.filePath))) {
|
|
34
48
|
continue;
|
|
35
49
|
}
|
|
36
50
|
if (!writing) {
|
|
37
51
|
writing = true;
|
|
38
|
-
spinner.start('Writing FESM bundles');
|
|
39
|
-
await (0, fs_1.mkdir)(fesm2022Dir, { recursive: true });
|
|
52
|
+
spinner.start('Writing FESM and DTS bundles');
|
|
53
|
+
await Promise.all([(0, fs_1.mkdir)(fesm2022Dir, { recursive: true }), (0, fs_1.mkdir)(declarationsDir, { recursive: true })]);
|
|
40
54
|
}
|
|
41
|
-
|
|
55
|
+
writeFilePromises.push((0, fs_1.writeFile)(file.filePath, file.type === 'asset' ? file.source : file.code));
|
|
42
56
|
}
|
|
43
57
|
if (writing) {
|
|
44
|
-
|
|
58
|
+
await Promise.all(writeFilePromises);
|
|
59
|
+
spinner.succeed('Writing FESM and DTS bundles');
|
|
45
60
|
}
|
|
46
61
|
}
|
|
47
62
|
catch (error) {
|
|
48
63
|
if (!writing) {
|
|
49
|
-
spinner.start('Writing FESM bundles');
|
|
64
|
+
spinner.start('Writing FESM and DTS bundles');
|
|
50
65
|
}
|
|
51
66
|
spinner.fail();
|
|
52
67
|
throw error;
|
|
@@ -54,43 +69,79 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
|
|
|
54
69
|
return;
|
|
55
70
|
}
|
|
56
71
|
}
|
|
57
|
-
async function
|
|
58
|
-
const { cache:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
async function generateBundles() {
|
|
73
|
+
const [{ cache: rollupFESM2022Cache, files: fesmFiles }, { cache: rollupTypesCache, files: typesFiles }] = await Promise.all([
|
|
74
|
+
(0, rollup_1.rollupBundleFile)({
|
|
75
|
+
entry: esm2022,
|
|
76
|
+
entryName: ngEntryPoint.flatModuleFile,
|
|
77
|
+
moduleName: ngEntryPoint.moduleId,
|
|
78
|
+
dir: fesm2022Dir,
|
|
79
|
+
cache: cache.rollupFESM2022Cache,
|
|
80
|
+
cacheDirectory,
|
|
81
|
+
fileCache: cache.outputCache,
|
|
82
|
+
cacheKey,
|
|
83
|
+
sourcemap: true,
|
|
84
|
+
}),
|
|
85
|
+
(0, rollup_1.rollupBundleFile)({
|
|
86
|
+
entry: declarations,
|
|
87
|
+
entryName: 'index',
|
|
88
|
+
// entryName: ngEntryPoint.flatModuleFile,
|
|
89
|
+
moduleName: ngEntryPoint.moduleId,
|
|
90
|
+
dir: declarationsDir,
|
|
91
|
+
cache: cache.rollupTypesCache,
|
|
92
|
+
cacheDirectory,
|
|
93
|
+
fileCache: cache.outputCache,
|
|
94
|
+
cacheKey,
|
|
95
|
+
sourcemap: tsConfig.options.declarationMap || false,
|
|
75
96
|
}),
|
|
76
|
-
|
|
97
|
+
]);
|
|
98
|
+
cache.rollupFESM2022Cache = rollupFESM2022Cache;
|
|
99
|
+
cache.rollupTypesCache = rollupTypesCache;
|
|
100
|
+
return {
|
|
101
|
+
hash,
|
|
102
|
+
types: typesFiles,
|
|
103
|
+
fesm2022: fesmFiles,
|
|
77
104
|
};
|
|
78
105
|
}
|
|
79
|
-
|
|
80
|
-
hash,
|
|
81
|
-
};
|
|
106
|
+
let cacheRollup;
|
|
82
107
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
cacheRollup = await generateBundles();
|
|
109
|
+
spinner.succeed(`Generating FESM and DTS bundles`);
|
|
110
|
+
// Invalidate dependent entry-points
|
|
111
|
+
const entryPoints = graph.filter(nodes_1.isEntryPoint);
|
|
112
|
+
for (const file of cacheRollup.types) {
|
|
113
|
+
if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const dtsFile = (0, path_2.ensureUnixPath)((0, path_1.join)(declarationsDir, file.fileName));
|
|
117
|
+
const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);
|
|
118
|
+
if (((_a = cachedSourceFile === null || cachedSourceFile === void 0 ? void 0 : cachedSourceFile.sourceFile) === null || _a === void 0 ? void 0 : _a.text) === file.code) {
|
|
119
|
+
// Contents of the file is exact
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
cache.sourcesFileCache.delete(dtsFile);
|
|
123
|
+
cache.analysesSourcesFileCache.delete(dtsFile);
|
|
124
|
+
const changedFileUrl = (0, nodes_1.fileUrl)(dtsFile);
|
|
125
|
+
const nodeToClean = graph.find(node => changedFileUrl === node.url);
|
|
126
|
+
if (!nodeToClean) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
for (const entryPoint of entryPoints) {
|
|
130
|
+
if ((0, select_1.isPending)(entryPoint)) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (entryPoint.dependents.has(nodeToClean)) {
|
|
134
|
+
entryPoint.state = node_1.STATE_PENDING;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
87
138
|
}
|
|
88
139
|
catch (error) {
|
|
89
140
|
spinner.fail();
|
|
90
141
|
throw error;
|
|
91
142
|
}
|
|
92
143
|
if (cacheDirectory) {
|
|
93
|
-
await (0, cache_1.saveCacheEntry)(cacheDirectory,
|
|
144
|
+
await (0, cache_1.saveCacheEntry)(cacheDirectory, cacheKey, cacheRollup);
|
|
94
145
|
}
|
|
95
146
|
});
|
|
96
147
|
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,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,oCAAkE;AAQ3D,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;IAElD,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,GAAG,GA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SACzD,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAA0B;QACvC,IAAI;KACL,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;QAE1F,KAAK,CAAC,mBAAmB,GAAG,WAAW,CAAC;QACxC,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC;QAE3B,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC7C,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,GAAG,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;AACH,CAAC,CAAC,CAAC;AAnGQ,QAAA,qBAAqB,yBAmG7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk, RollupCache } from 'rollup';\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 { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2022: (OutputChunk | OutputAsset)[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2022Dir, esm2022 } = destinationFiles;\n\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const key = await generateKey(ngEntryPoint.moduleId, esm2022, fesm2022Dir, tsConfig.options.compilationMode);\n const hash = await generateKey([...cache.outputCache.values()].map(({ version }) => version).join(':'));\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, key);\n let writing = false;\n\n if (cacheResult?.hash === hash) {\n try {\n for (const file of cacheResult.fesm2022) {\n const filePath = join(fesm2022Dir, file.fileName);\n if (options.watch && (await exists(filePath))) {\n continue;\n }\n\n if (!writing) {\n writing = true;\n spinner.start('Writing FESM bundles');\n await mkdir(fesm2022Dir, { recursive: true });\n }\n\n await writeFile(filePath, file.type === 'asset' ? file.source : file.code);\n }\n\n if (writing) {\n spinner.succeed('Writing FESM bundles');\n }\n } catch (error) {\n if (!writing) {\n spinner.start('Writing FESM bundles');\n }\n\n spinner.fail();\n throw error;\n }\n\n return;\n }\n }\n\n async function generateFESM(\n rollupCache: RollupCache,\n dir: string,\n ): Promise<{ files: (OutputChunk | OutputAsset)[]; rollupCache: RollupCache }> {\n const { cache: rollupFESMCache, files } = await rollupBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir,\n cache: rollupCache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2022, dir, ngEntryPoint.moduleId, tsConfig.options.compilationMode),\n });\n\n return {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n files: files.map(f => {\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n rollupCache: options.watch ? rollupFESMCache : undefined,\n };\n }\n\n const fesmCache: Partial<BundlesCache> = {\n hash,\n };\n\n try {\n const { rollupCache, files } = await generateFESM(cache.rollupFESM2022Cache, fesm2022Dir);\n\n cache.rollupFESM2022Cache = rollupCache;\n fesmCache.fesm2022 = files;\n\n spinner.succeed(`Generating FESM bundles`);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, key, fesmCache);\n }\n });\n"]}
|
|
1
|
+
{"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA4B;AAE5B,iDAAwD;AACxD,2CAAiD;AACjD,+CAA+C;AAC/C,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAAyF;AASlF,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;;IACjC,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAAC;IACjF,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAChC,YAAY,CAAC,QAAQ,EACrB,OAAO,EACP,WAAW,EACX,QAAQ,CAAC,OAAO,CAAC,eAAe,EAChC,YAAY,EACZ,eAAe,CAChB,CAAC;IACF,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,CAAC,CAAC;IACxG,MAAM,cAAc,G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AAgC;gBAChC,SAAS;YACX,CAAC;YAED,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAE/C,MAAM,cAAc,GAAG,IAAA,eAAO,EAAC,OAAO,CAAC,CAAC;YACxC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC;YACpE,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,SAAS;YACX,CAAC;YAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,IAAI,IAAA,kBAAS,EAAC,UAAU,CAAC,EAAE,CAAC;oBAC1B,SAAS;gBACX,CAAC;gBAED,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC3C,UAAU,CAAC,KAAK,GAAG,oBAAa,CAAC;gBACnC,CAAC;YACH,CAAC;QACH,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;AA1JQ,QAAA,qBAAqB,yBA0J7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk } from 'rollup';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { STATE_PENDING } from '../../graph/node';\nimport { isPending } from '../../graph/select';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, fileUrl, isEntryPoint, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2022: (OutputChunk | OutputAsset)[];\n types: (OutputChunk | OutputAsset)[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const cacheKey = await generateKey(\n ngEntryPoint.moduleId,\n esm2022,\n fesm2022Dir,\n tsConfig.options.compilationMode,\n declarations,\n declarationsDir,\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 let writing = false;\n\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 (!writing) {\n writing = true;\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 (writing) {\n await Promise.all(writeFilePromises);\n spinner.succeed('Writing FESM and DTS bundles');\n }\n } catch (error) {\n if (!writing) {\n spinner.start('Writing FESM and DTS bundles');\n }\n\n spinner.fail();\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: 'index',\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 entryPoints = graph.filter(isEntryPoint);\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 // Contents of the file is exact\n continue;\n }\n\n cache.sourcesFileCache.delete(dtsFile);\n cache.analysesSourcesFileCache.delete(dtsFile);\n\n const changedFileUrl = fileUrl(dtsFile);\n const nodeToClean = graph.find(node => changedFileUrl === node.url);\n if (!nodeToClean) {\n continue;\n }\n\n for (const entryPoint of entryPoints) {\n if (isPending(entryPoint)) {\n continue;\n }\n\n if (entryPoint.dependents.has(nodeToClean)) {\n entryPoint.state = STATE_PENDING;\n }\n }\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, cacheRollup);\n }\n });\n"]}
|
|
@@ -78,7 +78,7 @@ const writePackageTransform = (options) => (0, transform_1.transformFromPromise)
|
|
|
78
78
|
const { compilationMode } = entryPoint.data.tsConfig.options;
|
|
79
79
|
await writePackageJson(ngEntryPoint, ngPackage, {
|
|
80
80
|
module: relativeUnixFromDestPath(destinationFiles.fesm2022),
|
|
81
|
-
typings: relativeUnixFromDestPath(destinationFiles.
|
|
81
|
+
typings: relativeUnixFromDestPath(destinationFiles.declarationsBundled),
|
|
82
82
|
exports: generatePackageExports(ngEntryPoint, graph),
|
|
83
83
|
// webpack v4+ specific flag to enable advanced optimizations and code splitting
|
|
84
84
|
sideEffects: (_a = ngEntryPoint.packageJson.sideEffects) !== null && _a !== void 0 ? _a : false,
|
|
@@ -312,7 +312,7 @@ function generatePackageExports({ destinationPath, packageJson }, graph) {
|
|
|
312
312
|
const { destinationFiles, isSecondaryEntryPoint } = entryPoint.data.entryPoint;
|
|
313
313
|
const subpath = isSecondaryEntryPoint ? `./${destinationFiles.directory}` : '.';
|
|
314
314
|
insertMappingOrError(subpath, {
|
|
315
|
-
types: relativeUnixFromDestPath(destinationFiles.
|
|
315
|
+
types: relativeUnixFromDestPath(destinationFiles.declarationsBundled),
|
|
316
316
|
default: relativeUnixFromDestPath(destinationFiles.fesm2022),
|
|
317
317
|
});
|
|
318
318
|
}
|