ng-packagr 22.2.0-next.0 → 22.2.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -7
- package/src/lib/flatten/file-loader-plugin.d.ts +1 -1
- package/src/lib/flatten/file-loader-plugin.js.map +1 -1
- package/src/lib/flatten/rolldown.d.ts +19 -0
- package/src/lib/flatten/{rollup.js → rolldown.js} +26 -40
- package/src/lib/flatten/rolldown.js.map +1 -0
- package/src/lib/ng-package/entry-point/write-bundles.transform.js +4 -12
- package/src/lib/ng-package/entry-point/write-bundles.transform.js.map +1 -1
- package/src/lib/ng-package/nodes.d.ts +0 -3
- package/src/lib/ng-package/nodes.js.map +1 -1
- package/src/lib/ts/cache-compiler-host.js +14 -11
- package/src/lib/ts/cache-compiler-host.js.map +1 -1
- package/src/lib/flatten/rollup.d.ts +0 -23
- package/src/lib/flatten/rollup.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "22.2.0-next.
|
|
3
|
+
"version": "22.2.0-next.2",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -33,8 +33,6 @@
|
|
|
33
33
|
"typings": "./src/public_api.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@ampproject/remapping": "^2.3.0",
|
|
36
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
37
|
-
"@rollup/wasm-node": "^4.24.0",
|
|
38
36
|
"ajv": "^8.17.1",
|
|
39
37
|
"browserslist": "^4.26.0",
|
|
40
38
|
"chokidar": "^5.0.0",
|
|
@@ -48,14 +46,12 @@
|
|
|
48
46
|
"ora": "^9.0.0",
|
|
49
47
|
"piscina": "^5.0.0",
|
|
50
48
|
"postcss": "^8.4.47",
|
|
51
|
-
"
|
|
49
|
+
"rolldown": "^1.2.0",
|
|
50
|
+
"rolldown-plugin-dts": "^0.27.14",
|
|
52
51
|
"rxjs": "^7.8.1",
|
|
53
52
|
"sass": "^1.81.0",
|
|
54
53
|
"tinyglobby": "^0.2.12"
|
|
55
54
|
},
|
|
56
|
-
"optionalDependencies": {
|
|
57
|
-
"rollup": "^4.24.0"
|
|
58
|
-
},
|
|
59
55
|
"peerDependencies": {
|
|
60
56
|
"@angular/compiler-cli": "^22.0.0 || ^22.1.0-next || ^22.2.0-next",
|
|
61
57
|
"tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,4CAoDC;AAnED,yCAA6C;AAI7C,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B,EAAE,oBAA8B,EAAE,OAAgB;IAC3G,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ;YAC/B,MAAM,YAAY,GAAG,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC;YACxC,IAAI,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,OAAO,YAAY,CAAC;YACtB,CAAC;YAED,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAChD,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;oBACnD,IAAI,OAAO,EAAE,CAAC;wBACZ,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,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,EAAE,WAAW,CAAC,CAAC,CAAC;YACzE,IAAI,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;gBAC1C,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;gBACpC,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC7B,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,EAAE,UAAU,EAAE;YAChB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YAC/B,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/B,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;YACzD,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO;aACzC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { dirname, resolve } from 'node:path';\nimport type { Plugin } from 'rolldown';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * A regex used to strip the file extension from a file path.\n */\nconst FILE_EXT_REGEXP = /\\.(c|m)?(t|j)s$/;\n\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache, resolutionExtensions: string[], dtsMode: boolean): Plugin {\n return {\n name: 'file-loader',\n resolveId: function (id, importer) {\n const normalizedId = ensureUnixPath(id);\n if (fileCache.has(normalizedId)) {\n return normalizedId;\n }\n\n const potentialId = normalizedId.endsWith('.d.ts')\n ? normalizedId\n : normalizedId.replace(FILE_EXT_REGEXP, (_match, p1) => {\n if (dtsMode) {\n return p1 ? `.d.${p1}ts` : '.d.ts';\n }\n\n return p1 ? `.${p1}js` : '.js';\n });\n\n if (fileCache.has(potentialId)) {\n return potentialId;\n }\n\n if (!importer) {\n return;\n }\n\n const resolved = ensureUnixPath(resolve(dirname(importer), potentialId));\n if (fileCache.has(resolved)) {\n return resolved;\n }\n\n for (const suffix of resolutionExtensions) {\n const potential = resolved + suffix;\n if (fileCache.has(potential)) {\n return potential;\n }\n }\n },\n load: function (id) {\n log.debug(`file-loader ${id}`);\n const data = fileCache.get(id);\n if (!data) {\n throw new Error(`Could not load '${id}' from memory.`);\n }\n\n return {\n code: data.content,\n map: fileCache.get(`${id}.map`)?.content,\n };\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type OutputAsset, type OutputChunk } from 'rolldown';
|
|
2
|
+
import { OutputFileCache } from '../ng-package/nodes';
|
|
3
|
+
/**
|
|
4
|
+
* Options used in `ng-packagr` for writing flat bundle files.
|
|
5
|
+
*
|
|
6
|
+
* These options are passed through to rolldown.
|
|
7
|
+
*/
|
|
8
|
+
export interface RolldownOptions {
|
|
9
|
+
moduleName: string;
|
|
10
|
+
entry: string;
|
|
11
|
+
entryName: string;
|
|
12
|
+
dir: string;
|
|
13
|
+
fileCache: OutputFileCache;
|
|
14
|
+
sourcemap: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Runs rolldown over the given entry file, writes a bundle file. */
|
|
17
|
+
export declare function rolldownBundleFile(opts: RolldownOptions): Promise<{
|
|
18
|
+
files: (OutputChunk | OutputAsset)[];
|
|
19
|
+
}>;
|
|
@@ -32,40 +32,35 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
36
|
+
exports.rolldownBundleFile = rolldownBundleFile;
|
|
41
37
|
const path = __importStar(require("path"));
|
|
42
|
-
const
|
|
43
|
-
const
|
|
38
|
+
const rolldown_1 = require("rolldown");
|
|
39
|
+
const rolldown_plugin_dts_1 = require("rolldown-plugin-dts");
|
|
44
40
|
const log = __importStar(require("../utils/log"));
|
|
45
41
|
const file_loader_plugin_1 = require("./file-loader-plugin");
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
await ensureRollup();
|
|
50
|
-
log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
|
|
51
|
-
const cacheDirectory = opts.cacheDirectory;
|
|
42
|
+
/** Runs rolldown over the given entry file, writes a bundle file. */
|
|
43
|
+
async function rolldownBundleFile(opts) {
|
|
44
|
+
log.debug(`rolldown ${opts.entry} to ${opts.dir}`);
|
|
52
45
|
const dtsMode = opts.entry.endsWith('.d.ts');
|
|
53
46
|
let outExtension;
|
|
54
47
|
let plugins;
|
|
55
48
|
const jail = path.dirname(opts.entry);
|
|
56
49
|
if (dtsMode) {
|
|
57
50
|
outExtension = '.d.ts';
|
|
58
|
-
plugins = [
|
|
51
|
+
plugins = [
|
|
52
|
+
(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode),
|
|
53
|
+
(0, rolldown_plugin_dts_1.dts)({ generator: 'oxc', sourcemap: opts.sourcemap }),
|
|
54
|
+
];
|
|
59
55
|
}
|
|
60
56
|
else {
|
|
61
57
|
outExtension = '.mjs';
|
|
62
|
-
plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.js', '/index.js'], dtsMode)
|
|
58
|
+
plugins = [(0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache, ['.js', '/index.js'], dtsMode)];
|
|
63
59
|
}
|
|
64
60
|
// Create the bundle
|
|
65
|
-
const bundle = await
|
|
61
|
+
const bundle = await (0, rolldown_1.rolldown)({
|
|
66
62
|
context: 'this',
|
|
67
63
|
external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),
|
|
68
|
-
cache: opts.cache ?? (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
|
|
69
64
|
input: opts.entry,
|
|
70
65
|
plugins,
|
|
71
66
|
onwarn: warning => {
|
|
@@ -80,7 +75,12 @@ async function rollupBundleFile(opts) {
|
|
|
80
75
|
break;
|
|
81
76
|
}
|
|
82
77
|
},
|
|
83
|
-
|
|
78
|
+
experimental: {
|
|
79
|
+
attachDebugInfo: 'none',
|
|
80
|
+
},
|
|
81
|
+
resolve: {
|
|
82
|
+
symlinks: false,
|
|
83
|
+
},
|
|
84
84
|
// Disable treeshaking when generating bundles
|
|
85
85
|
// see: https://github.com/angular/angular/pull/32069
|
|
86
86
|
treeshake: false,
|
|
@@ -90,50 +90,36 @@ async function rollupBundleFile(opts) {
|
|
|
90
90
|
name: opts.moduleName,
|
|
91
91
|
format: 'es',
|
|
92
92
|
dir: opts.dir,
|
|
93
|
-
importAttributesKey: 'with',
|
|
94
|
-
inlineDynamicImports: false,
|
|
95
93
|
hoistTransitiveImports: false,
|
|
96
94
|
chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,
|
|
97
95
|
entryFileNames: opts.entryName + outExtension,
|
|
98
96
|
banner: '',
|
|
99
97
|
sourcemap: opts.sourcemap,
|
|
98
|
+
comments: {
|
|
99
|
+
legal: true,
|
|
100
|
+
annotation: true,
|
|
101
|
+
jsdoc: dtsMode,
|
|
102
|
+
},
|
|
100
103
|
});
|
|
101
|
-
if (cacheDirectory) {
|
|
102
|
-
await (0, cache_1.saveCacheEntry)(cacheDirectory, opts.cacheKey, bundle.cache);
|
|
103
|
-
}
|
|
104
104
|
// Close the bundle to let plugins clean up their external processes or services
|
|
105
105
|
await bundle.close();
|
|
106
106
|
return {
|
|
107
107
|
files: output.output.map(f => {
|
|
108
108
|
/** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
|
|
109
109
|
if (f.type === 'chunk') {
|
|
110
|
-
f
|
|
110
|
+
Object.defineProperty(f, 'map', { value: null, configurable: true });
|
|
111
111
|
}
|
|
112
112
|
return f;
|
|
113
113
|
}),
|
|
114
|
-
cache: bundle.cache,
|
|
115
114
|
};
|
|
116
115
|
}
|
|
117
|
-
async function ensureRollup() {
|
|
118
|
-
if (rollup) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
rollup = await Promise.resolve().then(() => __importStar(require('rollup')));
|
|
123
|
-
log.debug(`rollup using native version.`);
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
rollup = await Promise.resolve().then(() => __importStar(require('@rollup/wasm-node')));
|
|
127
|
-
log.debug(`rollup using wasm version.`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
116
|
function isExternalDependency(moduleId, parentId, jail) {
|
|
131
117
|
// more information about why we don't check for 'node_modules' path
|
|
132
118
|
// https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632
|
|
133
119
|
if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {
|
|
134
120
|
// if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib
|
|
135
|
-
return !path.join(parentId, moduleId).startsWith(jail);
|
|
121
|
+
return !parentId || !path.join(parentId, moduleId).startsWith(jail);
|
|
136
122
|
}
|
|
137
123
|
return true;
|
|
138
124
|
}
|
|
139
|
-
//# sourceMappingURL=
|
|
125
|
+
//# sourceMappingURL=rolldown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rolldown.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rolldown.ts"],"names":[],"mappings":";;;;;;;;;;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AAI,EAAE,CAAC,CAAC;YACvE,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB,EAAE,QAA4B,EAAE,IAAY;IACxF,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as path from 'path';\nimport { type OutputAsset, type OutputChunk, type RolldownPluginOption, rolldown } from 'rolldown';\nimport { dts } from 'rolldown-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport * as log from '../utils/log';\nimport { fileLoaderPlugin } from './file-loader-plugin';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rolldown.\n */\nexport interface RolldownOptions {\n moduleName: string;\n entry: string;\n entryName: string;\n dir: string;\n fileCache: OutputFileCache;\n sourcemap: boolean;\n}\n\n/** Runs rolldown over the given entry file, writes a bundle file. */\nexport async function rolldownBundleFile(opts: RolldownOptions): Promise<{ files: (OutputChunk | OutputAsset)[] }> {\n log.debug(`rolldown ${opts.entry} to ${opts.dir}`);\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: RolldownPluginOption[];\n const jail = path.dirname(opts.entry);\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [\n fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode),\n dts({ generator: 'oxc', sourcemap: opts.sourcemap }),\n ];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js'], dtsMode)];\n }\n\n // Create the bundle\n const bundle = await rolldown({\n context: 'this',\n external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),\n input: opts.entry,\n plugins,\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n case 'EMPTY_BUNDLE':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n experimental: {\n attachDebugInfo: 'none',\n },\n resolve: {\n symlinks: false,\n },\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n dir: opts.dir,\n hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n comments: {\n legal: true,\n annotation: true,\n jsdoc: dtsMode,\n },\n });\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n files: output.output.map(f => {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n if (f.type === 'chunk') {\n Object.defineProperty(f, 'map', { value: null, configurable: true });\n }\n\n return f;\n }),\n };\n}\n\nfunction isExternalDependency(moduleId: string, parentId: string | undefined, jail: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return !parentId || !path.join(parentId, moduleId).startsWith(jail);\n }\n\n return true;\n}\n"]}
|
|
@@ -7,7 +7,7 @@ exports.writeBundlesTransform = void 0;
|
|
|
7
7
|
const ora_1 = __importDefault(require("ora"));
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const file_watcher_1 = require("../../file-system/file-watcher");
|
|
10
|
-
const
|
|
10
|
+
const rolldown_1 = require("../../flatten/rolldown");
|
|
11
11
|
const transform_1 = require("../../graph/transform");
|
|
12
12
|
const cache_1 = require("../../utils/cache");
|
|
13
13
|
const fs_1 = require("../../utils/fs");
|
|
@@ -63,32 +63,24 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
async function generateBundles() {
|
|
66
|
-
const [{
|
|
67
|
-
(0,
|
|
66
|
+
const [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([
|
|
67
|
+
(0, rolldown_1.rolldownBundleFile)({
|
|
68
68
|
entry: esm2022,
|
|
69
69
|
entryName: ngEntryPoint.flatModuleFile,
|
|
70
70
|
moduleName: ngEntryPoint.moduleId,
|
|
71
71
|
dir: fesm2022Dir,
|
|
72
|
-
cache: cache.rollupFESM2022Cache,
|
|
73
|
-
cacheDirectory,
|
|
74
72
|
fileCache: cache.outputCache,
|
|
75
|
-
cacheKey,
|
|
76
73
|
sourcemap: true,
|
|
77
74
|
}),
|
|
78
|
-
(0,
|
|
75
|
+
(0, rolldown_1.rolldownBundleFile)({
|
|
79
76
|
entry: declarations,
|
|
80
77
|
entryName: ngEntryPoint.flatModuleFile,
|
|
81
78
|
moduleName: ngEntryPoint.moduleId,
|
|
82
79
|
dir: declarationsDir,
|
|
83
|
-
cache: cache.rollupTypesCache,
|
|
84
|
-
cacheDirectory,
|
|
85
80
|
fileCache: cache.outputCache,
|
|
86
|
-
cacheKey,
|
|
87
81
|
sourcemap: tsConfig.options.declarationMap ?? false,
|
|
88
82
|
}),
|
|
89
83
|
]);
|
|
90
|
-
cache.rollupFESM2022Cache = rollupFESM2022Cache;
|
|
91
|
-
cache.rollupTypesCache = rollupTypesCache;
|
|
92
84
|
return {
|
|
93
85
|
hash,
|
|
94
86
|
types: typesFiles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA4B;AAE5B,iEAA2F;AAC3F,
|
|
1
|
+
{"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA4B;AAE5B,iEAA2F;AAC3F,qDAA4D;AAC5D,qDAA6D;AAC7D,6CAAgF;AAChF,uCAA0D;AAC1D,2CAAkD;AAClD,oCAAoD;AAS7C,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAG,IAAA,gCAAwB,EAAC,KAAK,CAAC,CAAC;IACnD,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAAC;IACjF,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAChC,YAAY,CAAC,QAAQ,EACrB,eAAe,EACf,WAAW,EACX,QAAQ,CAAC,OAAO,CAAC,eAAe,EAChC,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,CACtD,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAW,EAAC,CAAC,GAAG,KAAK,C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AC;QACnB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,CAAC,CAAC;AAxHQ,QAAA,qBAAqB,yBAwH7B","sourcesContent":["import ora from 'ora';\nimport { join } from 'path';\nimport type { OutputAsset, OutputChunk } from 'rolldown';\nimport { invalidateEntryPointsAndCacheOnFileChange } from '../../file-system/file-watcher';\nimport { rolldownBundleFile } from '../../flatten/rolldown';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { exists, mkdir, writeFile } from '../../utils/fs';\nimport { ensureUnixPath } from '../../utils/path';\nimport { findEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2022: (OutputChunk | OutputAsset)[];\n types: (OutputChunk | OutputAsset)[];\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint = findEntryPointInProgress(graph);\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2022Dir, esm2022, declarations, declarationsDir } = destinationFiles;\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const cacheKey = await generateKey(\n ngEntryPoint.moduleId,\n declarationsDir,\n fesm2022Dir,\n tsConfig.options.compilationMode,\n (tsConfig.options.declarationMap ?? false).toString(),\n );\n\n const hash = await generateKey([...cache.outputCache.values()].map(({ version }) => version).join(':'));\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, cacheKey);\n if (cacheResult?.hash === hash) {\n const filesToCopy = [\n ...cacheResult.fesm2022.map(file => ({\n ...file,\n filePath: join(fesm2022Dir, file.fileName),\n })),\n ...cacheResult.types.map(file => ({\n ...file,\n filePath: join(declarationsDir, file.fileName),\n })),\n ];\n\n try {\n const writeFilePromises: Promise<void>[] = [];\n for (const file of filesToCopy) {\n if (options.watch && (await exists(file.filePath))) {\n continue;\n }\n\n if (writeFilePromises.length === 0) {\n spinner.start('Writing FESM and DTS bundles');\n await Promise.all([mkdir(fesm2022Dir, { recursive: true }), mkdir(declarationsDir, { recursive: true })]);\n }\n\n writeFilePromises.push(writeFile(file.filePath, file.type === 'asset' ? file.source : file.code));\n }\n\n if (writeFilePromises.length) {\n await Promise.all(writeFilePromises);\n spinner.succeed('Writing FESM and DTS bundles');\n }\n } catch (error) {\n spinner.fail('Writing FESM and DTS bundles');\n throw error;\n }\n\n return;\n }\n }\n\n async function generateBundles(): Promise<BundlesCache> {\n const [{ files: fesmFiles }, { files: typesFiles }] = await Promise.all([\n rolldownBundleFile({\n entry: esm2022,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: fesm2022Dir,\n fileCache: cache.outputCache,\n sourcemap: true,\n }),\n rolldownBundleFile({\n entry: declarations,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n dir: declarationsDir,\n fileCache: cache.outputCache,\n sourcemap: tsConfig.options.declarationMap ?? false,\n }),\n ]);\n\n return {\n hash,\n types: typesFiles,\n fesm2022: fesmFiles,\n };\n }\n\n let cacheRollup: BundlesCache;\n try {\n cacheRollup = await generateBundles();\n spinner.succeed(`Generating FESM and DTS bundles`);\n\n // Invalidate dependent entry-points\n const changedDtsFiles: string[] = [];\n for (const file of cacheRollup.types) {\n if (file.type !== 'chunk' || !file.fileName.endsWith('.d.ts')) {\n continue;\n }\n\n const dtsFile = ensureUnixPath(join(declarationsDir, file.fileName));\n const cachedSourceFile = cache.sourcesFileCache.get(dtsFile);\n if (cachedSourceFile?.sourceFile?.text !== file.code) {\n changedDtsFiles.push(dtsFile);\n }\n }\n\n if (changedDtsFiles.length) {\n invalidateEntryPointsAndCacheOnFileChange(graph, changedDtsFiles, cache.sourcesFileCache);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, cacheKey, cacheRollup);\n }\n });\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';
|
|
2
|
-
import type { RollupCache } from 'rollup';
|
|
3
2
|
import ts from 'typescript';
|
|
4
3
|
import { FileCache } from '../file-system/file-cache';
|
|
5
4
|
import { BuildGraph, ComplexPredicate } from '../graph/build-graph';
|
|
@@ -32,8 +31,6 @@ export declare class EntryPointNode extends Node {
|
|
|
32
31
|
sourcesFileCache: FileCache;
|
|
33
32
|
analysesSourcesFileCache: FileCache;
|
|
34
33
|
moduleResolutionCache: ts.ModuleResolutionCache;
|
|
35
|
-
rollupFESM2022Cache?: RollupCache;
|
|
36
|
-
rollupTypesCache?: RollupCache;
|
|
37
34
|
stylesheetProcessor?: StylesheetProcessor;
|
|
38
35
|
oldNgtscProgram?: NgtscProgram;
|
|
39
36
|
oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAoBA,oCAEC;AAED,8BAEC;AAED,oCAEC;AAED,wDAEC;AAED,kDAEC;AAED,4DAOC;AAED,0CAOC;AAED,0BAEC;AAED,kCAEC;AAED,sBAEC;AAnED,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA8D;AAC9D,gFAA2E;AAK3E,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAEzD,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,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ACrC,OAAO,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxF,CAAC;AAED,SAAgB,KAAK,CAAC,IAAY;IAChC,OAAO,GAAG,eAAe,GAAG,IAAI,EAAE,CAAC;AACrC,CAAC;AAID,MAAa,cAAe,SAAQ,WAAI;IAIpB;IAHT,IAAI,GAAG,mBAAmB,CAAC;IAEpC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QAJK,QAAG,GAAH,GAAG,CAAQ;QAM3B,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,wBAAwB,EAAE,IAAI,sBAAS,EAAE;YACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;YACtB,sBAAsB,EAAE,IAAI,mDAAuB,EAAE;SACtD,CAAC;IACJ,CAAC;IAED,KAAK,CAUH;IAQF,OAAO;QACL,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF;AAzCD,wCAyCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAC1B,IAAI,GAAG,eAAe,CAAC;IAGhC,KAAK,GAAG;QACN,gBAAgB,EAAE,IAAI,sBAAS,EAAE;QACjC,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC7E,CAAC;CACH;AARD,kCAQC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph, ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isInProgress, isPending } from '../graph/select';\nimport { AngularDiagnosticsCache } from '../ngc/angular-diagnostics-cache';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\n\nconst TYPE_NG_PACKAGE = 'application/ng-package';\nconst TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\n/** A node that can be read through the `fs` api. */\nconst URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nconst URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isInProgress(n));\n}\n\nexport function isEntryPointPending(): ComplexPredicate<EntryPointNode> {\n return by(n => isEntryPoint(n) && isPending(n));\n}\n\nexport function findEntryPointInProgress(graph: BuildGraph): EntryPointNode {\n const entryPoint = graph.find(isEntryPointInProgress());\n if (!entryPoint) {\n throw new Error('Could not find entry point in progress');\n }\n\n return entryPoint;\n}\n\nexport function findPackageNode(graph: BuildGraph): PackageNode {\n const packageNode: PackageNode | undefined = graph.find(isPackage);\n if (!packageNode) {\n throw new Error('Could not find package node in build graph');\n }\n\n return packageNode;\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string | null {\n return url.startsWith(URL_PROTOCOL_FILE) ? url.slice(URL_PROTOCOL_FILE.length) : null;\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version?: string; content: string }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n analysesSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n angularDiagnosticCache: new AngularDiagnosticsCache(),\n };\n }\n\n cache: {\n outputCache: OutputFileCache;\n oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;\n sourcesFileCache: FileCache;\n analysesSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n angularDiagnosticCache: AngularDiagnosticsCache;\n };\n\n declare data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n\n dispose(): void {\n this.cache.stylesheetProcessor?.destroy();\n this.cache = undefined;\n }\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n declare data: NgPackage;\n\n cache = {\n sourcesFileCache: new FileCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
|
|
@@ -72,7 +72,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
72
72
|
fileExists: (fileName) => {
|
|
73
73
|
const cache = sourcesFileCache.getOrCreate(fileName);
|
|
74
74
|
if (cache.exists === undefined) {
|
|
75
|
-
cache.exists = compilerHost.fileExists
|
|
75
|
+
cache.exists = compilerHost.fileExists(fileName);
|
|
76
76
|
}
|
|
77
77
|
return cache.exists;
|
|
78
78
|
},
|
|
@@ -80,7 +80,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
80
80
|
addDependee(fileName);
|
|
81
81
|
const cache = sourcesFileCache.getOrCreate(fileName);
|
|
82
82
|
if (shouldCreateNewSourceFile || !cache.sourceFile) {
|
|
83
|
-
cache.sourceFile = compilerHost.getSourceFile
|
|
83
|
+
cache.sourceFile = compilerHost.getSourceFile(fileName, languageVersion, onError, true, ...parameters);
|
|
84
84
|
}
|
|
85
85
|
return cache.sourceFile;
|
|
86
86
|
},
|
|
@@ -91,7 +91,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
91
91
|
const extension = path.extname(fileName);
|
|
92
92
|
if (!sourceFiles?.length && extension === '.tsbuildinfo') {
|
|
93
93
|
// Save builder info contents to specified location
|
|
94
|
-
compilerHost.writeFile
|
|
94
|
+
compilerHost.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
(0, node_assert_1.default)(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + fileName);
|
|
@@ -108,7 +108,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
108
108
|
addDependee(fileName);
|
|
109
109
|
const cache = sourcesFileCache.getOrCreate(fileName);
|
|
110
110
|
if (cache.content === undefined) {
|
|
111
|
-
cache.content = compilerHost.readFile
|
|
111
|
+
cache.content = compilerHost.readFile(fileName);
|
|
112
112
|
}
|
|
113
113
|
return cache.content;
|
|
114
114
|
},
|
|
@@ -128,23 +128,26 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
128
128
|
}
|
|
129
129
|
if (/(?:html?|svg)$/.test(path.extname(fileName))) {
|
|
130
130
|
// template
|
|
131
|
-
cache.content = compilerHost.readFile
|
|
131
|
+
cache.content = compilerHost.readFile(fileName);
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
134
|
// stylesheet
|
|
135
|
+
if (!stylesheetProcessor) {
|
|
136
|
+
throw new Error('stylesheetProcessor is not available for processing stylesheets');
|
|
137
|
+
}
|
|
135
138
|
const { referencedFiles, contents, errors: esbuildErrors, warnings: esBuildWarnings, } = await stylesheetProcessor.bundleFile(fileName);
|
|
136
139
|
const node = getNode(fileName);
|
|
137
|
-
const depNodes = [...referencedFiles].map(getNode).filter(n => n !== node);
|
|
140
|
+
const depNodes = [...(referencedFiles ?? [])].map(getNode).filter(n => n !== node);
|
|
138
141
|
node.dependsOn(depNodes);
|
|
139
142
|
for (const n of node.dependees) {
|
|
140
143
|
if (n.url.endsWith('.ts')) {
|
|
141
144
|
n.dependsOn(depNodes);
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
|
-
if (esBuildWarnings?.length
|
|
147
|
+
if (esBuildWarnings?.length) {
|
|
145
148
|
(await (0, esbuild_1.formatMessages)(esBuildWarnings, { kind: 'warning' })).forEach(msg => (0, log_1.warn)(msg));
|
|
146
149
|
}
|
|
147
|
-
if (esbuildErrors?.length
|
|
150
|
+
if (esbuildErrors?.length) {
|
|
148
151
|
(await (0, esbuild_1.formatMessages)(esbuildErrors, { kind: 'error' })).forEach(msg => (0, log_1.error)(msg));
|
|
149
152
|
throw new Error(`An error has occuried while processing ${fileName}.`);
|
|
150
153
|
}
|
|
@@ -152,7 +155,7 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
152
155
|
}
|
|
153
156
|
cache.exists = true;
|
|
154
157
|
}
|
|
155
|
-
return cache.content;
|
|
158
|
+
return cache.content ?? '';
|
|
156
159
|
},
|
|
157
160
|
transformResource: async (data, context) => {
|
|
158
161
|
const { containingFile, resourceFile, type } = context;
|
|
@@ -163,10 +166,10 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
163
166
|
const { contents, referencedFiles, errors: esbuildErrors, warnings: esBuildWarnings, } = await stylesheetProcessor.bundleInline(data, containingFile, containingFile.endsWith('.html') ? 'css' : inlineStyleLanguage);
|
|
164
167
|
const node = getNode(containingFile);
|
|
165
168
|
node.dependsOn([...referencedFiles].map(getNode));
|
|
166
|
-
if (esBuildWarnings?.length
|
|
169
|
+
if (esBuildWarnings?.length) {
|
|
167
170
|
(await (0, esbuild_1.formatMessages)(esBuildWarnings, { kind: 'warning' })).forEach(msg => (0, log_1.warn)(msg));
|
|
168
171
|
}
|
|
169
|
-
if (esbuildErrors?.length
|
|
172
|
+
if (esbuildErrors?.length) {
|
|
170
173
|
(await (0, esbuild_1.formatMessages)(esbuildErrors, { kind: 'error' })).forEach(msg => (0, log_1.error)(msg));
|
|
171
174
|
throw new Error(`An error has occuried while processing ${containingFile}.`);
|
|
172
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,8CAyMC;AAED,oEAaC;AAtOD,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;YACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CA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AM,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 { 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 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"]}
|
|
1
|
+
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,8CAqMC;AAED,oEAaC;AAlOD,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;YACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QAED,OAAO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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 { 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(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(fileName, languageVersion, onError, true, ...parameters);\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(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 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(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): Promise<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(fileName);\n } else {\n // stylesheet\n if (!stylesheetProcessor) {\n throw new Error('stylesheetProcessor is not available for processing stylesheets');\n }\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) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length) {\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) {\n (await formatMessages(esBuildWarnings, { kind: 'warning' })).forEach(msg => warn(msg));\n }\n\n if (esbuildErrors?.length) {\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,23 +0,0 @@
|
|
|
1
|
-
import type { OutputAsset, OutputChunk, RollupCache } from 'rollup';
|
|
2
|
-
import { OutputFileCache } from '../ng-package/nodes';
|
|
3
|
-
/**
|
|
4
|
-
* Options used in `ng-packagr` for writing flat bundle files.
|
|
5
|
-
*
|
|
6
|
-
* These options are passed through to rollup.
|
|
7
|
-
*/
|
|
8
|
-
export interface RollupOptions {
|
|
9
|
-
moduleName: string;
|
|
10
|
-
entry: string;
|
|
11
|
-
entryName: string;
|
|
12
|
-
dir: string;
|
|
13
|
-
cache?: RollupCache;
|
|
14
|
-
cacheDirectory?: string | false;
|
|
15
|
-
fileCache: OutputFileCache;
|
|
16
|
-
cacheKey: string;
|
|
17
|
-
sourcemap: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** Runs rollup over the given entry file, writes a bundle file. */
|
|
20
|
-
export declare function rollupBundleFile(opts: RollupOptions): Promise<{
|
|
21
|
-
cache: RollupCache;
|
|
22
|
-
files: (OutputChunk | OutputAsset)[];
|
|
23
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,4CA8EC;AA3GD,sEAA6C;AAC7C,2CAA6B;AAE7B,yDAAwC;AAExC,0CAAgE;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AAO;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,EAAE,QAAgB,EAAE,IAAY;IAC5E,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,yGAAyG;QACzG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport * as path from 'path';\nimport type { InputPluginOption, OutputAsset, OutputChunk, RollupCache } from 'rollup';\nimport { dts } from 'rollup-plugin-dts';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { fileLoaderPlugin } from './file-loader-plugin';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n entryName: string;\n dir: string;\n cache?: RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n sourcemap: boolean;\n}\n\nlet rollup: typeof import('rollup') | undefined;\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: RollupCache; files: (OutputChunk | OutputAsset)[] }> {\n await ensureRollup();\n\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);\n const cacheDirectory = opts.cacheDirectory;\n const dtsMode = opts.entry.endsWith('.d.ts');\n let outExtension: string;\n let plugins: InputPluginOption[];\n const jail = path.dirname(opts.entry);\n\n if (dtsMode) {\n outExtension = '.d.ts';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.d.ts', '/index.d.ts'], dtsMode), dts({ sourcemap: opts.sourcemap })];\n } else {\n outExtension = '.mjs';\n plugins = [fileLoaderPlugin(opts.fileCache, ['.js', '/index.js'], dtsMode), rollupJson()];\n }\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: (moduleId, parentId) => isExternalDependency(moduleId, parentId, jail),\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins,\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n case 'EMPTY_BUNDLE':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n dir: opts.dir,\n importAttributesKey: 'with',\n inlineDynamicImports: false,\n hoistTransitiveImports: false,\n chunkFileNames: `${opts.entryName}-[name]-[hash]${outExtension}`,\n entryFileNames: opts.entryName + outExtension,\n banner: '',\n sourcemap: opts.sourcemap,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, bundle.cache);\n }\n\n // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\n\n return {\n files: output.output.map(f => {\n /** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */\n if (f.type === 'chunk') {\n f.map = null;\n }\n\n return f;\n }),\n cache: bundle.cache,\n };\n}\n\nasync function ensureRollup(): Promise<void> {\n if (rollup) {\n return;\n }\n\n try {\n rollup = await import('rollup');\n log.debug(`rollup using native version.`);\n } catch {\n rollup = await import('@rollup/wasm-node');\n log.debug(`rollup using wasm version.`);\n }\n}\n\nfunction isExternalDependency(moduleId: string, parentId: string, jail: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId[0] === '.' || moduleId[0] === '/' || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return !path.join(parentId, moduleId).startsWith(jail);\n }\n\n return true;\n}\n"]}
|