ng-packagr 17.0.1 → 17.0.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/lib/flatten/rollup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { OutputAsset, OutputChunk, RollupCache } from 'rollup';
|
|
2
2
|
import { OutputFileCache } from '../ng-package/nodes';
|
|
3
3
|
/**
|
|
4
4
|
* Options used in `ng-packagr` for writing flat bundle files.
|
|
@@ -11,13 +11,13 @@ export interface RollupOptions {
|
|
|
11
11
|
entryName: string;
|
|
12
12
|
dir: string;
|
|
13
13
|
sourceRoot: string;
|
|
14
|
-
cache?:
|
|
14
|
+
cache?: RollupCache;
|
|
15
15
|
cacheDirectory?: string | false;
|
|
16
16
|
fileCache: OutputFileCache;
|
|
17
17
|
cacheKey: string;
|
|
18
18
|
}
|
|
19
19
|
/** Runs rollup over the given entry file, writes a bundle file. */
|
|
20
20
|
export declare function rollupBundleFile(opts: RollupOptions): Promise<{
|
|
21
|
-
cache:
|
|
22
|
-
files: (
|
|
21
|
+
cache: RollupCache;
|
|
22
|
+
files: (OutputChunk | OutputAsset)[];
|
|
23
23
|
}>;
|
package/lib/flatten/rollup.js
CHANGED
|
@@ -30,13 +30,14 @@ exports.rollupBundleFile = void 0;
|
|
|
30
30
|
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
31
31
|
const plugin_node_resolve_1 = __importDefault(require("@rollup/plugin-node-resolve"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
|
-
const rollup = __importStar(require("rollup"));
|
|
34
33
|
const cache_1 = require("../utils/cache");
|
|
35
34
|
const log = __importStar(require("../utils/log"));
|
|
36
35
|
const file_loader_plugin_1 = require("./file-loader-plugin");
|
|
36
|
+
let rollup;
|
|
37
37
|
/** Runs rollup over the given entry file, writes a bundle file. */
|
|
38
38
|
async function rollupBundleFile(opts) {
|
|
39
39
|
var _a;
|
|
40
|
+
await ensureRollup();
|
|
40
41
|
log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
|
|
41
42
|
const cacheDirectory = opts.cacheDirectory;
|
|
42
43
|
// Create the bundle
|
|
@@ -84,6 +85,19 @@ async function rollupBundleFile(opts) {
|
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
exports.rollupBundleFile = rollupBundleFile;
|
|
88
|
+
async function ensureRollup() {
|
|
89
|
+
if (rollup) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
rollup = await Promise.resolve().then(() => __importStar(require('rollup')));
|
|
94
|
+
log.debug(`rollup using native version.`);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
rollup = await Promise.resolve().then(() => __importStar(require('@rollup/wasm-node')));
|
|
98
|
+
log.debug(`rollup using wasm version.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
87
101
|
function isExternalDependency(moduleId) {
|
|
88
102
|
// more information about why we don't check for 'node_modules' path
|
|
89
103
|
// https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAC7C,sFAAsD;AACtD,2CAA6B;
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAC7C,sFAAsD;AACtD,2CAA6B;AAG7B,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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,GAAG,oBAAoB;QACrD,cAAc,EAAE,IAAI,CAAC,SAAS,GAAG,MAAM;QACvC,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACnF;IAED,gFAAgF;IAChF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AAzDD,4CAyDC;AAED,KAAK,UAAU,YAAY;IACzB,IAAI,MAAM,EAAE;QACV,OAAO;KACR;IAED,IAAI;QACF,MAAM,GAAG,wDAAa,QAAQ,GAAC,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;KAC3C;IAAC,MAAM;QACN,MAAM,GAAG,wDAAa,mBAAmB,GAAC,CAAC;QAC3C,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;KACzC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACrF,yGAAyG;QACzG,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as path from 'path';\nimport type { OutputAsset, OutputChunk, RollupCache } from 'rollup';\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 sourceRoot: string;\n cache?: RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\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\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: [nodeResolve(), rollupJson(), fileLoaderPlugin(opts.fileCache)],\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 chunkFileNames: opts.entryName + '-[name]-[hash].mjs',\n entryFileNames: opts.entryName + '.mjs',\n banner: '',\n sourcemap: true,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, JSON.stringify(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,\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.startsWith('.') || moduleId.startsWith('/') || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return false;\n }\n\n return true;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.2",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@rollup/plugin-json": "^6.0.1",
|
|
36
36
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
37
|
+
"@rollup/wasm-node": "^4.5.0",
|
|
37
38
|
"ajv": "^8.12.0",
|
|
38
39
|
"ansi-colors": "^4.1.3",
|
|
39
40
|
"autoprefixer": "^10.4.16",
|
|
@@ -53,12 +54,12 @@
|
|
|
53
54
|
"piscina": "^4.1.0",
|
|
54
55
|
"postcss": "^8.4.31",
|
|
55
56
|
"postcss-url": "^10.1.3",
|
|
56
|
-
"rollup": "^4.2.0",
|
|
57
57
|
"rxjs": "^7.8.1",
|
|
58
58
|
"sass": "^1.69.5"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"esbuild": "^0.19.0"
|
|
61
|
+
"esbuild": "^0.19.0",
|
|
62
|
+
"rollup": "^4.5.0"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"@angular/compiler-cli": "^17.0.0 || ^17.0.0-next.0",
|