ng-packagr 20.0.0-next.2 → 20.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/file-system/file-watcher.js +3 -0
- package/lib/file-system/file-watcher.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/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 +57 -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 +1 -1
- package/lib/ng-package/nodes.js.map +1 -1
- package/lib/ng-package/package.transform.js +6 -5
- 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 -46
- 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
|
@@ -48,6 +48,9 @@ function createFileWatch(basePaths, ignoredPaths = [], poll) {
|
|
|
48
48
|
/\.map$/,
|
|
49
49
|
/.tsbuildinfo$/,
|
|
50
50
|
file => {
|
|
51
|
+
if (file.endsWith('.d.ts')) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
51
54
|
const normalizedPath = (0, path_1.ensureUnixPath)(file);
|
|
52
55
|
return ignoredPaths.some(f => normalizedPath.startsWith(f));
|
|
53
56
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,
|
|
1
|
+
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../src/lib/file-system/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,0CA6DC;AA5ED,mDAAqC;AACrC,2BAA8B;AAC9B,2CAA6B;AAC7B,+BAA4C;AAC5C,kDAAoC;AACpC,wCAA+C;AAU/C,SAAgB,eAAe,CAC7B,SAA4B,EAC5B,eAAyB,EAAE,EAC3B,IAAa;IAKb,GAAG,CAAC,KAAK,CAAC,mCAAmC,SAAS,mBAAmB,YAAY,EAAE,CAAC,CAAC;IAEzF,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE;QAC/B,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE;YACP,QAAQ;YACR,eAAe;YACf,IAAI,CAAC,EAAE;gBACL,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC3B,OAAO,KAAK,CAAC;gBACf,CAAC;gBAED,MAAM,cAAc,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;gBAE5C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC;SACF;QACD,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QACnD,QAAQ,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KACtD,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,aAAQ,GAAE,KAAK,OAAO,CAAC;IACvC,MAAM,gBAAgB,GAAG,CAAC,KAAyB,EAAE,QAAgB,EAAE,QAAoC,EAAE,EAAE;QAC7G,GAAG,CAAC,KAAK,CAAC,+BAA+B,KAAK,WAAW,QAAQ,EAAE,CAAC,CAAC;QAErE,IAAI,OAAO,EAAE,CAAC;YACZ,oEAAoE;YACpE,0DAA0D;YAC1D,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACxB,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;QAED,IAAI,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;YAChD,2GAA2G;YAC3G,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC;YACZ,QAAQ,EAAE,IAAA,qBAAc,EAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChD,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,IAAI,iBAAU,CAAC,QAAQ,CAAC,EAAE;YACtC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAyB,EAAE,QAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;YAE9G,kEAAkE;YAClE,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import * as chokidar from 'chokidar';\nimport { platform } from 'os';\nimport * as path from 'path';\nimport { Observable, Observer } from 'rxjs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\ntype AllFileWatchEvents = 'change' | 'unlink' | 'add' | 'unlinkDir' | 'addDir';\nexport type FileWatchEvent = Exclude<AllFileWatchEvents, 'unlinkDir' | 'addDir'>;\n\nexport interface FileChangedEvent {\n filePath: string;\n event: FileWatchEvent;\n}\n\nexport function createFileWatch(\n basePaths: string | string[],\n ignoredPaths: string[] = [],\n poll?: number,\n): {\n watcher: chokidar.FSWatcher;\n onFileChange: Observable<FileChangedEvent>;\n} {\n log.debug(`Watching for changes: basePath: ${basePaths}, ignoredPaths: ${ignoredPaths}`);\n\n const watch = chokidar.watch([], {\n ignoreInitial: true,\n ignored: [\n /\\.map$/,\n /.tsbuildinfo$/,\n file => {\n if (file.endsWith('.d.ts')) {\n return false;\n }\n\n const normalizedPath = ensureUnixPath(file);\n\n return ignoredPaths.some(f => normalizedPath.startsWith(f));\n },\n ],\n persistent: true,\n usePolling: typeof poll === 'number' ? true : false,\n interval: typeof poll === 'number' ? poll : undefined,\n });\n\n const isLinux = platform() === 'linux';\n const handleFileChange = (event: AllFileWatchEvents, filePath: string, observer: Observer<FileChangedEvent>) => {\n log.debug(`Watch: Path changed. Event: ${event}, Path: ${filePath}`);\n\n if (isLinux) {\n // Workaround for Linux where chokidar will not handle future events\n // for files that were unlinked and immediately recreated.\n watch.unwatch(filePath);\n watch.add(filePath);\n }\n\n if (event === 'unlinkDir' || event === 'addDir') {\n // we don't need to trigger on directory removed or renamed as chokidar will fire the changes for each file\n return;\n }\n\n observer.next({\n filePath: ensureUnixPath(path.resolve(filePath)),\n event,\n });\n };\n\n return {\n watcher: watch,\n onFileChange: new Observable(observer => {\n watch.on('all', (event: AllFileWatchEvents, filePath: string) => handleFileChange(event, filePath, observer));\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return () => watch.close();\n }),\n };\n}\n"]}
|
|
@@ -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 = ['', '.mjs', '/index.mjs'];
|
|
40
|
+
const POTENTIAL_MATCHES = ['', '.mjs', '/index.mjs', '.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,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;AAC7E;;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 = ['', '.mjs', '/index.mjs', '.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,I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CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,gFAAgF;IAChF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC3B,wGAAwG;YACxG,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACvB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;YACf,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,YAAY;IACzB,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,wDAAa,QAAQ,GAAC,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC3C,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport * as path from 'path';\nimport type { 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"]}
|
|
@@ -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}.mjs`),
|
|
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;IACvB;IACE,+DAA+D;IAC/C,WAAgC;IAChD,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,iGAAiG;IAChF,aAAmC;QANpC,gBAAW,GAAX,WAAW,CAAqB;QAEhC,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GAAR,QAAQ,CAAQ;QAEf,kBAAa,GAAb,aAAa,CAAsB;IACnD,CAAC;IAEJ,sEAAs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Q,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}.mjs`),\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"]}
|
|
@@ -15,38 +15,49 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
|
|
|
15
15
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
16
16
|
const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;
|
|
17
17
|
const cache = entryPoint.cache;
|
|
18
|
-
const { fesm2022Dir, esm2022 } = destinationFiles;
|
|
18
|
+
const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;
|
|
19
19
|
const spinner = (0, ora_1.default)({
|
|
20
20
|
hideCursor: false,
|
|
21
21
|
discardStdin: false,
|
|
22
22
|
});
|
|
23
|
-
const
|
|
23
|
+
const cacheKey = await (0, cache_1.generateKey)(ngEntryPoint.moduleId, esm2022, fesm2022Dir, tsConfig.options.compilationMode, declarations, declarationsDir);
|
|
24
24
|
const hash = await (0, cache_1.generateKey)([...cache.outputCache.values()].map(({ version }) => version).join(':'));
|
|
25
25
|
const cacheDirectory = options.cacheEnabled && options.cacheDirectory;
|
|
26
26
|
if (cacheDirectory) {
|
|
27
|
-
const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory,
|
|
27
|
+
const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory, cacheKey);
|
|
28
28
|
let writing = false;
|
|
29
29
|
if ((cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.hash) === hash) {
|
|
30
|
+
const filesToCopy = [
|
|
31
|
+
...cacheResult.fesm2022.map(file => ({
|
|
32
|
+
...file,
|
|
33
|
+
filePath: (0, path_1.join)(fesm2022Dir, file.fileName),
|
|
34
|
+
})),
|
|
35
|
+
...cacheResult.types.map(file => ({
|
|
36
|
+
...file,
|
|
37
|
+
filePath: (0, path_1.join)(declarationsDir, file.fileName),
|
|
38
|
+
})),
|
|
39
|
+
];
|
|
30
40
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (options.watch && (await (0, fs_1.exists)(filePath))) {
|
|
41
|
+
const writeFilePromises = [];
|
|
42
|
+
for (const file of filesToCopy) {
|
|
43
|
+
if (options.watch && (await (0, fs_1.exists)(file.filePath))) {
|
|
34
44
|
continue;
|
|
35
45
|
}
|
|
36
46
|
if (!writing) {
|
|
37
47
|
writing = true;
|
|
38
|
-
spinner.start('Writing FESM bundles');
|
|
39
|
-
await (0, fs_1.mkdir)(fesm2022Dir, { recursive: true });
|
|
48
|
+
spinner.start('Writing FESM and DTS bundles');
|
|
49
|
+
await Promise.all([(0, fs_1.mkdir)(fesm2022Dir, { recursive: true }), (0, fs_1.mkdir)(declarationsDir, { recursive: true })]);
|
|
40
50
|
}
|
|
41
|
-
|
|
51
|
+
writeFilePromises.push((0, fs_1.writeFile)(file.filePath, file.type === 'asset' ? file.source : file.code));
|
|
42
52
|
}
|
|
43
53
|
if (writing) {
|
|
44
|
-
|
|
54
|
+
await Promise.all(writeFilePromises);
|
|
55
|
+
spinner.succeed('Writing FESM and DTS bundles');
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
catch (error) {
|
|
48
59
|
if (!writing) {
|
|
49
|
-
spinner.start('Writing FESM bundles');
|
|
60
|
+
spinner.start('Writing FESM and DTS bundles');
|
|
50
61
|
}
|
|
51
62
|
spinner.fail();
|
|
52
63
|
throw error;
|
|
@@ -54,43 +65,51 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
|
|
|
54
65
|
return;
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
|
-
async function
|
|
58
|
-
const { cache:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
|
|
70
|
-
files: files.map(f => {
|
|
71
|
-
if (f.type === 'chunk') {
|
|
72
|
-
f.map = null;
|
|
73
|
-
}
|
|
74
|
-
return f;
|
|
68
|
+
async function generateBundles() {
|
|
69
|
+
const [{ cache: rollupFESM2022Cache, files: fesmFiles }, { cache: rollupTypesCache, files: typesFiles }] = await Promise.all([
|
|
70
|
+
(0, rollup_1.rollupBundleFile)({
|
|
71
|
+
entry: esm2022,
|
|
72
|
+
entryName: ngEntryPoint.flatModuleFile,
|
|
73
|
+
moduleName: ngEntryPoint.moduleId,
|
|
74
|
+
dir: fesm2022Dir,
|
|
75
|
+
cache: cache.rollupFESM2022Cache,
|
|
76
|
+
cacheDirectory,
|
|
77
|
+
fileCache: cache.outputCache,
|
|
78
|
+
cacheKey,
|
|
79
|
+
sourcemap: true,
|
|
75
80
|
}),
|
|
76
|
-
|
|
81
|
+
(0, rollup_1.rollupBundleFile)({
|
|
82
|
+
entry: declarations,
|
|
83
|
+
entryName: 'index',
|
|
84
|
+
// entryName: ngEntryPoint.flatModuleFile,
|
|
85
|
+
moduleName: ngEntryPoint.moduleId,
|
|
86
|
+
dir: declarationsDir,
|
|
87
|
+
cache: cache.rollupTypesCache,
|
|
88
|
+
cacheDirectory,
|
|
89
|
+
fileCache: cache.outputCache,
|
|
90
|
+
cacheKey,
|
|
91
|
+
sourcemap: tsConfig.options.declarationMap || false,
|
|
92
|
+
}),
|
|
93
|
+
]);
|
|
94
|
+
cache.rollupFESM2022Cache = rollupFESM2022Cache;
|
|
95
|
+
cache.rollupTypesCache = rollupTypesCache;
|
|
96
|
+
return {
|
|
97
|
+
hash,
|
|
98
|
+
types: typesFiles,
|
|
99
|
+
fesm2022: fesmFiles,
|
|
77
100
|
};
|
|
78
101
|
}
|
|
79
|
-
|
|
80
|
-
hash,
|
|
81
|
-
};
|
|
102
|
+
let cacheRollup;
|
|
82
103
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fesmCache.fesm2022 = files;
|
|
86
|
-
spinner.succeed(`Generating FESM bundles`);
|
|
104
|
+
cacheRollup = await generateBundles();
|
|
105
|
+
spinner.succeed(`Generating FESM and DTS bundles`);
|
|
87
106
|
}
|
|
88
107
|
catch (error) {
|
|
89
108
|
spinner.fail();
|
|
90
109
|
throw error;
|
|
91
110
|
}
|
|
92
111
|
if (cacheDirectory) {
|
|
93
|
-
await (0, cache_1.saveCacheEntry)(cacheDirectory,
|
|
112
|
+
await (0, cache_1.saveCacheEntry)(cacheDirectory, cacheKey, cacheRollup);
|
|
94
113
|
}
|
|
95
114
|
});
|
|
96
115
|
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;
|
|
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;AAS3D,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAAC;IAEjF,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,QAA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,CAAC,CAAC,CAAC;AAzHQ,QAAA,qBAAqB,yBAyH7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk } 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 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\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 } 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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,2CAA6B;AAC7B,2CAAkC;AAGlC,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAoF;AACpF,qDAAuC;AACvC,2CAAkD;AAClD,oCAAiH;AAO1G,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;;IACjC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAChE,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,G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A,qBAAc,EAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAElE,oBAAoB,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEtE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IAC/C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;QAC/E,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAEhF,oBAAoB,CAAC,OAAO,EAAE;YAC5B,KAAK,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,YAAY,CAAC;YAC9D,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB;IAC3B,OAAO,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport { glob } from 'tinyglobby';\nimport { AssetPattern } from '../../../ng-package.schema';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, exists, readFile, rmdir, stat, writeFile } from '../../utils/fs';\nimport * as log from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, fileUrl, isEntryPoint, isEntryPointInProgress, isPackage } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\nimport { NgPackage } from '../package';\nimport { NgEntryPoint } from './entry-point';\n\ntype CompilationMode = 'partial' | 'full' | undefined;\n\nexport const writePackageTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const spinner = ora({ hideCursor: false, discardStdin: false });\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n spinner.start('Copying assets');\n try {\n await copyAssets(graph, entryPoint, ngPackageNode);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n try {\n spinner.start('Writing package manifest');\n if (!options.watch) {\n const primary = ngPackageNode.data.primary;\n await writeFile(\n path.join(primary.destinationPath, '.npmignore'),\n `# Nested package.json's are only needed for development.\\n**/package.json`,\n );\n }\n\n const { compilationMode } = entryPoint.data.tsConfig.options;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2022),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n exports: generatePackageExports(ngEntryPoint, graph),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,\n },\n !!options.watch,\n compilationMode as CompilationMode,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n } else if (ngEntryPoint.isSecondaryEntryPoint) {\n if (options.watch) {\n // Update the watch version of the primary entry point `package.json` file.\n // this is needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/ng-packagr/ng-packagr/issues/2069\n const primary = ngPackageNode.data.primary;\n const packageJsonPath = path.join(primary.destinationPath, 'package.json');\n\n if (await exists(packageJsonPath)) {\n const packageJson = JSON.parse(await readFile(packageJsonPath, { encoding: 'utf8' }));\n packageJson.version = generateWatchVersion();\n await writeFile(\n path.join(primary.destinationPath, 'package.json'),\n JSON.stringify(packageJson, undefined, 2),\n );\n }\n }\n\n // Write a package.json in each secondary entry-point\n // This is need for esbuild to secondary entry-points in dist correctly.\n await writeFile(\n path.join(ngEntryPoint.destinationPath, 'package.json'),\n JSON.stringify({ module: relativeUnixFromDestPath(destinationFiles.fesm2022) }, undefined, 2),\n );\n }\n\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n });\n\ntype AssetEntry = Exclude<AssetPattern, string>;\n\nasync function copyAssets(\n graph: BuildGraph,\n entryPointNode: EntryPointNode,\n ngPackageNode: PackageNode,\n): Promise<void> {\n const ngPackage = ngPackageNode.data;\n\n const globsForceIgnored: string[] = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db', `${ngPackage.dest}/**`];\n const defaultAssets: AssetEntry[] = [\n { glob: 'LICENSE', input: '/', output: '/' },\n ...graph.filter(isEntryPoint).map(({ data }) => {\n const subpath = data.entryPoint.destinationFiles.directory || '/';\n\n return { glob: 'README.md', input: subpath, output: subpath };\n }),\n ];\n\n const assets: AssetEntry[] = [];\n\n for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {\n let asset: AssetEntry;\n if (typeof assetPath === 'object') {\n asset = { ...assetPath };\n } else {\n const [isDir, isFile] = await stat(path.join(ngPackage.src, assetPath))\n .then(stats => [stats.isDirectory(), stats.isFile()])\n .catch(() => [false, false]);\n if (isDir) {\n asset = { glob: '**/*', input: assetPath, output: assetPath };\n } else if (isFile) {\n // filenames are their own glob\n asset = { glob: path.basename(assetPath), input: path.dirname(assetPath), output: path.dirname(assetPath) };\n } else {\n asset = { glob: assetPath, input: '/', output: '/' };\n }\n }\n\n asset.input = path.join(ngPackage.src, asset.input);\n asset.output = path.join(ngPackage.dest, asset.output);\n\n const isAncestorPath = (target: string, datum: string) => path.relative(datum, target).startsWith('..');\n if (isAncestorPath(asset.input, ngPackage.src)) {\n throw new Error('Cannot read assets from a location outside of the project root.');\n }\n if (isAncestorPath(asset.output, ngPackage.dest)) {\n throw new Error('Cannot write assets to a location outside of the output path.');\n }\n\n assets.push(asset);\n }\n\n for (const asset of assets) {\n const filePaths = await glob(asset.glob, {\n cwd: asset.input,\n ignore: [...(asset.ignore ?? []), ...globsForceIgnored],\n dot: true,\n onlyFiles: true,\n followSymbolicLinks: asset.followSymlinks,\n });\n for (const filePath of filePaths) {\n const fileSrcFullPath = path.join(asset.input, filePath);\n const fileDestFullPath = path.join(asset.output, filePath);\n const nodeUri = fileUrl(ensureUnixPath(fileSrcFullPath));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n entryPointNode.dependsOn(node);\n await copyFile(fileSrcFullPath, fileDestFullPath);\n }\n }\n}\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] | ConditionalExport },\n isWatchMode: boolean,\n compilationMode: CompilationMode,\n spinner: ora.Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = generateWatchVersion();\n }\n\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = { ...packageJson.dependencies, tslib: tsLibVersion };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = { ...(packageJson.dependencies || {}), tslib: packageJson.peerDependencies.tslib };\n\n delete packageJson.peerDependencies.tslib;\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rmdir(entryPoint.destinationPath, { recursive: true });\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (compilationMode !== 'partial') {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy in full compilation mode. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package with Ivy partial compilation mode, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: ora.Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} ` +\n `to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n\ntype PackageExports = Record<string, ConditionalExport>;\n\n/**\n * Type describing the conditional exports descriptor for an entry-point.\n * https://nodejs.org/api/packages.html#packages_conditional_exports\n */\ntype ConditionalExport = { types?: string; default?: string };\n\n/**\n * Generates the `package.json` package exports following APF v13.\n * This is supposed to match with: https://github.com/angular/angular/blob/e0667efa6eada64d1fb8b143840689090fc82e52/packages/bazel/src/ng_package/packager.ts#L415.\n */\nfunction generatePackageExports({ destinationPath, packageJson }: NgEntryPoint, graph: BuildGraph): PackageExports {\n const exports: PackageExports = packageJson.exports ? JSON.parse(JSON.stringify(packageJson.exports)) : {};\n\n const insertMappingOrError = (subpath: string, mapping: ConditionalExport) => {\n exports[subpath] ??= {};\n const subpathExport = exports[subpath];\n\n // Go through all conditions that should be inserted. If the condition is already\n // manually set of the subpath export, we throw an error. In general, we allow for\n // additional conditions to be set. These will always precede the generated ones.\n for (const conditionName of Object.keys(mapping)) {\n if (subpathExport[conditionName] !== undefined) {\n log.warn(\n `Found a conflicting export condition for \"${subpath}\". The \"${conditionName}\" ` +\n `condition would be overridden by ng-packagr. Please unset it.`,\n );\n }\n\n // **Note**: The order of the conditions is preserved even though we are setting\n // the conditions once at a time (the latest assignment will be at the end).\n subpathExport[conditionName] = mapping[conditionName];\n }\n };\n\n const relativeUnixFromDestPath = (filePath: string) =>\n './' + ensureUnixPath(path.relative(destinationPath, filePath));\n\n insertMappingOrError('./package.json', { default: './package.json' });\n\n const entryPoints = graph.filter(isEntryPoint);\n for (const entryPoint of entryPoints) {\n const { destinationFiles, isSecondaryEntryPoint } = entryPoint.data.entryPoint;\n const subpath = isSecondaryEntryPoint ? `./${destinationFiles.directory}` : '.';\n\n insertMappingOrError(subpath, {\n types: relativeUnixFromDestPath(destinationFiles.declarations),\n default: relativeUnixFromDestPath(destinationFiles.fesm2022),\n });\n }\n\n return exports;\n}\n\n/**\n * Generates a new version for the package `package.json` when runing in watch mode.\n */\nfunction generateWatchVersion() {\n return `0.0.0-watch+${Date.now()}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,2CAA6B;AAC7B,2CAAkC;AAGlC,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAoF;AACpF,qDAAuC;AACvC,2CAAkD;AAClD,oCAAiH;AAO1G,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;;IACjC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;IAChE,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC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c,EAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAElE,oBAAoB,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEtE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IAC/C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;QAC/E,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAEhF,oBAAoB,CAAC,OAAO,EAAE;YAC5B,KAAK,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC;YACrE,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB;IAC3B,OAAO,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport { glob } from 'tinyglobby';\nimport { AssetPattern } from '../../../ng-package.schema';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, exists, readFile, rmdir, stat, writeFile } from '../../utils/fs';\nimport * as log from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, fileUrl, isEntryPoint, isEntryPointInProgress, isPackage } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\nimport { NgPackage } from '../package';\nimport { NgEntryPoint } from './entry-point';\n\ntype CompilationMode = 'partial' | 'full' | undefined;\n\nexport const writePackageTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const spinner = ora({ hideCursor: false, discardStdin: false });\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n spinner.start('Copying assets');\n try {\n await copyAssets(graph, entryPoint, ngPackageNode);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n try {\n spinner.start('Writing package manifest');\n if (!options.watch) {\n const primary = ngPackageNode.data.primary;\n await writeFile(\n path.join(primary.destinationPath, '.npmignore'),\n `# Nested package.json's are only needed for development.\\n**/package.json`,\n );\n }\n\n const { compilationMode } = entryPoint.data.tsConfig.options;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2022),\n typings: relativeUnixFromDestPath(destinationFiles.declarationsBundled),\n exports: generatePackageExports(ngEntryPoint, graph),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,\n },\n !!options.watch,\n compilationMode as CompilationMode,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n } else if (ngEntryPoint.isSecondaryEntryPoint) {\n if (options.watch) {\n // Update the watch version of the primary entry point `package.json` file.\n // this is needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/ng-packagr/ng-packagr/issues/2069\n const primary = ngPackageNode.data.primary;\n const packageJsonPath = path.join(primary.destinationPath, 'package.json');\n\n if (await exists(packageJsonPath)) {\n const packageJson = JSON.parse(await readFile(packageJsonPath, { encoding: 'utf8' }));\n packageJson.version = generateWatchVersion();\n await writeFile(\n path.join(primary.destinationPath, 'package.json'),\n JSON.stringify(packageJson, undefined, 2),\n );\n }\n }\n\n // Write a package.json in each secondary entry-point\n // This is need for esbuild to secondary entry-points in dist correctly.\n await writeFile(\n path.join(ngEntryPoint.destinationPath, 'package.json'),\n JSON.stringify({ module: relativeUnixFromDestPath(destinationFiles.fesm2022) }, undefined, 2),\n );\n }\n\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n });\n\ntype AssetEntry = Exclude<AssetPattern, string>;\n\nasync function copyAssets(\n graph: BuildGraph,\n entryPointNode: EntryPointNode,\n ngPackageNode: PackageNode,\n): Promise<void> {\n const ngPackage = ngPackageNode.data;\n\n const globsForceIgnored: string[] = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db', `${ngPackage.dest}/**`];\n const defaultAssets: AssetEntry[] = [\n { glob: 'LICENSE', input: '/', output: '/' },\n ...graph.filter(isEntryPoint).map(({ data }) => {\n const subpath = data.entryPoint.destinationFiles.directory || '/';\n\n return { glob: 'README.md', input: subpath, output: subpath };\n }),\n ];\n\n const assets: AssetEntry[] = [];\n\n for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {\n let asset: AssetEntry;\n if (typeof assetPath === 'object') {\n asset = { ...assetPath };\n } else {\n const [isDir, isFile] = await stat(path.join(ngPackage.src, assetPath))\n .then(stats => [stats.isDirectory(), stats.isFile()])\n .catch(() => [false, false]);\n if (isDir) {\n asset = { glob: '**/*', input: assetPath, output: assetPath };\n } else if (isFile) {\n // filenames are their own glob\n asset = { glob: path.basename(assetPath), input: path.dirname(assetPath), output: path.dirname(assetPath) };\n } else {\n asset = { glob: assetPath, input: '/', output: '/' };\n }\n }\n\n asset.input = path.join(ngPackage.src, asset.input);\n asset.output = path.join(ngPackage.dest, asset.output);\n\n const isAncestorPath = (target: string, datum: string) => path.relative(datum, target).startsWith('..');\n if (isAncestorPath(asset.input, ngPackage.src)) {\n throw new Error('Cannot read assets from a location outside of the project root.');\n }\n if (isAncestorPath(asset.output, ngPackage.dest)) {\n throw new Error('Cannot write assets to a location outside of the output path.');\n }\n\n assets.push(asset);\n }\n\n for (const asset of assets) {\n const filePaths = await glob(asset.glob, {\n cwd: asset.input,\n ignore: [...(asset.ignore ?? []), ...globsForceIgnored],\n dot: true,\n onlyFiles: true,\n followSymbolicLinks: asset.followSymlinks,\n });\n for (const filePath of filePaths) {\n const fileSrcFullPath = path.join(asset.input, filePath);\n const fileDestFullPath = path.join(asset.output, filePath);\n const nodeUri = fileUrl(ensureUnixPath(fileSrcFullPath));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n entryPointNode.dependsOn(node);\n await copyFile(fileSrcFullPath, fileDestFullPath);\n }\n }\n}\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] | ConditionalExport },\n isWatchMode: boolean,\n compilationMode: CompilationMode,\n spinner: ora.Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = generateWatchVersion();\n }\n\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = { ...packageJson.dependencies, tslib: tsLibVersion };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = { ...(packageJson.dependencies || {}), tslib: packageJson.peerDependencies.tslib };\n\n delete packageJson.peerDependencies.tslib;\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rmdir(entryPoint.destinationPath, { recursive: true });\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (compilationMode !== 'partial') {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy in full compilation mode. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package with Ivy partial compilation mode, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: ora.Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} ` +\n `to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n\ntype PackageExports = Record<string, ConditionalExport>;\n\n/**\n * Type describing the conditional exports descriptor for an entry-point.\n * https://nodejs.org/api/packages.html#packages_conditional_exports\n */\ntype ConditionalExport = { types?: string; default?: string };\n\n/**\n * Generates the `package.json` package exports following APF v13.\n * This is supposed to match with: https://github.com/angular/angular/blob/e0667efa6eada64d1fb8b143840689090fc82e52/packages/bazel/src/ng_package/packager.ts#L415.\n */\nfunction generatePackageExports({ destinationPath, packageJson }: NgEntryPoint, graph: BuildGraph): PackageExports {\n const exports: PackageExports = packageJson.exports ? JSON.parse(JSON.stringify(packageJson.exports)) : {};\n\n const insertMappingOrError = (subpath: string, mapping: ConditionalExport) => {\n exports[subpath] ??= {};\n const subpathExport = exports[subpath];\n\n // Go through all conditions that should be inserted. If the condition is already\n // manually set of the subpath export, we throw an error. In general, we allow for\n // additional conditions to be set. These will always precede the generated ones.\n for (const conditionName of Object.keys(mapping)) {\n if (subpathExport[conditionName] !== undefined) {\n log.warn(\n `Found a conflicting export condition for \"${subpath}\". The \"${conditionName}\" ` +\n `condition would be overridden by ng-packagr. Please unset it.`,\n );\n }\n\n // **Note**: The order of the conditions is preserved even though we are setting\n // the conditions once at a time (the latest assignment will be at the end).\n subpathExport[conditionName] = mapping[conditionName];\n }\n };\n\n const relativeUnixFromDestPath = (filePath: string) =>\n './' + ensureUnixPath(path.relative(destinationPath, filePath));\n\n insertMappingOrError('./package.json', { default: './package.json' });\n\n const entryPoints = graph.filter(isEntryPoint);\n for (const entryPoint of entryPoints) {\n const { destinationFiles, isSecondaryEntryPoint } = entryPoint.data.entryPoint;\n const subpath = isSecondaryEntryPoint ? `./${destinationFiles.directory}` : '.';\n\n insertMappingOrError(subpath, {\n types: relativeUnixFromDestPath(destinationFiles.declarationsBundled),\n default: relativeUnixFromDestPath(destinationFiles.fesm2022),\n });\n }\n\n return exports;\n}\n\n/**\n * Generates a new version for the package `package.json` when runing in watch mode.\n */\nfunction generateWatchVersion() {\n return `0.0.0-watch+${Date.now()}`;\n}\n"]}
|
|
@@ -26,7 +26,6 @@ export declare function ngUrl(path: string): string;
|
|
|
26
26
|
export type OutputFileCache = Map<string, {
|
|
27
27
|
version?: string;
|
|
28
28
|
content: string;
|
|
29
|
-
map?: any;
|
|
30
29
|
}>;
|
|
31
30
|
export declare class EntryPointNode extends Node {
|
|
32
31
|
readonly url: string;
|
|
@@ -39,6 +38,7 @@ export declare class EntryPointNode extends Node {
|
|
|
39
38
|
analysesSourcesFileCache: FileCache;
|
|
40
39
|
moduleResolutionCache: ts.ModuleResolutionCache;
|
|
41
40
|
rollupFESM2022Cache?: RollupCache;
|
|
41
|
+
rollupTypesCache?: RollupCache;
|
|
42
42
|
stylesheetProcessor?: StylesheetProcessor;
|
|
43
43
|
oldNgtscProgram?: NgtscProgram;
|
|
44
44
|
oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","source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;YACN,gBAAgB,EAAE,IAAI,sBAAS,EAAE;YACjC,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7E,CAAC;IACJ,CAAC;CAAA;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 { ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isDirty, isInProgress } 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\nexport const TYPE_NG_PACKAGE = 'application/ng-package';\nexport const TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nexport const URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nexport const 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(isEntryPoint).and(isInProgress);\n}\n\nexport function isEntryPointDirty(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isDirty);\n}\n\nexport function isFileUrl(value: string): boolean {\n return value.startsWith(URL_PROTOCOL_FILE);\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string {\n if (url.startsWith(URL_PROTOCOL_FILE)) {\n return url.substring(URL_PROTOCOL_FILE.length);\n }\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 data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n data: NgPackage;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
|
|
@@ -112,8 +112,8 @@ const watchTransformFactory = (project, options, analyseSourcesTransform, entryP
|
|
|
112
112
|
const { data, cache } = graph.find(nodes_1.isPackage);
|
|
113
113
|
const { onFileChange, watcher } = (0, file_watcher_1.createFileWatch)([], [data.dest + '/'], options.poll);
|
|
114
114
|
graph.watcher = watcher;
|
|
115
|
-
return onFileChange.pipe((0, rxjs_1.
|
|
116
|
-
var _a;
|
|
115
|
+
return onFileChange.pipe((0, rxjs_1.map)(fileChange => {
|
|
116
|
+
var _a, _b;
|
|
117
117
|
const { filePath } = fileChange;
|
|
118
118
|
const { sourcesFileCache } = cache;
|
|
119
119
|
const cachedSourceFile = sourcesFileCache.get(filePath);
|
|
@@ -121,7 +121,7 @@ const watchTransformFactory = (project, options, analyseSourcesTransform, entryP
|
|
|
121
121
|
const uriToClean = [filePath, declarationFileName].map(x => (0, nodes_1.fileUrl)((0, path_1.ensureUnixPath)(x)));
|
|
122
122
|
const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));
|
|
123
123
|
if (!nodesToClean.length) {
|
|
124
|
-
return;
|
|
124
|
+
return false;
|
|
125
125
|
}
|
|
126
126
|
const allNodesToClean = [
|
|
127
127
|
...nodesToClean,
|
|
@@ -140,7 +140,7 @@ const watchTransformFactory = (project, options, analyseSourcesTransform, entryP
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
for (const entryPoint of graph.filter(nodes_1.isEntryPoint)) {
|
|
143
|
-
let isDirty = !!((_a = entryPoint.cache.stylesheetProcessor.invalidate(potentialStylesResources)) === null ||
|
|
143
|
+
let isDirty = !!((_b = (_a = entryPoint.cache.stylesheetProcessor) === null || _a === void 0 ? void 0 : _a.invalidate(potentialStylesResources)) === null || _b === void 0 ? void 0 : _b.length);
|
|
144
144
|
isDirty || (isDirty = allNodesToClean.some(dependent => entryPoint.dependents.has(dependent)));
|
|
145
145
|
if (isDirty) {
|
|
146
146
|
entryPoint.state = node_1.STATE_DIRTY;
|
|
@@ -149,7 +149,8 @@ const watchTransformFactory = (project, options, analyseSourcesTransform, entryP
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
return true;
|
|
153
|
+
}), (0, rxjs_1.filter)(isChanged => isChanged), (0, rxjs_1.debounceTime)(100), (0, rxjs_1.tap)(() => log.msg(FileChangeDetected)), (0, rxjs_1.startWith)(undefined), (0, rxjs_1.map)(() => graph));
|
|
153
154
|
}), (0, rxjs_1.switchMap)(graph => {
|
|
154
155
|
return (0, rxjs_1.of)(graph).pipe(buildTransformFactory(project, analyseSourcesTransform, entryPointTransform), (0, rxjs_1.tap)(() => log.msg(CompleteWaitingForFileChange)), (0, rxjs_1.catchError)(error => {
|
|
155
156
|
log.error(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA4C;AAC5C,+BAiBc;AACd,8DAA8D;AAE9D,wCAA2E;AAE3E,0CAAwC;AACxC,oCAAoC;AACpC,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAuD;AACvD,mCAUiB;AAGjB;;;;;;;;;;;;;;;GAeG;AACI,MAAM,uBAAuB,GAClC,CACE,OAAe,EACf,OAAyB,EACzB,qBAAgC,EAChC,uBAAkC,EAClC,mBAA8B,EAC9B,EAAE,CACJ,CAAC,OAA+B,EAA0B,EAAE;IAC1D,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAErC,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK;QAClC,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC;QACvF,CAAC,CAAC,qBAAqB,CAAC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,CAAC,CAAC;IAEjF,MAAM,MAAM,GAAG,IAAA,aAAK,EAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,mBAAW,CAAC,MAAM,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC,IAAI;IACjB,qCAAqC;IACrC,oFAAoF;IACpF,IAAA,gBAAS,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;QACtB,KAAK,CAAC,IAAI,GAAG,MAAM,IAAA,oCAAgB,EAAC,EAAE,OAAO,EAAE,CAAC,CAA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,CACF,EACD,IAAA,eAAQ,EAAC,CAAC,CAAC,EAAE,4EAA4E;IACzF,IAAA,qBAAc,EAAC,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport {\n NEVER,\n Observable,\n catchError,\n concatMap,\n debounceTime,\n defaultIfEmpty,\n filter,\n finalize,\n from,\n map,\n of as observableOf,\n pipe,\n startWith,\n switchMap,\n takeLast,\n tap,\n} from 'rxjs';\nimport { createFileWatch } from '../file-system/file-watcher';\nimport { BuildGraph } from '../graph/build-graph';\nimport { STATE_DIRTY, STATE_DONE, STATE_IN_PROGRESS } from '../graph/node';\nimport { Transform } from '../graph/transform';\nimport { colors } from '../utils/color';\nimport { rmdir } from '../utils/fs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { discoverPackages } from './discover-packages';\nimport {\n EntryPointNode,\n PackageNode,\n byEntryPoint,\n fileUrl,\n fileUrlPath,\n isEntryPoint,\n isFileUrl,\n isPackage,\n ngUrl,\n} from './nodes';\nimport { NgPackagrOptions } from './options.di';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory =\n (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform,\n ) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n log.info(`Building Angular Package`);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);\n\n const pkgUri = ngUrl(project);\n const ngPkg = new PackageNode(pkgUri);\n\n return source$.pipe(\n // Discover packages and entry points\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(async graph => {\n ngPkg.data = await discoverPackages({ project });\n\n graph.put(ngPkg);\n const { dest, deleteDestPath } = ngPkg.data;\n\n if (deleteDestPath) {\n try {\n await rmdir(dest, { recursive: true });\n } catch {}\n }\n\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(\n ngUrl(moduleId),\n ngPkg.cache.sourcesFileCache,\n ngPkg.cache.moduleResolutionCache,\n );\n node.data = { entryPoint, destinationFiles };\n node.state = 'dirty';\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n // Add entry points to graph\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform,\n finalize(() => {\n for (const node of ngPkg.dependents) {\n if (node instanceof EntryPointNode) {\n node.cache.stylesheetProcessor?.destroy();\n }\n }\n }),\n );\n };\n\nconst watchTransformFactory =\n (project: string, options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const { data, cache } = graph.find(isPackage);\n const { onFileChange, watcher } = createFileWatch([], [data.dest + '/'], options.poll);\n graph.watcher = watcher;\n\n return onFileChange.pipe(\n tap(fileChange => {\n const { filePath } = fileChange;\n const { sourcesFileCache } = cache;\n const cachedSourceFile = sourcesFileCache.get(filePath);\n const { declarationFileName } = cachedSourceFile || {};\n const uriToClean = [filePath, declarationFileName].map(x => fileUrl(ensureUnixPath(x)));\n const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));\n\n if (!nodesToClean.length) {\n return;\n }\n\n const allNodesToClean = [\n ...nodesToClean,\n // if a non ts file changes we need to clean up its direct dependees\n // this is mainly done for resources such as html and css\n ...nodesToClean.filter(node => !node.url.endsWith('.ts')).flatMap(node => [...node.dependees]),\n ];\n\n // delete node that changes\n for (const { url } of allNodesToClean) {\n sourcesFileCache.delete(fileUrlPath(url));\n }\n\n const potentialStylesResources = new Set<string>();\n for (const { url } of allNodesToClean) {\n if (isFileUrl(url)) {\n potentialStylesResources.add(fileUrlPath(url));\n }\n }\n\n for (const entryPoint of graph.filter(isEntryPoint)) {\n let isDirty = !!entryPoint.cache.stylesheetProcessor.invalidate(potentialStylesResources)?.length;\n isDirty ||= allNodesToClean.some(dependent => entryPoint.dependents.has(dependent));\n\n if (isDirty) {\n entryPoint.state = STATE_DIRTY;\n\n for (const url of uriToClean) {\n entryPoint.cache.analysesSourcesFileCache.delete(fileUrlPath(url));\n }\n }\n }\n }),\n debounceTime(100),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n map(() => graph),\n );\n }),\n switchMap(graph => {\n return observableOf(graph).pipe(\n buildTransformFactory(project, analyseSourcesTransform, entryPointTransform),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n\n return NEVER;\n }),\n );\n }),\n );\n };\n\nconst buildTransformFactory =\n (project: string, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const startTime = Date.now();\n\n const pkgUri = ngUrl(project);\n\n return source$.pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform),\n tap(graph => {\n const ngPkg = graph.get(pkgUri);\n log.success('\\n------------------------------------------------------------------------------');\n log.success(`Built Angular Package\n - from: ${ngPkg.data.src}\n - to: ${ngPkg.data.dest}`);\n log.success('------------------------------------------------------------------------------');\n const b = colors.bold;\n const w = colors.white;\n log.msg(w(`\\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\\n`));\n }),\n );\n };\n\nconst scheduleEntryPoints = (epTransform: Transform): Transform =>\n pipe(\n concatMap(graph => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\n for (const node of graph.values()) {\n if (!isEntryPoint(node)) {\n continue;\n }\n\n // Remove `ng://` prefix for better error messages\n const from = node.url.substring(5);\n depGraph.addNode(from);\n\n for (const dep of node.dependents) {\n if (!isEntryPoint(dep)) {\n continue;\n }\n\n const to = dep.url.substring(5);\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // The array index is the depth.\n const groups = depGraph.overallOrder().map(ngUrl);\n\n // Build entry points with lower depth values first.\n return from(groups).pipe(\n map((epUrl: string): EntryPointNode => graph.find(byEntryPoint().and(ep => ep.url === epUrl))),\n filter((entryPoint: EntryPointNode): boolean => entryPoint.state !== STATE_DONE),\n concatMap(ep =>\n observableOf(ep).pipe(\n // Mark the entry point as 'in-progress'\n tap(entryPoint => (entryPoint.state = STATE_IN_PROGRESS)),\n map(() => graph),\n epTransform,\n ),\n ),\n takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',\n defaultIfEmpty(graph),\n );\n }),\n );\n"]}
|
|
1
|
+
{"version":3,"file":"package.transform.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA4C;AAC5C,+BAiBc;AACd,8DAA8D;AAE9D,wCAA2E;AAE3E,0CAAwC;AACxC,oCAAoC;AACpC,kDAAoC;AACpC,wCAA+C;AAC/C,2DAAuD;AACvD,mCAUiB;AAGjB;;;;;;;;;;;;;;;GAeG;AACI,MAAM,uBAAuB,GAClC,CACE,OAAe,EACf,OAAyB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AAI,EAAE,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,gCAAgC;IAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,aAAK,CAAC,CAAC;IAElD,oDAAoD;IACpD,OAAO,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,IAAI,CACtB,IAAA,UAAG,EAAC,CAAC,KAAa,EAAkB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAA,oBAAY,GAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,EAC9F,IAAA,aAAM,EAAC,CAAC,UAA0B,EAAW,EAAE,CAAC,UAAU,CAAC,KAAK,KAAK,iBAAU,CAAC,EAChF,IAAA,gBAAS,EAAC,EAAE,CAAC,EAAE,CACb,IAAA,SAAY,EAAC,EAAE,CAAC,CAAC,IAAI;IACnB,wCAAwC;IACxC,IAAA,UAAG,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,wBAAiB,CAAC,CAAC,EACzD,IAAA,UAAG,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAChB,WAAW,CACZ,CACF,EACD,IAAA,eAAQ,EAAC,CAAC,CAAC,EAAE,4EAA4E;IACzF,IAAA,qBAAc,EAAC,KAAK,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { DepGraph } from 'dependency-graph';\nimport {\n NEVER,\n Observable,\n catchError,\n concatMap,\n debounceTime,\n defaultIfEmpty,\n filter,\n finalize,\n from,\n map,\n of as observableOf,\n pipe,\n startWith,\n switchMap,\n takeLast,\n tap,\n} from 'rxjs';\nimport { createFileWatch } from '../file-system/file-watcher';\nimport { BuildGraph } from '../graph/build-graph';\nimport { STATE_DIRTY, STATE_DONE, STATE_IN_PROGRESS } from '../graph/node';\nimport { Transform } from '../graph/transform';\nimport { colors } from '../utils/color';\nimport { rmdir } from '../utils/fs';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { discoverPackages } from './discover-packages';\nimport {\n EntryPointNode,\n PackageNode,\n byEntryPoint,\n fileUrl,\n fileUrlPath,\n isEntryPoint,\n isFileUrl,\n isPackage,\n ngUrl,\n} from './nodes';\nimport { NgPackagrOptions } from './options.di';\n\n/**\n * A transformation for building an npm package:\n *\n * - discoverPackages\n * - options\n * - initTsConfig\n * - analyzeTsSources (thereby extracting template and stylesheet files)\n * - for each entry point\n * - run the entryPontTransform\n *\n * @param project Project token, reference to `ng-package.json`\n * @param options ng-packagr options\n * @param initTsConfigTransform Transformation initializing the tsconfig of each entry point.\n * @param analyseSourcesTransform Transformation analyzing the typescript source files of each entry point.\n * @param entryPointTransform Transformation for asset rendering and compilation of a single entry point.\n */\nexport const packageTransformFactory =\n (\n project: string,\n options: NgPackagrOptions,\n initTsConfigTransform: Transform,\n analyseSourcesTransform: Transform,\n entryPointTransform: Transform,\n ) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n log.info(`Building Angular Package`);\n\n const buildTransform = options.watch\n ? watchTransformFactory(project, options, analyseSourcesTransform, entryPointTransform)\n : buildTransformFactory(project, analyseSourcesTransform, entryPointTransform);\n\n const pkgUri = ngUrl(project);\n const ngPkg = new PackageNode(pkgUri);\n\n return source$.pipe(\n // Discover packages and entry points\n // Clean the primary dest folder (should clean all secondary sub-directory, as well)\n switchMap(async graph => {\n ngPkg.data = await discoverPackages({ project });\n\n graph.put(ngPkg);\n const { dest, deleteDestPath } = ngPkg.data;\n\n if (deleteDestPath) {\n try {\n await rmdir(dest, { recursive: true });\n } catch {}\n }\n\n const entryPoints = [ngPkg.data.primary, ...ngPkg.data.secondaries].map(entryPoint => {\n const { destinationFiles, moduleId } = entryPoint;\n const node = new EntryPointNode(\n ngUrl(moduleId),\n ngPkg.cache.sourcesFileCache,\n ngPkg.cache.moduleResolutionCache,\n );\n node.data = { entryPoint, destinationFiles };\n node.state = 'dirty';\n ngPkg.dependsOn(node);\n\n return node;\n });\n\n // Add entry points to graph\n return graph.put(entryPoints);\n }),\n // Initialize the tsconfig for each entry point\n initTsConfigTransform,\n // perform build\n buildTransform,\n finalize(() => {\n for (const node of ngPkg.dependents) {\n if (node instanceof EntryPointNode) {\n node.cache.stylesheetProcessor?.destroy();\n }\n }\n }),\n );\n };\n\nconst watchTransformFactory =\n (project: string, options: NgPackagrOptions, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const CompleteWaitingForFileChange = '\\nCompilation complete. Watching for file changes...';\n const FileChangeDetected = '\\nFile change detected. Starting incremental compilation...';\n const FailedWaitingForFileChange = '\\nCompilation failed. Watching for file changes...';\n\n return source$.pipe(\n switchMap(graph => {\n const { data, cache } = graph.find(isPackage);\n const { onFileChange, watcher } = createFileWatch([], [data.dest + '/'], options.poll);\n graph.watcher = watcher;\n\n return onFileChange.pipe(\n map(fileChange => {\n const { filePath } = fileChange;\n const { sourcesFileCache } = cache;\n const cachedSourceFile = sourcesFileCache.get(filePath);\n const { declarationFileName } = cachedSourceFile || {};\n const uriToClean = [filePath, declarationFileName].map(x => fileUrl(ensureUnixPath(x)));\n const nodesToClean = graph.filter(node => uriToClean.some(uri => uri === node.url));\n\n if (!nodesToClean.length) {\n return false;\n }\n\n const allNodesToClean = [\n ...nodesToClean,\n // if a non ts file changes we need to clean up its direct dependees\n // this is mainly done for resources such as html and css\n ...nodesToClean.filter(node => !node.url.endsWith('.ts')).flatMap(node => [...node.dependees]),\n ];\n\n // delete node that changes\n for (const { url } of allNodesToClean) {\n sourcesFileCache.delete(fileUrlPath(url));\n }\n\n const potentialStylesResources = new Set<string>();\n for (const { url } of allNodesToClean) {\n if (isFileUrl(url)) {\n potentialStylesResources.add(fileUrlPath(url));\n }\n }\n\n for (const entryPoint of graph.filter(isEntryPoint)) {\n let isDirty = !!entryPoint.cache.stylesheetProcessor?.invalidate(potentialStylesResources)?.length;\n isDirty ||= allNodesToClean.some(dependent => entryPoint.dependents.has(dependent));\n\n if (isDirty) {\n entryPoint.state = STATE_DIRTY;\n\n for (const url of uriToClean) {\n entryPoint.cache.analysesSourcesFileCache.delete(fileUrlPath(url));\n }\n }\n }\n\n return true;\n }),\n filter(isChanged => isChanged),\n debounceTime(100),\n tap(() => log.msg(FileChangeDetected)),\n startWith(undefined),\n map(() => graph),\n );\n }),\n switchMap(graph => {\n return observableOf(graph).pipe(\n buildTransformFactory(project, analyseSourcesTransform, entryPointTransform),\n tap(() => log.msg(CompleteWaitingForFileChange)),\n catchError(error => {\n log.error(error);\n log.msg(FailedWaitingForFileChange);\n\n return NEVER;\n }),\n );\n }),\n );\n };\n\nconst buildTransformFactory =\n (project: string, analyseSourcesTransform: Transform, entryPointTransform: Transform) =>\n (source$: Observable<BuildGraph>): Observable<BuildGraph> => {\n const startTime = Date.now();\n\n const pkgUri = ngUrl(project);\n\n return source$.pipe(\n // Analyse dependencies and external resources for each entry point\n analyseSourcesTransform,\n // Next, run through the entry point transformation (assets rendering, code compilation)\n scheduleEntryPoints(entryPointTransform),\n tap(graph => {\n const ngPkg = graph.get(pkgUri);\n log.success('\\n------------------------------------------------------------------------------');\n log.success(`Built Angular Package\n - from: ${ngPkg.data.src}\n - to: ${ngPkg.data.dest}`);\n log.success('------------------------------------------------------------------------------');\n const b = colors.bold;\n const w = colors.white;\n log.msg(w(`\\nBuild at: ${b(new Date().toISOString())} - Time: ${b('' + (Date.now() - startTime))}ms\\n`));\n }),\n );\n };\n\nconst scheduleEntryPoints = (epTransform: Transform): Transform =>\n pipe(\n concatMap(graph => {\n // Calculate node/dependency depth and determine build order\n const depGraph = new DepGraph({ circular: false });\n for (const node of graph.values()) {\n if (!isEntryPoint(node)) {\n continue;\n }\n\n // Remove `ng://` prefix for better error messages\n const from = node.url.substring(5);\n depGraph.addNode(from);\n\n for (const dep of node.dependents) {\n if (!isEntryPoint(dep)) {\n continue;\n }\n\n const to = dep.url.substring(5);\n depGraph.addNode(to);\n depGraph.addDependency(from, to);\n }\n }\n\n // The array index is the depth.\n const groups = depGraph.overallOrder().map(ngUrl);\n\n // Build entry points with lower depth values first.\n return from(groups).pipe(\n map((epUrl: string): EntryPointNode => graph.find(byEntryPoint().and(ep => ep.url === epUrl))),\n filter((entryPoint: EntryPointNode): boolean => entryPoint.state !== STATE_DONE),\n concatMap(ep =>\n observableOf(ep).pipe(\n // Mark the entry point as 'in-progress'\n tap(entryPoint => (entryPoint.state = STATE_IN_PROGRESS)),\n map(() => graph),\n epTransform,\n ),\n ),\n takeLast(1), // don't use last as sometimes it this will cause 'no elements in sequence',\n defaultIfEmpty(graph),\n );\n }),\n );\n"]}
|
|
@@ -24,32 +24,39 @@ function createCssResourcePlugin(url, cache) {
|
|
|
24
24
|
name: 'angular-css-resource',
|
|
25
25
|
setup(build) {
|
|
26
26
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
27
|
-
var _a
|
|
27
|
+
var _a;
|
|
28
|
+
const { importer, path, kind, resolveDir, namespace, pluginData = {} } = args;
|
|
28
29
|
// Only attempt to resolve url tokens which only exist inside CSS.
|
|
29
30
|
// Also, skip this plugin if already attempting to resolve the url-token.
|
|
30
|
-
if (
|
|
31
|
+
if (kind !== 'url-token' || pluginData[CSS_RESOURCE_RESOLUTION]) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
34
|
+
let [containingDir, resourceUrl] = path.split('||file:', 2);
|
|
35
|
+
if (resourceUrl === undefined) {
|
|
36
|
+
// This can happen due to early exit checks in rebasing-importer
|
|
37
|
+
// logic such as when the url is an external URL.
|
|
38
|
+
resourceUrl = containingDir;
|
|
39
|
+
containingDir = '';
|
|
40
|
+
}
|
|
33
41
|
// If root-relative, absolute or protocol relative url, mark as external to leave the
|
|
34
42
|
// path/URL in place.
|
|
35
|
-
if (url !== stylesheet_processor_1.CssUrl.inline || /^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(
|
|
43
|
+
if (url !== stylesheet_processor_1.CssUrl.inline || /^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(resourceUrl)) {
|
|
36
44
|
return {
|
|
37
|
-
path:
|
|
45
|
+
path: resourceUrl,
|
|
38
46
|
external: true,
|
|
39
47
|
};
|
|
40
48
|
}
|
|
41
|
-
const { importer, kind, resolveDir, namespace, pluginData = {} } = args;
|
|
42
49
|
pluginData[CSS_RESOURCE_RESOLUTION] = true;
|
|
43
|
-
const result = await build.resolve(
|
|
50
|
+
const result = await build.resolve(resourceUrl, {
|
|
44
51
|
importer,
|
|
45
52
|
kind,
|
|
46
53
|
namespace,
|
|
47
54
|
pluginData,
|
|
48
|
-
resolveDir,
|
|
55
|
+
resolveDir: (0, node_path_1.join)(resolveDir, containingDir),
|
|
49
56
|
});
|
|
50
57
|
if (result.errors.length) {
|
|
51
58
|
const error = result.errors[0];
|
|
52
|
-
if (
|
|
59
|
+
if (resourceUrl[0] === '~') {
|
|
53
60
|
error.notes = [
|
|
54
61
|
{
|
|
55
62
|
location: null,
|
|
@@ -57,7 +64,7 @@ function createCssResourcePlugin(url, cache) {
|
|
|
57
64
|
},
|
|
58
65
|
];
|
|
59
66
|
}
|
|
60
|
-
else if (
|
|
67
|
+
else if (resourceUrl[0] === '^') {
|
|
61
68
|
error.notes = [
|
|
62
69
|
{
|
|
63
70
|
location: null,
|
|
@@ -83,7 +90,7 @@ function createCssResourcePlugin(url, cache) {
|
|
|
83
90
|
...result,
|
|
84
91
|
// Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
|
|
85
92
|
// This is only necessary for custom namespaces. esbuild will handle the file namespace.
|
|
86
|
-
path: (0, node_path_1.relative)((
|
|
93
|
+
path: (0, node_path_1.relative)((_a = build.initialOptions.absWorkingDir) !== null && _a !== void 0 ? _a : '', result.path),
|
|
87
94
|
namespace: CSS_RESOURCE_NAMESPACE,
|
|
88
95
|
};
|
|
89
96
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-resource-plugin.js","sourceRoot":"","sources":["../../../../src/lib/styles/stylesheets/css-resource-plugin.ts"],"names":[],"mappings":";;AAsBA,
|
|
1
|
+
{"version":3,"file":"css-resource-plugin.js","sourceRoot":"","sources":["../../../../src/lib/styles/stylesheets/css-resource-plugin.ts"],"names":[],"mappings":";;AAsBA,0DAiGC;AAtHD,+CAA4C;AAC5C,yCAAoD;AACpD,4DAAyE;AACzE,kEAAiD;AAEjD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,GAAW,EAAE,KAAuB;IAC1E,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,KAAK,CAAC,KAAkB;YACtB,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;;gBAC7C,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC;gBAE9E,kEAAkE;gBAClE,yEAAyE;gBACzE,IAAI,IAAI,KAAK,WAAW,IAAI,UAAU,CAAC,uBAAuB,CAAC,EAAE,CAAC;oBAChE,OAAO,IAAI,CAAC;gBACd,CAAC;gBAED,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;gBAC5D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;oBAC9B,gEAAgE;oBAChE,iDAAiD;oBACjD,WAAW,GAAG,aAAa,CAAC;oBAC5B,aAAa,GAAG,EAAE,CAAC;gBACrB,CAAC;gBAED,qFAAqF;gBACrF,qBAAqB;gBACrB,IAAI,GAAG,KAAK,6BAAM,CAAC,MAAM,IAAI,qCAAqC,CAA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O,MAAM,CAAC;gBAChB,CAAC;gBAED,uFAAuF;gBACvF,OAAO;oBACL,GAAG,MAAM;oBACT,yFAAyF;oBACzF,wFAAwF;oBACxF,IAAI,EAAE,IAAA,oBAAQ,EAAC,MAAA,KAAK,CAAC,cAAc,CAAC,aAAa,mCAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC;oBACrE,SAAS,EAAE,sBAAsB;iBAClC,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,MAAM,CACV,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,sBAAsB,EAAE,EAClD,IAAA,oCAAgB,EAAC,KAAK,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;;gBACnC,MAAM,YAAY,GAAG,IAAA,gBAAI,EAAC,MAAA,KAAK,CAAC,cAAc,CAAC,aAAa,mCAAI,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAE/E,OAAO;oBACL,QAAQ,EAAE,MAAM,IAAA,mBAAQ,EAAC,YAAY,CAAC;oBACtC,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE,CAAC,YAAY,CAAC;iBAC3B,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Plugin, PluginBuild } from 'esbuild';\nimport { readFile } from 'node:fs/promises';\nimport { extname, join, relative } from 'node:path';\nimport { LoadResultCache, createCachedLoad } from '../load-result-cache';\nimport { CssUrl } from '../stylesheet-processor';\n\nconst CSS_RESOURCE_NAMESPACE = 'angular:css-resource';\n\n/**\n * Symbol marker used to indicate CSS resource resolution is being attempted.\n * This is used to prevent an infinite loop within the plugin's resolve hook.\n */\nconst CSS_RESOURCE_RESOLUTION = Symbol('CSS_RESOURCE_RESOLUTION');\n\n/**\n * Creates an esbuild {@link Plugin} that loads all CSS url token references using the\n * built-in esbuild `file` loader. A plugin is used to allow for all file extensions\n * and types to be supported without needing to manually specify all extensions\n * within the build configuration.\n *\n * @returns An esbuild {@link Plugin} instance.\n */\nexport function createCssResourcePlugin(url: CssUrl, cache?: LoadResultCache): Plugin {\n return {\n name: 'angular-css-resource',\n setup(build: PluginBuild): void {\n build.onResolve({ filter: /.*/ }, async args => {\n const { importer, path, kind, resolveDir, namespace, pluginData = {} } = args;\n\n // Only attempt to resolve url tokens which only exist inside CSS.\n // Also, skip this plugin if already attempting to resolve the url-token.\n if (kind !== 'url-token' || pluginData[CSS_RESOURCE_RESOLUTION]) {\n return null;\n }\n\n let [containingDir, resourceUrl] = path.split('||file:', 2);\n if (resourceUrl === undefined) {\n // This can happen due to early exit checks in rebasing-importer\n // logic such as when the url is an external URL.\n resourceUrl = containingDir;\n containingDir = '';\n }\n\n // If root-relative, absolute or protocol relative url, mark as external to leave the\n // path/URL in place.\n if (url !== CssUrl.inline || /^((?:\\w+:)?\\/\\/|data:|chrome:|#|\\/)/.test(resourceUrl)) {\n return {\n path: resourceUrl,\n external: true,\n };\n }\n\n pluginData[CSS_RESOURCE_RESOLUTION] = true;\n\n const result = await build.resolve(resourceUrl, {\n importer,\n kind,\n namespace,\n pluginData,\n resolveDir: join(resolveDir, containingDir),\n });\n\n if (result.errors.length) {\n const error = result.errors[0];\n if (resourceUrl[0] === '~') {\n error.notes = [\n {\n location: null,\n text: 'You can remove the tilde and use a relative path to reference it, which should remove this error.',\n },\n ];\n } else if (resourceUrl[0] === '^') {\n error.notes = [\n {\n location: null,\n text: 'You can remove the caret and use a relative path to reference it, which should remove this error.',\n },\n ];\n }\n\n const extension = importer && extname(importer);\n if (extension !== '.css') {\n error.notes.push({\n location: null,\n text: 'Preprocessor stylesheets may not show the exact file location of the error.',\n });\n }\n }\n\n // Return results that are not files since these are most likely specific to another plugin\n // and cannot be loaded by this plugin.\n if (result.namespace !== 'file') {\n return result;\n }\n\n // All file results are considered CSS resources and will be loaded via the file loader\n return {\n ...result,\n // Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).\n // This is only necessary for custom namespaces. esbuild will handle the file namespace.\n path: relative(build.initialOptions.absWorkingDir ?? '', result.path),\n namespace: CSS_RESOURCE_NAMESPACE,\n };\n });\n\n build.onLoad(\n { filter: /./, namespace: CSS_RESOURCE_NAMESPACE },\n createCachedLoad(cache, async args => {\n const resourcePath = join(build.initialOptions.absWorkingDir ?? '', args.path);\n\n return {\n contents: await readFile(resourcePath),\n loader: 'dataurl',\n watchFiles: [resourcePath],\n };\n }),\n );\n },\n };\n}\n"]}
|
|
@@ -38,7 +38,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.cacheCompilerHost = cacheCompilerHost;
|
|
40
40
|
exports.augmentProgramWithVersioning = augmentProgramWithVersioning;
|
|
41
|
-
const convert_source_map_1 = __importDefault(require("convert-source-map"));
|
|
42
41
|
const crypto_1 = require("crypto");
|
|
43
42
|
const esbuild_1 = require("esbuild");
|
|
44
43
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
@@ -63,10 +62,6 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
63
62
|
const node = getNode(fileName);
|
|
64
63
|
entryPoint.dependsOn(node);
|
|
65
64
|
};
|
|
66
|
-
const { flatModuleFile, destinationPath, entryFile } = entryPoint.data.entryPoint;
|
|
67
|
-
const flatModuleFileDtsFilename = `${flatModuleFile}.d.ts`;
|
|
68
|
-
const flatModuleFileDtsPath = (0, path_1.ensureUnixPath)(path.join(destinationPath, flatModuleFileDtsFilename));
|
|
69
|
-
const hasIndexEntryFile = path.basename(entryFile.toLowerCase()) === 'index.ts';
|
|
70
65
|
return {
|
|
71
66
|
...compilerHost,
|
|
72
67
|
// Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse
|
|
@@ -90,7 +85,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
90
85
|
return cache.sourceFile;
|
|
91
86
|
},
|
|
92
87
|
writeFile: (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
|
93
|
-
var _a
|
|
88
|
+
var _a;
|
|
94
89
|
if (fileName.includes('.ngtypecheck.')) {
|
|
95
90
|
return;
|
|
96
91
|
}
|
|
@@ -103,57 +98,23 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
103
98
|
(0, node_assert_1.default)((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1, 'Invalid TypeScript program emit for ' + fileName);
|
|
104
99
|
const outputCache = entryPoint.cache.outputCache;
|
|
105
100
|
if (extension === '.ts') {
|
|
106
|
-
if (fileName === flatModuleFileDtsPath) {
|
|
107
|
-
if (hasIndexEntryFile) {
|
|
108
|
-
// In case the entry file is index.ts, we should not emit the `d.ts` which are a re-export of the `index.ts`.
|
|
109
|
-
// Because it will cause a conflict.
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
// Rename file to index.d.ts so that TypeScript can resolve types without
|
|
114
|
-
// them needing to be referenced in the package.json manifest.
|
|
115
|
-
fileName = fileName.replace(flatModuleFileDtsFilename, 'index.d.ts');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
101
|
for (const source of sourceFiles) {
|
|
119
102
|
const cache = sourcesFileCache.getOrCreate(source.fileName);
|
|
120
103
|
if (!cache.declarationFileName) {
|
|
121
104
|
cache.declarationFileName = (0, path_1.ensureUnixPath)(fileName);
|
|
122
105
|
}
|
|
123
106
|
}
|
|
124
|
-
if (((_a = outputCache.get(fileName)) === null || _a === void 0 ? void 0 : _a.content) === data) {
|
|
125
|
-
// Only emit files that changed content.
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
outputCache.set(fileName, {
|
|
129
|
-
content: data,
|
|
130
|
-
});
|
|
131
107
|
}
|
|
132
108
|
else {
|
|
133
109
|
fileName = fileName.replace(/\.js(\.map)?$/, '.mjs$1');
|
|
134
|
-
if (((_b = outputCache.get(fileName)) === null || _b === void 0 ? void 0 : _b.content) === data) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
// Extract inline sourcemap which will later be used by rollup.
|
|
138
|
-
let map = undefined;
|
|
139
|
-
const version = (0, crypto_1.createHash)('sha256').update(data).digest('hex');
|
|
140
|
-
if (fileName.endsWith('.mjs')) {
|
|
141
|
-
if (((_c = outputCache.get(fileName)) === null || _c === void 0 ? void 0 : _c.version) === version) {
|
|
142
|
-
// Only emit changed files
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
map = convert_source_map_1.default.fromComment(data).toJSON();
|
|
146
|
-
}
|
|
147
|
-
outputCache.set(fileName, {
|
|
148
|
-
content: data,
|
|
149
|
-
version,
|
|
150
|
-
map,
|
|
151
|
-
});
|
|
152
110
|
}
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
111
|
+
if (((_a = outputCache.get(fileName)) === null || _a === void 0 ? void 0 : _a.content) === data) {
|
|
112
|
+
return;
|
|
156
113
|
}
|
|
114
|
+
outputCache.set(fileName, {
|
|
115
|
+
content: data,
|
|
116
|
+
version: (0, crypto_1.createHash)('sha256').update(data).digest('hex'),
|
|
117
|
+
});
|
|
157
118
|
},
|
|
158
119
|
readFile: (fileName) => {
|
|
159
120
|
addDependee(fileName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,8CAkQC;AAED,oEAaC;AAhSD,4EAAkD;AAClD,mCAAoC;AACpC,qCAAyC;AACzC,8DAAiC;AACjC,2CAA6B;AAC7B,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,sCAA2C;AAC3C,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EA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IAAA,WAAK,EAAC,GAAG,CAAC,CAAC,CAAC;oBAEpF,MAAM,IAAI,KAAK,CAAC,0CAA0C,cAAc,GAAG,CAAC,CAAC;gBAC/E,CAAC;gBAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC/B,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAAC,OAAmB;IAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAClD,OAAO,CAAC,cAAc,GAAG,UAAU,GAAG,UAAU;QAC9C,MAAM,KAAK,GAAsD,kBAAkB,CAAC,GAAG,UAAU,CAAC,CAAC;QAEnG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { CompilerHost, CompilerOptions } from '@angular/compiler-cli';\nimport convertSourceMap from 'convert-source-map';\nimport { createHash } from 'crypto';\nimport { formatMessages } from 'esbuild';\nimport assert from 'node:assert';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { error, warn } from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n const { flatModuleFile, destinationPath, entryFile } = entryPoint.data.entryPoint;\n const flatModuleFileDtsFilename = `${flatModuleFile}.d.ts`;\n const flatModuleFileDtsPath = ensureUnixPath(path.join(destinationPath, flatModuleFileDtsFilename));\n const hasIndexEntryFile = path.basename(entryFile.toLowerCase()) === 'index.ts';\n\n return {\n ...compilerHost,\n\n // Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse\n // performance improvement by skipping non-type related JSDoc parsing.\n jsDocParsingMode: ts.JSDocParsingMode.ParseForTypeErrors,\n\n // ts specific\n getModuleResolutionCache: () => moduleResolutionCache,\n\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile, ...parameters) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n\n if (shouldCreateNewSourceFile || !cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(\n this,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.includes('.ngtypecheck.')) {\n return;\n }\n\n const extension = path.extname(fileName);\n\n if (!sourceFiles?.length && extension === '.tsbuildinfo') {\n // Save builder info contents to specified location\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n\n return;\n }\n\n assert(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);\n const outputCache = entryPoint.cache.outputCache;\n\n if (extension === '.ts') {\n if (fileName === flatModuleFileDtsPath) {\n if (hasIndexEntryFile) {\n // In case the entry file is index.ts, we should not emit the `d.ts` which are a re-export of the `index.ts`.\n // Because it will cause a conflict.\n return;\n } else {\n // Rename file to index.d.ts so that TypeScript can resolve types without\n // them needing to be referenced in the package.json manifest.\n fileName = fileName.replace(flatModuleFileDtsFilename, 'index.d.ts');\n }\n }\n\n for (const source of sourceFiles) {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n }\n\n if (outputCache.get(fileName)?.content === data) {\n // Only emit files that changed content.\n return;\n }\n\n outputCache.set(fileName, {\n content: data,\n });\n } else {\n fileName = fileName.replace(/\\.js(\\.map)?$/, '.mjs$1');\n if (outputCache.get(fileName)?.content === data) {\n return;\n }\n\n // Extract inline sourcemap which will later be used by rollup.\n let map = undefined;\n const version = createHash('sha256').update(data).digest('hex');\n\n if (fileName.endsWith('.mjs')) {\n if (outputCache.get(fileName)?.version === version) {\n // Only emit changed files\n return;\n }\n\n map = convertSourceMap.fromComment(data).toJSON();\n }\n\n outputCache.set(fileName, {\n content: data,\n version,\n map,\n });\n }\n\n if (extension === '.ts' || (extension === '.map' && fileName.endsWith('.d.ts.map'))) {\n // Only write .d.ts and .d.ts.map files to disk.\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n }\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n\n return cache.content;\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n const {\n referencedFiles,\n contents,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleFile(fileName);\n const node = getNode(fileName);\n const depNodes = [...referencedFiles].map(getNode).filter(n => n !== node);\n node.dependsOn(depNodes);\n\n for (const n of node.dependees) {\n if (n.url.endsWith('.ts')) {\n n.dependsOn(depNodes);\n }\n }\n\n if (esBuildWarnings?.length > 0) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length > 0) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${fileName}.`);\n }\n\n return contents;\n }\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n transformResource: async (data, context) => {\n const { containingFile, resourceFile, type } = context;\n\n if (resourceFile || type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const {\n contents,\n referencedFiles,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleInline(\n data,\n containingFile,\n containingFile.endsWith('.html') ? 'css' : inlineStyleLanguage,\n );\n\n const node = getNode(containingFile);\n node.dependsOn([...referencedFiles].map(getNode));\n\n if (esBuildWarnings?.length > 0) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length > 0) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${containingFile}.`);\n }\n\n return { content: contents };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,8CAqNC;AAED,oEAaC;AAlPD,mCAAoC;AACpC,qCAAyC;AACzC,8DAAiC;AACjC,2CAA6B;AAC7B,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,sCAA2C;AAC3C,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,IAAI,WAAI,CAAC,OAAO,CAAC,CAAC;YACz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ompilerOptions } from '@angular/compiler-cli';\nimport { createHash } from 'crypto';\nimport { formatMessages } from 'esbuild';\nimport assert from 'node:assert';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { error, warn } from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n return {\n ...compilerHost,\n\n // Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse\n // performance improvement by skipping non-type related JSDoc parsing.\n jsDocParsingMode: ts.JSDocParsingMode.ParseForTypeErrors,\n\n // ts specific\n getModuleResolutionCache: () => moduleResolutionCache,\n\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile, ...parameters) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n\n if (shouldCreateNewSourceFile || !cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(\n this,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.includes('.ngtypecheck.')) {\n return;\n }\n\n const extension = path.extname(fileName);\n if (!sourceFiles?.length && extension === '.tsbuildinfo') {\n // Save builder info contents to specified location\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n\n return;\n }\n\n assert(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);\n const outputCache = entryPoint.cache.outputCache;\n\n if (extension === '.ts') {\n for (const source of sourceFiles) {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n }\n } else {\n fileName = fileName.replace(/\\.js(\\.map)?$/, '.mjs$1');\n }\n\n if (outputCache.get(fileName)?.content === data) {\n return;\n }\n\n outputCache.set(fileName, {\n content: data,\n version: createHash('sha256').update(data).digest('hex'),\n });\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n\n return cache.content;\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n const {\n referencedFiles,\n contents,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleFile(fileName);\n const node = getNode(fileName);\n const depNodes = [...referencedFiles].map(getNode).filter(n => n !== node);\n node.dependsOn(depNodes);\n\n for (const n of node.dependees) {\n if (n.url.endsWith('.ts')) {\n n.dependsOn(depNodes);\n }\n }\n\n if (esBuildWarnings?.length > 0) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length > 0) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${fileName}.`);\n }\n\n return contents;\n }\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n transformResource: async (data, context) => {\n const { containingFile, resourceFile, type } = context;\n\n if (resourceFile || type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const {\n contents,\n referencedFiles,\n errors: esbuildErrors,\n warnings: esBuildWarnings,\n } = await stylesheetProcessor.bundleInline(\n data,\n containingFile,\n containingFile.endsWith('.html') ? 'css' : inlineStyleLanguage,\n );\n\n const node = getNode(containingFile);\n node.dependsOn([...referencedFiles].map(getNode));\n\n if (esBuildWarnings?.length > 0) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length > 0) {\n (await formatMessages(esbuildErrors, { kind: 'error' })).forEach(msg => error(msg));\n\n throw new Error(`An error has occuried while processing ${containingFile}.`);\n }\n\n return { content: contents };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
"baseUrl": ".",
|
|
11
11
|
"target": "es2022",
|
|
12
12
|
"module": "es2022",
|
|
13
|
-
"moduleResolution": "
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
14
|
"outDir": "AUTOGENERATED",
|
|
15
15
|
"declaration": true,
|
|
16
16
|
"declarationDir": "AUTOGENERATED",
|
|
17
|
-
"
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"inlineSourceMap": false,
|
|
18
19
|
"inlineSources": true,
|
|
19
20
|
"skipLibCheck": true,
|
|
20
21
|
"emitDecoratorMetadata": false,
|
package/lib/ts/tsconfig.js
CHANGED
|
@@ -52,9 +52,9 @@ async function readDefaultTsConfig(fileName = exports.defaultTsConfigPath) {
|
|
|
52
52
|
const extraOptions = {
|
|
53
53
|
target: typescript_1.default.ScriptTarget.ES2022,
|
|
54
54
|
// sourcemaps
|
|
55
|
-
sourceMap:
|
|
55
|
+
sourceMap: true,
|
|
56
56
|
inlineSources: true,
|
|
57
|
-
inlineSourceMap:
|
|
57
|
+
inlineSourceMap: false,
|
|
58
58
|
outDir: '',
|
|
59
59
|
declaration: true,
|
|
60
60
|
// Disable removing of comments as TS is quite aggressive with these and can
|
|
@@ -132,7 +132,7 @@ function setDependenciesTsConfigPaths(parsedTsConfig, entryPoints, pointToSource
|
|
|
132
132
|
for (const dep of entryPoints) {
|
|
133
133
|
const { entryPoint } = dep.data;
|
|
134
134
|
const { moduleId, destinationFiles, entryFilePath } = entryPoint;
|
|
135
|
-
const mappedPath = [pointToSource ? entryFilePath : destinationFiles.
|
|
135
|
+
const mappedPath = [pointToSource ? entryFilePath : destinationFiles.declarationsBundled];
|
|
136
136
|
if (!tsConfig.options.paths[moduleId]) {
|
|
137
137
|
tsConfig.options.paths[moduleId] = mappedPath;
|
|
138
138
|
}
|
package/lib/ts/tsconfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,gDA6BC;AAYD,oEAyBC;AA7HD,2CAA6B;AAC7B,4DAA4B;AAE5B,gDAAkD;AAClD,kDAAoC;AAEvB,QAAA,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;AACrF;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAAC,QAAQ,GAAG,2BAAmB;IAC/D,8BAA8B;IAC9B,MAAM,YAAY,GAAoB;QACpC,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;QAE9B,aAAa;QACb,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"tsconfig.js","sourceRoot":"","sources":["../../../src/lib/ts/tsconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,gDA6BC;AAYD,oEAyBC;AA7HD,2CAA6B;AAC7B,4DAA4B;AAE5B,gDAAkD;AAClD,kDAAoC;AAEvB,QAAA,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC;AACrF;;GAEG;AACH,KAAK,UAAU,mBAAmB,CAAC,QAAQ,GAAG,2BAAmB;IAC/D,8BAA8B;IAC9B,MAAM,YAAY,GAAoB;QACpC,MAAM,EAAE,oBAAE,CAAC,YAAY,CAAC,MAAM;QAE9B,aAAa;QACb,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,KAAK;QAEtB,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,IAAI;QAEjB,4EAA4E;QAC5E,wDAAwD;QACxD,cAAc,EAAE,KAAK;QAErB,cAAc;QACd,sBAAsB,EAAE,IAAI;QAE5B,sDAAsD;QACtD,YAAY,EAAE,eAAe;Q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AAM,CAAC;YACN,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { CompilerOptions, ParsedConfiguration } from '@angular/compiler-cli';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { EntryPointNode } from '../ng-package/nodes';\nimport { ngCompilerCli } from '../utils/load-esm';\nimport * as log from '../utils/log';\n\nexport const defaultTsConfigPath = path.join(__dirname, 'conf', 'tsconfig.ngc.json');\n/**\n * Reads the default TypeScript configuration.\n */\nasync function readDefaultTsConfig(fileName = defaultTsConfigPath): Promise<ParsedConfiguration> {\n // these options are mandatory\n const extraOptions: CompilerOptions = {\n target: ts.ScriptTarget.ES2022,\n\n // sourcemaps\n sourceMap: true,\n inlineSources: true,\n inlineSourceMap: false,\n\n outDir: '',\n declaration: true,\n\n // Disable removing of comments as TS is quite aggressive with these and can\n // remove important annotations, such as /* @__PURE__ */\n removeComments: false,\n\n // ng compiler\n enableResourceInlining: true,\n\n // these are required to set the appropriate EmitFlags\n flatModuleId: 'AUTOGENERATED',\n flatModuleOutFile: 'AUTOGENERATED',\n };\n\n const { readConfiguration } = await ngCompilerCli();\n\n return readConfiguration(fileName, extraOptions);\n}\n\n/**\n * Creates a parsed TypeScript configuration object.\n *\n * @param values File path or parsed configuration.\n */\nasync function createDefaultTsConfig(values?: ParsedConfiguration | string): Promise<ParsedConfiguration> {\n if (!values) {\n return readDefaultTsConfig();\n } else if (typeof values === 'string') {\n return readDefaultTsConfig(values);\n } else {\n return values;\n }\n}\n\n/**\n * Initializes TypeScript Compiler options and Angular Compiler options by overriding the\n * default config with entry point-specific values.\n */\nexport async function initializeTsConfig(\n defaultTsConfig: ParsedConfiguration | string | undefined,\n entryPoints: EntryPointNode[],\n): Promise<void> {\n const defaultTsConfigParsed = await createDefaultTsConfig(defaultTsConfig);\n if (defaultTsConfigParsed.errors.length > 0) {\n const { formatDiagnostics } = await ngCompilerCli();\n throw new Error(formatDiagnostics(defaultTsConfigParsed.errors));\n }\n\n for (const currentEntryPoint of entryPoints) {\n const { entryPoint } = currentEntryPoint.data;\n log.debug(`Initializing tsconfig for ${entryPoint.moduleId}`);\n const basePath = path.dirname(entryPoint.entryFilePath);\n\n // Resolve defaults from DI token and create a deep copy of the defaults\n const tsConfig: ParsedConfiguration = JSON.parse(JSON.stringify(defaultTsConfigParsed));\n const overrideOptions: CompilerOptions = {\n flatModuleId: entryPoint.moduleId,\n flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,\n basePath,\n rootDir: basePath,\n sourceRoot: '',\n };\n\n tsConfig.rootNames = [entryPoint.entryFilePath];\n tsConfig.options = { ...tsConfig.options, ...overrideOptions };\n currentEntryPoint.data.tsConfig = tsConfig;\n }\n}\n\n/**\n * Set the paths for entrypoint dependencies.\n *\n * This doesn't mutate the object.\n *\n * @param parsedTsConfig - A parsed tsconfig\n * @param entryPoints - A list of entryPoints\n * @param pointToSource Point the path mapping to either the source code or emitted declarations.\n * Typically for analysis one should point to the source files while for a compilation once should use the emitted declarations\n */\nexport function setDependenciesTsConfigPaths(\n parsedTsConfig: ParsedConfiguration,\n entryPoints: EntryPointNode[],\n pointToSource = false,\n): ParsedConfiguration {\n const tsConfig = JSON.parse(JSON.stringify(parsedTsConfig));\n\n // Add paths mappings for dependencies\n if (!tsConfig.options.paths) {\n tsConfig.options.paths = {};\n }\n\n for (const dep of entryPoints) {\n const { entryPoint } = dep.data;\n const { moduleId, destinationFiles, entryFilePath } = entryPoint;\n const mappedPath = [pointToSource ? entryFilePath : destinationFiles.declarationsBundled];\n\n if (!tsConfig.options.paths[moduleId]) {\n tsConfig.options.paths[moduleId] = mappedPath;\n } else {\n tsConfig.options.paths[moduleId].unshift(...mappedPath);\n }\n }\n\n return tsConfig;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "20.0.0-next.
|
|
3
|
+
"version": "20.0.0-next.3",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"browserslist": "^4.22.1",
|
|
41
41
|
"chokidar": "^4.0.1",
|
|
42
42
|
"commander": "^13.0.0",
|
|
43
|
-
"convert-source-map": "^2.0.0",
|
|
44
43
|
"dependency-graph": "^1.0.0",
|
|
45
44
|
"esbuild": "^0.25.0",
|
|
46
45
|
"find-cache-dir": "^3.3.2",
|
|
@@ -50,6 +49,7 @@
|
|
|
50
49
|
"ora": "^5.1.0",
|
|
51
50
|
"piscina": "^4.7.0",
|
|
52
51
|
"postcss": "^8.4.47",
|
|
52
|
+
"rollup-plugin-dts": "^6.2.0",
|
|
53
53
|
"rxjs": "^7.8.1",
|
|
54
54
|
"sass": "^1.81.0",
|
|
55
55
|
"tinyglobby": "^0.2.12"
|