ng-packagr 17.3.0 → 18.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/flatten/esbuild.d.ts +20 -0
- package/lib/flatten/esbuild.js +72 -0
- package/lib/flatten/esbuild.js.map +1 -0
- package/lib/ng-package/entry-point/write-bundles.transform.js +8 -67
- package/lib/ng-package/entry-point/write-bundles.transform.js.map +1 -1
- package/lib/ng-package/nodes.d.ts +2 -2
- package/lib/ng-package/nodes.js.map +1 -1
- package/lib/ng-package/package.transform.js +2 -1
- package/lib/ng-package/package.transform.js.map +1 -1
- package/lib/styles/stylesheet-processor-worker.js +4 -6
- package/lib/styles/stylesheet-processor-worker.js.map +1 -1
- package/lib/utils/load-esm.d.ts +0 -1
- package/package.json +9 -11
- package/lib/esbuild/esbuild-executor.d.ts +0 -48
- package/lib/esbuild/esbuild-executor.js +0 -130
- package/lib/esbuild/esbuild-executor.js.map +0 -1
- package/lib/flatten/file-loader-plugin.d.ts +0 -6
- package/lib/flatten/file-loader-plugin.js +0 -49
- package/lib/flatten/file-loader-plugin.js.map +0 -1
- package/lib/flatten/rollup.d.ts +0 -23
- package/lib/flatten/rollup.js +0 -110
- package/lib/flatten/rollup.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BuildContext, BuildOptions } from 'esbuild';
|
|
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 BundleOptions {
|
|
9
|
+
moduleName: string;
|
|
10
|
+
entry: string;
|
|
11
|
+
outdir: string;
|
|
12
|
+
entryName: string;
|
|
13
|
+
buildContext?: BuildContext;
|
|
14
|
+
fileCache: OutputFileCache;
|
|
15
|
+
watch: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function bundle({ entryName, entry, watch, buildContext, outdir }: BundleOptions): Promise<{
|
|
18
|
+
esbuildContext: BuildContext<BuildOptions>;
|
|
19
|
+
outputFiles: import("esbuild").OutputFile[];
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.bundle = void 0;
|
|
27
|
+
const esbuild_1 = require("esbuild");
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const log = __importStar(require("../utils/log"));
|
|
30
|
+
async function bundle({ entryName, entry, watch, buildContext, outdir }) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const dir = path.dirname(entry);
|
|
33
|
+
const esbuildOptions = {
|
|
34
|
+
format: 'esm',
|
|
35
|
+
outdir,
|
|
36
|
+
bundle: true,
|
|
37
|
+
logLevel: 'silent',
|
|
38
|
+
minify: false,
|
|
39
|
+
legalComments: 'eof',
|
|
40
|
+
packages: 'external',
|
|
41
|
+
write: true,
|
|
42
|
+
entryPoints: [entry],
|
|
43
|
+
resolveExtensions: ['.mjs', '.js'],
|
|
44
|
+
preserveSymlinks: true,
|
|
45
|
+
sourcemap: 'linked',
|
|
46
|
+
absWorkingDir: dir,
|
|
47
|
+
splitting: true,
|
|
48
|
+
treeShaking: false,
|
|
49
|
+
chunkNames: entryName + '-[name]-[hash]',
|
|
50
|
+
entryNames: entryName,
|
|
51
|
+
outExtension: { '.js': '.mjs' },
|
|
52
|
+
charset: 'utf8',
|
|
53
|
+
};
|
|
54
|
+
let esbuildContext;
|
|
55
|
+
if (watch) {
|
|
56
|
+
esbuildContext = buildContext !== null && buildContext !== void 0 ? buildContext : (await (0, esbuild_1.context)(esbuildOptions));
|
|
57
|
+
}
|
|
58
|
+
const { outputFiles, errors, warnings } = await ((_b = (_a = esbuildContext === null || esbuildContext === void 0 ? void 0 : esbuildContext.rebuild) === null || _a === void 0 ? void 0 : _a.call(esbuildContext)) !== null && _b !== void 0 ? _b : (0, esbuild_1.build)(esbuildOptions));
|
|
59
|
+
if (warnings.length > 0) {
|
|
60
|
+
log.warn((await (0, esbuild_1.formatMessages)(warnings, { kind: 'warning' })).join('\n'));
|
|
61
|
+
}
|
|
62
|
+
if (errors.length > 0) {
|
|
63
|
+
log.error((await (0, esbuild_1.formatMessages)(errors, { kind: 'error' })).join('\n'));
|
|
64
|
+
throw new Error(`An error has occuried while processing ${entry}.`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
esbuildContext,
|
|
68
|
+
outputFiles: outputFiles,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.bundle = bundle;
|
|
72
|
+
//# sourceMappingURL=es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8DAAI,mCAAI,IAAA,eAAK,EAAC,cAAc,CAAC,CAAC,CAAC;IAEvG,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAA,wBAAc,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,IAAA,wBAAc,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAExE,MAAM,IAAI,KAAK,CAAC,0CAA0C,KAAK,GAAG,CAAC,CAAC;IACtE,CAAC;IAED,OAAO;QACL,cAAc;QACd,WAAW,EAAE,WAAW;KACzB,CAAC;AACJ,CAAC;AA7CD,wBA6CC","sourcesContent":["import { BuildContext, BuildOptions, build, context, formatMessages } from 'esbuild';\nimport * as path from 'path';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport * as log from '../utils/log';\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 BundleOptions {\n moduleName: string;\n entry: string;\n outdir: string;\n entryName: string;\n buildContext?: BuildContext;\n fileCache: OutputFileCache;\n watch: boolean;\n}\n\nexport async function bundle({ entryName, entry, watch, buildContext, outdir }: BundleOptions) {\n const dir = path.dirname(entry);\n const esbuildOptions: BuildOptions = {\n format: 'esm',\n outdir,\n bundle: true,\n logLevel: 'silent',\n minify: false,\n legalComments: 'eof',\n packages: 'external',\n write: true,\n entryPoints: [entry],\n resolveExtensions: ['.mjs', '.js'],\n preserveSymlinks: true,\n sourcemap: 'linked',\n absWorkingDir: dir,\n splitting: true,\n treeShaking: false,\n chunkNames: entryName + '-[name]-[hash]',\n entryNames: entryName,\n outExtension: { '.js': '.mjs' },\n charset: 'utf8',\n };\n\n let esbuildContext: BuildContext | undefined;\n if (watch) {\n esbuildContext = buildContext ?? (await context(esbuildOptions));\n }\n\n const { outputFiles, errors, warnings } = await (esbuildContext?.rebuild?.() ?? build(esbuildOptions));\n\n if (warnings.length > 0) {\n log.warn((await formatMessages(warnings, { kind: 'warning' })).join('\\n'));\n }\n\n if (errors.length > 0) {\n log.error((await formatMessages(errors, { kind: 'error' })).join('\\n'));\n\n throw new Error(`An error has occuried while processing ${entry}.`);\n }\n\n return {\n esbuildContext,\n outputFiles: outputFiles,\n };\n}\n"]}
|
|
@@ -5,94 +5,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeBundlesTransform = void 0;
|
|
7
7
|
const ora_1 = __importDefault(require("ora"));
|
|
8
|
-
const
|
|
9
|
-
const rollup_1 = require("../../flatten/rollup");
|
|
8
|
+
const esbuild_1 = require("../../flatten/esbuild");
|
|
10
9
|
const transform_1 = require("../../graph/transform");
|
|
11
|
-
const cache_1 = require("../../utils/cache");
|
|
12
|
-
const fs_1 = require("../../utils/fs");
|
|
13
10
|
const nodes_1 = require("../nodes");
|
|
14
11
|
const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)(async (graph) => {
|
|
15
12
|
const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
|
|
16
|
-
const { destinationFiles, entryPoint: ngEntryPoint
|
|
13
|
+
const { destinationFiles, entryPoint: ngEntryPoint } = entryPoint.data;
|
|
17
14
|
const cache = entryPoint.cache;
|
|
18
15
|
const { fesm2022Dir, esm2022 } = destinationFiles;
|
|
19
16
|
const spinner = (0, ora_1.default)({
|
|
20
17
|
hideCursor: false,
|
|
21
18
|
discardStdin: false,
|
|
22
19
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (cacheDirectory) {
|
|
27
|
-
const cacheResult = await (0, cache_1.readCacheEntry)(options.cacheDirectory, key);
|
|
28
|
-
let writing = false;
|
|
29
|
-
if ((cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult.hash) === hash) {
|
|
30
|
-
try {
|
|
31
|
-
for (const file of cacheResult.fesm2022) {
|
|
32
|
-
const filePath = (0, path_1.join)(fesm2022Dir, file.fileName);
|
|
33
|
-
if (options.watch && await (0, fs_1.exists)(filePath)) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (!writing) {
|
|
37
|
-
writing = true;
|
|
38
|
-
spinner.start('Writing FESM bundles');
|
|
39
|
-
await (0, fs_1.mkdir)(fesm2022Dir, { recursive: true });
|
|
40
|
-
}
|
|
41
|
-
await (0, fs_1.writeFile)(filePath, file.type === 'asset' ? file.source : file.code);
|
|
42
|
-
}
|
|
43
|
-
if (writing) {
|
|
44
|
-
spinner.succeed('Writing FESM bundles');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
if (!writing) {
|
|
49
|
-
spinner.start('Writing FESM bundles');
|
|
50
|
-
}
|
|
51
|
-
spinner.fail();
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async function generateFESM(rollupCache, dir) {
|
|
58
|
-
const { cache: rollupFESMCache, files } = await (0, rollup_1.rollupBundleFile)({
|
|
59
|
-
sourceRoot: tsConfig.options.sourceRoot,
|
|
20
|
+
try {
|
|
21
|
+
const result = await (0, esbuild_1.bundle)({
|
|
22
|
+
buildContext: cache.esbuildBuildContext,
|
|
60
23
|
entry: esm2022,
|
|
24
|
+
outdir: fesm2022Dir,
|
|
61
25
|
entryName: ngEntryPoint.flatModuleFile,
|
|
62
26
|
moduleName: ngEntryPoint.moduleId,
|
|
63
|
-
|
|
64
|
-
cache: rollupCache,
|
|
65
|
-
cacheDirectory,
|
|
27
|
+
watch: options.watch,
|
|
66
28
|
fileCache: cache.outputCache,
|
|
67
|
-
cacheKey: await (0, cache_1.generateKey)(esm2022, dir, ngEntryPoint.moduleId, tsConfig.options.compilationMode),
|
|
68
29
|
});
|
|
69
|
-
|
|
70
|
-
/** The map contents are in an asset file type, which makes storing the map in the cache as redudant. */
|
|
71
|
-
files: files.map(f => {
|
|
72
|
-
if (f.type === 'chunk') {
|
|
73
|
-
f.map = null;
|
|
74
|
-
}
|
|
75
|
-
return f;
|
|
76
|
-
}),
|
|
77
|
-
rollupCache: options.watch ? rollupFESMCache : undefined,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const fesmCache = {
|
|
81
|
-
hash,
|
|
82
|
-
};
|
|
83
|
-
try {
|
|
84
|
-
const { rollupCache, files } = await generateFESM(cache.rollupFESM2022Cache, fesm2022Dir);
|
|
85
|
-
cache.rollupFESM2022Cache = rollupCache;
|
|
86
|
-
fesmCache.fesm2022 = files;
|
|
30
|
+
cache.esbuildBuildContext = result.esbuildContext;
|
|
87
31
|
spinner.succeed(`Generating FESM bundles`);
|
|
88
32
|
}
|
|
89
33
|
catch (error) {
|
|
90
34
|
spinner.fail();
|
|
91
35
|
throw error;
|
|
92
36
|
}
|
|
93
|
-
if (cacheDirectory) {
|
|
94
|
-
await (0, cache_1.saveCacheEntry)(cacheDirectory, key, JSON.stringify(fesmCache));
|
|
95
|
-
}
|
|
96
37
|
});
|
|
97
38
|
exports.writeBundlesTransform = writeBundlesTransform;
|
|
98
39
|
//# sourceMappingURL=write-bundles.transform.js.map
|
|
@@ -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
|
|
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,mDAA+C;AAC/C,qDAA6D;AAC7D,oCAAkE;AAG3D,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,GAAG,UAAU,CAAC,IAAI,CAAC;IACvE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;IAElD,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,gBAAM,EAAC;YAC1B,YAAY,EAAE,KAAK,CAAC,mBAAmB;YACvC,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,YAAY,CAAC,cAAc;YACtC,UAAU,EAAE,YAAY,CAAC,QAAQ;YACjC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,SAAS,EAAE,KAAK,CAAC,WAAW;SAC7B,CAAC,CAAC;QAEH,KAAK,CAAC,mBAAmB,GAAG,MAAM,CAAC,cAAc,CAAC;QAElD,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC,CAAC;AA9BQ,QAAA,qBAAqB,yBA8B7B","sourcesContent":["import ora from 'ora';\nimport { bundle } from '../../flatten/esbuild';\nimport { transformFromPromise } from '../../graph/transform';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2022Dir, esm2022 } = destinationFiles;\n\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n try {\n const result = await bundle({\n buildContext: cache.esbuildBuildContext,\n entry: esm2022,\n outdir: fesm2022Dir,\n entryName: ngEntryPoint.flatModuleFile,\n moduleName: ngEntryPoint.moduleId,\n watch: options.watch,\n fileCache: cache.outputCache,\n });\n\n cache.esbuildBuildContext = result.esbuildContext;\n\n spinner.succeed(`Generating FESM bundles`);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n });\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';
|
|
2
|
-
import
|
|
2
|
+
import { BuildContext } from 'esbuild';
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { FileCache } from '../file-system/file-cache';
|
|
5
5
|
import { ComplexPredicate } from '../graph/build-graph';
|
|
@@ -37,7 +37,7 @@ export declare class EntryPointNode extends Node {
|
|
|
37
37
|
sourcesFileCache: FileCache;
|
|
38
38
|
analysesSourcesFileCache: FileCache;
|
|
39
39
|
moduleResolutionCache: ts.ModuleResolutionCache;
|
|
40
|
-
|
|
40
|
+
esbuildBuildContext?: BuildContext;
|
|
41
41
|
stylesheetProcessor?: StylesheetProcessor;
|
|
42
42
|
oldNgtscProgram?: NgtscProgram;
|
|
43
43
|
oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAC5B,0DAAs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,OAAO,GAAG,uBAAe,GAAG,IAAI,EAAE,CAAC;AACrC,CAAC;AAFD,sBAEC;AAID,MAAa,cAAe,SAAQ,WAAI;IAGtC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QAJK,QAAG,GAAH,GAAG,CAAQ;QAHpB,SAAI,GAAG,2BAAmB,CAAC;QASlC,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,wBAAwB,EAAE,IAAI,sBAAS,EAAE;YACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;CAmBF;AAnCD,wCAmCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAArC;;QACW,SAAI,GAAG,uBAAe,CAAC;QAGhC,UAAK,GAAG;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
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA4D;AAK/C,QAAA,eAAe,GAAG,wBAAwB,CAAC;AAC3C,QAAA,mBAAmB,GAAG,4BAA4B,CAAC;AAEhE,oDAAoD;AACvC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C,kCAAkC;AACrB,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC,SAAgB,YAAY,CAAC,IAAU;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,2BAAmB,CAAC;AAC3C,CAAC;AAFD,oCAEC;AAED,SA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ACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;CAmBF;AAnCD,wCAmCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAArC;;QACW,SAAI,GAAG,uBAAe,CAAC;QAGhC,UAAK,GAAG;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 { BuildContext } from 'esbuild';\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 { 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; map?: any }>;\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 };\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 esbuildBuildContext?: BuildContext;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\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"]}
|
|
@@ -85,10 +85,11 @@ const packageTransformFactory = (project, options, initTsConfigTransform, analys
|
|
|
85
85
|
initTsConfigTransform,
|
|
86
86
|
// perform build
|
|
87
87
|
buildTransform, (0, rxjs_1.finalize)(() => {
|
|
88
|
-
var _a;
|
|
88
|
+
var _a, _b;
|
|
89
89
|
for (const node of ngPkg.dependents) {
|
|
90
90
|
if (node instanceof nodes_1.EntryPointNode) {
|
|
91
91
|
(_a = node.cache.stylesheetProcessor) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
92
|
+
void ((_b = node.cache.esbuildBuildContext) === null || _b === void 0 ? void 0 : _b.dispose());
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
}));
|
|
@@ -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,mCASiB;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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,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 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]);\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 (!cachedSourceFile) {\n if (!nodesToClean) {\n return;\n }\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 for (const entryPoint of graph.filter(isEntryPoint)) {\n const isDirty = [...allNodesToClean].some(dependent => entryPoint.dependents.has(dependent));\n if (isDirty) {\n entryPoint.state = STATE_DIRTY;\n\n uriToClean.forEach(url => {\n entryPoint.cache.analysesSourcesFileCache.delete(fileUrlPath(url));\n });\n }\n }\n }),\n debounceTime(200),\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 const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n\n for (const entryPoint of entryPoints) {\n // Remove `ng://` prefix for better error messages\n const from = entryPoint.url.substring(5);\n depGraph.addNode(from);\n\n for (const { url } of entryPoint.filter(isEntryPoint)) {\n const to = 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,mCASiB;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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C,CAAC,CAAC;YAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACrB,QAAQ,CAAC,aAAa,CAAC,IAAI,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 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 void node.cache.esbuildBuildContext?.dispose();\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]);\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 (!cachedSourceFile) {\n if (!nodesToClean) {\n return;\n }\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 for (const entryPoint of graph.filter(isEntryPoint)) {\n const isDirty = [...allNodesToClean].some(dependent => entryPoint.dependents.has(dependent));\n if (isDirty) {\n entryPoint.state = STATE_DIRTY;\n\n uriToClean.forEach(url => {\n entryPoint.cache.analysesSourcesFileCache.delete(fileUrlPath(url));\n });\n }\n }\n }),\n debounceTime(200),\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 const entryPoints: EntryPointNode[] = graph.filter(isEntryPoint);\n\n for (const entryPoint of entryPoints) {\n // Remove `ng://` prefix for better error messages\n const from = entryPoint.url.substring(5);\n depGraph.addNode(from);\n\n for (const { url } of entryPoint.filter(isEntryPoint)) {\n const to = 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"]}
|
|
@@ -26,18 +26,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const esbuild_1 = require("esbuild");
|
|
29
30
|
const node_path_1 = require("node:path");
|
|
30
31
|
const node_url_1 = require("node:url");
|
|
31
32
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
32
33
|
const postcss_1 = __importDefault(require("postcss"));
|
|
33
|
-
const esbuild_executor_1 = require("../esbuild/esbuild-executor");
|
|
34
34
|
const cache_1 = require("../utils/cache");
|
|
35
35
|
const log = __importStar(require("../utils/log"));
|
|
36
36
|
const css_resource_plugin_1 = require("./css-resource-plugin");
|
|
37
37
|
const { tailwindConfigPath, projectBasePath, browserslistData, targets, cssUrl, styleIncludePaths, postcssConfiguration, } = node_worker_threads_1.workerData;
|
|
38
38
|
let cacheDirectory = node_worker_threads_1.workerData.cacheDirectory;
|
|
39
39
|
let postCssProcessor;
|
|
40
|
-
let esbuild;
|
|
41
40
|
const CACHE_KEY_VALUES = [...browserslistData, ...styleIncludePaths, cssUrl].join(':');
|
|
42
41
|
/**
|
|
43
42
|
* An array of keywords that indicate Tailwind CSS processing is required for a stylesheet.
|
|
@@ -87,7 +86,7 @@ async function render({ content, filePath }) {
|
|
|
87
86
|
warnings.push(...result.warnings().map(w => w.toString()));
|
|
88
87
|
renderedCss = result.css;
|
|
89
88
|
}
|
|
90
|
-
const { outputFiles, warnings: esBuildWarnings, errors: esbuildErrors, } = await
|
|
89
|
+
const { outputFiles, warnings: esBuildWarnings, errors: esbuildErrors, } = await (0, esbuild_1.build)({
|
|
91
90
|
stdin: {
|
|
92
91
|
contents: renderedCss,
|
|
93
92
|
loader: 'css',
|
|
@@ -103,11 +102,11 @@ async function render({ content, filePath }) {
|
|
|
103
102
|
});
|
|
104
103
|
const code = outputFiles[0].text;
|
|
105
104
|
if (esBuildWarnings.length > 0) {
|
|
106
|
-
warnings.push(...(await
|
|
105
|
+
warnings.push(...(await (0, esbuild_1.formatMessages)(esBuildWarnings, { kind: 'warning' })));
|
|
107
106
|
warnings.forEach(msg => log.warn(msg));
|
|
108
107
|
}
|
|
109
108
|
if (esbuildErrors.length > 0) {
|
|
110
|
-
const errors = await
|
|
109
|
+
const errors = await (0, esbuild_1.formatMessages)(esBuildWarnings, { kind: 'error' });
|
|
111
110
|
errors.forEach(msg => log.error(msg));
|
|
112
111
|
throw new Error(`An error has occuried while processing ${filePath}.`);
|
|
113
112
|
}
|
|
@@ -185,7 +184,6 @@ async function initialize() {
|
|
|
185
184
|
if (postCssPlugins.length) {
|
|
186
185
|
postCssProcessor = (0, postcss_1.default)(postCssPlugins);
|
|
187
186
|
}
|
|
188
|
-
esbuild = new esbuild_executor_1.EsbuildExecutor();
|
|
189
187
|
// Return the render function for use
|
|
190
188
|
return render;
|
|
191
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheet-processor-worker.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor-worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAuD;AACvD,uCAAyC;AACzC,6DAAiD;AACjD,sDAA8B;AAC9B,kEAA8D;AAC9D,0CAA6E;AAC7E,kDAAoC;A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OAAO,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,kBAAe,UAAU,EAAE,CAAC","sourcesContent":["import { dirname, extname, relative } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { workerData } from 'node:worker_threads';\nimport postcss from 'postcss';\nimport { EsbuildExecutor } from '../esbuild/esbuild-executor';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport {createCssResourcePlugin} from './css-resource-plugin';\nimport { PostcssConfiguration } from './postcss-configuration';\nimport { CssUrl } from './stylesheet-processor';\n\nconst {\n tailwindConfigPath,\n projectBasePath,\n browserslistData,\n targets,\n cssUrl,\n styleIncludePaths,\n postcssConfiguration,\n} = workerData as {\n tailwindConfigPath: string | undefined;\n postcssConfiguration: PostcssConfiguration | undefined;\n browserslistData: string;\n targets: string[];\n projectBasePath: string;\n cssUrl: CssUrl;\n styleIncludePaths: string[];\n cacheDirectory: string | undefined;\n};\n\nlet cacheDirectory = workerData.cacheDirectory;\nlet postCssProcessor: ReturnType<typeof postcss> | undefined;\nlet esbuild: EsbuildExecutor;\n\ninterface RenderRequest {\n content: string;\n filePath: string;\n}\n\nconst CACHE_KEY_VALUES = [...browserslistData, ...styleIncludePaths, cssUrl].join(':');\n\n/**\n * An array of keywords that indicate Tailwind CSS processing is required for a stylesheet.\n *\n * Based on https://tailwindcss.com/docs/functions-and-directives\n */\nconst TAILWIND_KEYWORDS = [\n '@tailwind',\n '@layer',\n '@apply',\n '@config',\n 'theme(',\n 'screen(',\n '@screen', // Undocumented in version 3, see: https://github.com/tailwindlabs/tailwindcss/discussions/7516.\n];\n\nasync function render({ content, filePath }: RenderRequest): Promise<string> {\n let key: string | undefined;\n if (cacheDirectory && !content.includes('@import') && !content.includes('@use')) {\n // No transitive deps, we can cache more aggressively.\n key = await generateKey(content, CACHE_KEY_VALUES);\n const result = await readCacheEntry(cacheDirectory, key);\n if (result) {\n result.warnings.forEach(msg => log.warn(msg));\n\n return result.css;\n }\n }\n\n // Render pre-processor language (sass, styl, less)\n let renderedCss = await renderCss(filePath, content);\n\n // We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.\n // Example a change in a mixin or SCSS variable.\n if (!key) {\n key = await generateKey(renderedCss, CACHE_KEY_VALUES);\n }\n\n if (cacheDirectory) {\n const cachedResult = await readCacheEntry(cacheDirectory, key);\n if (cachedResult) {\n cachedResult.warnings.forEach(msg => log.warn(msg));\n\n return cachedResult.css;\n }\n }\n\n const warnings: string[] = [];\n if (postCssProcessor && (postcssConfiguration || (tailwindConfigPath && hasTailwindKeywords(renderedCss)))) {\n const result = await postCssProcessor.process(renderedCss, {\n from: filePath,\n to: filePath.replace(extname(filePath), '.css'),\n });\n\n warnings.push(...result.warnings().map(w => w.toString()));\n renderedCss = result.css;\n }\n\n const {\n outputFiles,\n warnings: esBuildWarnings,\n errors: esbuildErrors,\n } = await esbuild.build({\n stdin: {\n contents: renderedCss,\n loader: 'css',\n resolveDir: dirname(filePath),\n },\n plugins: [createCssResourcePlugin(cssUrl)],\n write: false,\n sourcemap: false,\n minify: true,\n bundle: true,\n absWorkingDir: projectBasePath,\n target: targets,\n });\n\n const code = outputFiles[0].text;\n if (esBuildWarnings.length > 0) {\n warnings.push(...(await esbuild.formatMessages(esBuildWarnings, { kind: 'warning' })));\n warnings.forEach(msg => log.warn(msg));\n }\n\n if (esbuildErrors.length > 0) {\n const errors = await esbuild.formatMessages(esBuildWarnings, { kind: 'error' });\n errors.forEach(msg => log.error(msg));\n\n throw new Error(`An error has occuried while processing ${filePath}.`);\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(\n cacheDirectory,\n key,\n JSON.stringify({\n css: code,\n warnings,\n }),\n );\n }\n\n return code;\n}\n\nasync function renderCss(filePath: string, css: string): Promise<string> {\n const ext = extname(filePath);\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n return (await import('sass')).compileString(css, {\n url: pathToFileURL(filePath),\n syntax: '.sass' === ext ? 'indented' : 'scss',\n loadPaths: styleIncludePaths,\n }).css;\n }\n case '.less': {\n const { css: content } = await (\n await import('less')\n ).default.render(css, {\n filename: filePath,\n javascriptEnabled: true,\n paths: styleIncludePaths,\n });\n\n return content;\n }\n\n case '.css':\n default:\n return css;\n }\n}\n\nfunction getTailwindPlugin() {\n // Attempt to setup Tailwind CSS\n // Only load Tailwind CSS plugin if configuration file was found.\n // This acts as a guard to ensure the project actually wants to use Tailwind CSS.\n // The package may be unknowningly present due to a third-party transitive package dependency.\n if (tailwindConfigPath) {\n let tailwindPackagePath;\n try {\n tailwindPackagePath = require.resolve('tailwindcss', { paths: [projectBasePath] });\n } catch {\n const relativeTailwindConfigPath = relative(projectBasePath, tailwindConfigPath);\n log.warn(\n `Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +\n ` but the 'tailwindcss' package is not installed.` +\n ` To enable Tailwind CSS, please install the 'tailwindcss' package.`,\n );\n }\n\n if (tailwindPackagePath) {\n return require(tailwindPackagePath)({ config: tailwindConfigPath });\n }\n }\n}\n\nasync function initialize() {\n const postCssPlugins = [];\n if (postcssConfiguration) {\n for (const [pluginName, pluginOptions] of postcssConfiguration.plugins) {\n const { default: plugin } = await import(pluginName);\n\n if (typeof plugin !== 'function' || plugin.postcss !== true) {\n throw new Error(`Attempted to load invalid Postcss plugin: \"${pluginName}\"`);\n }\n\n postCssPlugins.push(plugin(pluginOptions));\n }\n } else {\n const tailwinds = getTailwindPlugin();\n if (tailwinds) {\n postCssPlugins.push(tailwinds);\n cacheDirectory = undefined;\n }\n }\n\n if (postCssPlugins.length) {\n postCssProcessor = postcss(postCssPlugins);\n }\n\n esbuild = new EsbuildExecutor();\n\n // Return the render function for use\n return render;\n}\n\n/**\n * Searches the provided contents for keywords that indicate Tailwind is used\n * within a stylesheet.\n */\nfunction hasTailwindKeywords(contents: string): boolean {\n // TODO: use better search algorithm for keywords\n return TAILWIND_KEYWORDS.some(keyword => contents.includes(keyword));\n}\n\n/**\n * The default export will be the promise returned by the initialize function.\n * This is awaited by piscina prior to using the Worker.\n */\nexport default initialize();\n"]}
|
|
1
|
+
{"version":3,"file":"stylesheet-processor-worker.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor-worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAgD;AAChD,yCAAuD;AACvD,uCAAyC;AACzC,6DAAiD;AACjD,sDAA8B;AAC9B,0CAA6E;AAC7E,kDAAoC;AACpC,+DAAgE;AAIhE,MAAM,EACJ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,oBAAoB,GACrB,GAAG,gCASH,CAAC;AAEF,IAAI,cAAc,GAAG,gCAAU,CAAC,cAAc,CAAC;AAC/C,IAAI,gBAAwD,CAAC;AAO7D,MAAM,gBAAgB,GAAG,CAAC,GAAG,gBAAgB,EAAE,GAAG,iBAAiB,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEvF;;;;GAIG;AACH,MAAM,iBAAiB,GAAG;IACxB,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS,EAAE,gGAAgG;CAC5G,CAAC;AAEF,KAAK,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAiB;IACxD,IAAI,GAAuB,CAAC;IAC5B,IAAI,cAAc,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAChF,sDAAsD;QACtD,GAAG,GAAG,MAAM,IAAA,mBAAW,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,GAAG,CAAC,CAAC;QACzD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,CAAC,OA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AAC;IAED,qCAAqC;IACrC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,iDAAiD;IACjD,OAAO,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,kBAAe,UAAU,EAAE,CAAC","sourcesContent":["import { build, formatMessages } from 'esbuild';\nimport { dirname, extname, relative } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { workerData } from 'node:worker_threads';\nimport postcss from 'postcss';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { createCssResourcePlugin } from './css-resource-plugin';\nimport { PostcssConfiguration } from './postcss-configuration';\nimport { CssUrl } from './stylesheet-processor';\n\nconst {\n tailwindConfigPath,\n projectBasePath,\n browserslistData,\n targets,\n cssUrl,\n styleIncludePaths,\n postcssConfiguration,\n} = workerData as {\n tailwindConfigPath: string | undefined;\n postcssConfiguration: PostcssConfiguration | undefined;\n browserslistData: string;\n targets: string[];\n projectBasePath: string;\n cssUrl: CssUrl;\n styleIncludePaths: string[];\n cacheDirectory: string | undefined;\n};\n\nlet cacheDirectory = workerData.cacheDirectory;\nlet postCssProcessor: ReturnType<typeof postcss> | undefined;\n\ninterface RenderRequest {\n content: string;\n filePath: string;\n}\n\nconst CACHE_KEY_VALUES = [...browserslistData, ...styleIncludePaths, cssUrl].join(':');\n\n/**\n * An array of keywords that indicate Tailwind CSS processing is required for a stylesheet.\n *\n * Based on https://tailwindcss.com/docs/functions-and-directives\n */\nconst TAILWIND_KEYWORDS = [\n '@tailwind',\n '@layer',\n '@apply',\n '@config',\n 'theme(',\n 'screen(',\n '@screen', // Undocumented in version 3, see: https://github.com/tailwindlabs/tailwindcss/discussions/7516.\n];\n\nasync function render({ content, filePath }: RenderRequest): Promise<string> {\n let key: string | undefined;\n if (cacheDirectory && !content.includes('@import') && !content.includes('@use')) {\n // No transitive deps, we can cache more aggressively.\n key = await generateKey(content, CACHE_KEY_VALUES);\n const result = await readCacheEntry(cacheDirectory, key);\n if (result) {\n result.warnings.forEach(msg => log.warn(msg));\n\n return result.css;\n }\n }\n\n // Render pre-processor language (sass, styl, less)\n let renderedCss = await renderCss(filePath, content);\n\n // We cannot cache CSS re-rendering phase, because a transitive dependency via (@import) can case different CSS output.\n // Example a change in a mixin or SCSS variable.\n if (!key) {\n key = await generateKey(renderedCss, CACHE_KEY_VALUES);\n }\n\n if (cacheDirectory) {\n const cachedResult = await readCacheEntry(cacheDirectory, key);\n if (cachedResult) {\n cachedResult.warnings.forEach(msg => log.warn(msg));\n\n return cachedResult.css;\n }\n }\n\n const warnings: string[] = [];\n if (postCssProcessor && (postcssConfiguration || (tailwindConfigPath && hasTailwindKeywords(renderedCss)))) {\n const result = await postCssProcessor.process(renderedCss, {\n from: filePath,\n to: filePath.replace(extname(filePath), '.css'),\n });\n\n warnings.push(...result.warnings().map(w => w.toString()));\n renderedCss = result.css;\n }\n\n const {\n outputFiles,\n warnings: esBuildWarnings,\n errors: esbuildErrors,\n } = await build({\n stdin: {\n contents: renderedCss,\n loader: 'css',\n resolveDir: dirname(filePath),\n },\n plugins: [createCssResourcePlugin(cssUrl)],\n write: false,\n sourcemap: false,\n minify: true,\n bundle: true,\n absWorkingDir: projectBasePath,\n target: targets,\n });\n\n const code = outputFiles[0].text;\n if (esBuildWarnings.length > 0) {\n warnings.push(...(await formatMessages(esBuildWarnings, { kind: 'warning' })));\n warnings.forEach(msg => log.warn(msg));\n }\n\n if (esbuildErrors.length > 0) {\n const errors = await formatMessages(esBuildWarnings, { kind: 'error' });\n errors.forEach(msg => log.error(msg));\n\n throw new Error(`An error has occuried while processing ${filePath}.`);\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(\n cacheDirectory,\n key,\n JSON.stringify({\n css: code,\n warnings,\n }),\n );\n }\n\n return code;\n}\n\nasync function renderCss(filePath: string, css: string): Promise<string> {\n const ext = extname(filePath);\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n return (await import('sass')).compileString(css, {\n url: pathToFileURL(filePath),\n syntax: '.sass' === ext ? 'indented' : 'scss',\n loadPaths: styleIncludePaths,\n }).css;\n }\n case '.less': {\n const { css: content } = await (\n await import('less')\n ).default.render(css, {\n filename: filePath,\n javascriptEnabled: true,\n paths: styleIncludePaths,\n });\n\n return content;\n }\n\n case '.css':\n default:\n return css;\n }\n}\n\nfunction getTailwindPlugin() {\n // Attempt to setup Tailwind CSS\n // Only load Tailwind CSS plugin if configuration file was found.\n // This acts as a guard to ensure the project actually wants to use Tailwind CSS.\n // The package may be unknowningly present due to a third-party transitive package dependency.\n if (tailwindConfigPath) {\n let tailwindPackagePath;\n try {\n tailwindPackagePath = require.resolve('tailwindcss', { paths: [projectBasePath] });\n } catch {\n const relativeTailwindConfigPath = relative(projectBasePath, tailwindConfigPath);\n log.warn(\n `Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +\n ` but the 'tailwindcss' package is not installed.` +\n ` To enable Tailwind CSS, please install the 'tailwindcss' package.`,\n );\n }\n\n if (tailwindPackagePath) {\n return require(tailwindPackagePath)({ config: tailwindConfigPath });\n }\n }\n}\n\nasync function initialize() {\n const postCssPlugins = [];\n if (postcssConfiguration) {\n for (const [pluginName, pluginOptions] of postcssConfiguration.plugins) {\n const { default: plugin } = await import(pluginName);\n\n if (typeof plugin !== 'function' || plugin.postcss !== true) {\n throw new Error(`Attempted to load invalid Postcss plugin: \"${pluginName}\"`);\n }\n\n postCssPlugins.push(plugin(pluginOptions));\n }\n } else {\n const tailwinds = getTailwindPlugin();\n if (tailwinds) {\n postCssPlugins.push(tailwinds);\n cacheDirectory = undefined;\n }\n }\n\n if (postCssPlugins.length) {\n postCssProcessor = postcss(postCssPlugins);\n }\n\n // Return the render function for use\n return render;\n}\n\n/**\n * Searches the provided contents for keywords that indicate Tailwind is used\n * within a stylesheet.\n */\nfunction hasTailwindKeywords(contents: string): boolean {\n // TODO: use better search algorithm for keywords\n return TAILWIND_KEYWORDS.some(keyword => contents.includes(keyword));\n}\n\n/**\n * The default export will be the promise returned by the initialize function.\n * This is awaited by piscina prior to using the Worker.\n */\nexport default initialize();\n"]}
|
package/lib/utils/load-esm.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0-next.1",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scss"
|
|
15
15
|
],
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": "^18.
|
|
17
|
+
"node": "^18.19.1 || >=20.11.1"
|
|
18
18
|
},
|
|
19
19
|
"author": "David Herges <david@spektrakel.de>",
|
|
20
20
|
"license": "MIT",
|
|
@@ -26,15 +26,17 @@
|
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/ng-packagr/ng-packagr/issues"
|
|
28
28
|
},
|
|
29
|
+
"resolutions": {
|
|
30
|
+
"strip-ansi": "6.0.1",
|
|
31
|
+
"string-width": "4.2.2",
|
|
32
|
+
"wrap-ansi": "7.0.0"
|
|
33
|
+
},
|
|
29
34
|
"bin": {
|
|
30
35
|
"ng-packagr": "./cli/main.js"
|
|
31
36
|
},
|
|
32
37
|
"main": "./public_api.js",
|
|
33
38
|
"typings": "./public_api.d.ts",
|
|
34
39
|
"dependencies": {
|
|
35
|
-
"@rollup/plugin-json": "^6.0.1",
|
|
36
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
37
|
-
"@rollup/wasm-node": "^4.5.0",
|
|
38
40
|
"ajv": "^8.12.0",
|
|
39
41
|
"ansi-colors": "^4.1.3",
|
|
40
42
|
"browserslist": "^4.22.1",
|
|
@@ -43,7 +45,7 @@
|
|
|
43
45
|
"commander": "^12.0.0",
|
|
44
46
|
"convert-source-map": "^2.0.0",
|
|
45
47
|
"dependency-graph": "^1.0.0",
|
|
46
|
-
"esbuild
|
|
48
|
+
"esbuild": "^0.20.0",
|
|
47
49
|
"fast-glob": "^3.3.1",
|
|
48
50
|
"find-cache-dir": "^3.3.2",
|
|
49
51
|
"injection-js": "^2.4.0",
|
|
@@ -55,12 +57,8 @@
|
|
|
55
57
|
"rxjs": "^7.8.1",
|
|
56
58
|
"sass": "^1.69.5"
|
|
57
59
|
},
|
|
58
|
-
"optionalDependencies": {
|
|
59
|
-
"esbuild": "^0.20.0",
|
|
60
|
-
"rollup": "^4.5.0"
|
|
61
|
-
},
|
|
62
60
|
"peerDependencies": {
|
|
63
|
-
"@angular/compiler-cli": "^
|
|
61
|
+
"@angular/compiler-cli": "^18.0.0-next.0",
|
|
64
62
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
65
63
|
"tslib": "^2.3.0",
|
|
66
64
|
"typescript": ">=5.2 <5.5"
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import type { BuildOptions, BuildResult, FormatMessagesOptions, PartialMessage, TransformOptions, TransformResult } from 'esbuild';
|
|
9
|
-
/**
|
|
10
|
-
* Provides the ability to execute esbuild regardless of the current platform's support
|
|
11
|
-
* for using the native variant of esbuild. The native variant will be preferred (assuming
|
|
12
|
-
* the `alwaysUseWasm` constructor option is `false) due to its inherent performance advantages.
|
|
13
|
-
* At first use of esbuild, a supportability test will be automatically performed and the
|
|
14
|
-
* WASM-variant will be used if needed by the platform.
|
|
15
|
-
*/
|
|
16
|
-
export declare class EsbuildExecutor implements Pick<typeof import('esbuild'), 'transform' | 'formatMessages'> {
|
|
17
|
-
private alwaysUseWasm;
|
|
18
|
-
private esbuildTransform;
|
|
19
|
-
private esbuildBuild;
|
|
20
|
-
private esbuildFormatMessages;
|
|
21
|
-
private initialized;
|
|
22
|
-
/**
|
|
23
|
-
* Constructs an instance of the `EsbuildExecutor` class.
|
|
24
|
-
*
|
|
25
|
-
* @param alwaysUseWasm If true, the WASM-variant will be preferred and no support test will be
|
|
26
|
-
* performed; if false (default), the native variant will be preferred.
|
|
27
|
-
*/
|
|
28
|
-
constructor(alwaysUseWasm?: boolean);
|
|
29
|
-
/**
|
|
30
|
-
* Determines whether the native variant of esbuild can be used on the current platform.
|
|
31
|
-
*
|
|
32
|
-
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
|
33
|
-
*/
|
|
34
|
-
static hasNativeSupport(): Promise<boolean>;
|
|
35
|
-
/**
|
|
36
|
-
* Initializes the esbuild transform and format messages functions.
|
|
37
|
-
*
|
|
38
|
-
* @returns A promise that fulfills when esbuild has been loaded and available for use.
|
|
39
|
-
*/
|
|
40
|
-
private ensureEsbuild;
|
|
41
|
-
/**
|
|
42
|
-
* Transitions an executor instance to use the WASM-variant of esbuild.
|
|
43
|
-
*/
|
|
44
|
-
private useWasm;
|
|
45
|
-
transform(input: string, options?: TransformOptions): Promise<TransformResult>;
|
|
46
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
47
|
-
formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
|
|
48
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.EsbuildExecutor = void 0;
|
|
34
|
-
/**
|
|
35
|
-
* Provides the ability to execute esbuild regardless of the current platform's support
|
|
36
|
-
* for using the native variant of esbuild. The native variant will be preferred (assuming
|
|
37
|
-
* the `alwaysUseWasm` constructor option is `false) due to its inherent performance advantages.
|
|
38
|
-
* At first use of esbuild, a supportability test will be automatically performed and the
|
|
39
|
-
* WASM-variant will be used if needed by the platform.
|
|
40
|
-
*/
|
|
41
|
-
class EsbuildExecutor {
|
|
42
|
-
/**
|
|
43
|
-
* Constructs an instance of the `EsbuildExecutor` class.
|
|
44
|
-
*
|
|
45
|
-
* @param alwaysUseWasm If true, the WASM-variant will be preferred and no support test will be
|
|
46
|
-
* performed; if false (default), the native variant will be preferred.
|
|
47
|
-
*/
|
|
48
|
-
constructor(alwaysUseWasm = false) {
|
|
49
|
-
this.alwaysUseWasm = alwaysUseWasm;
|
|
50
|
-
this.initialized = false;
|
|
51
|
-
this.esbuildBuild =
|
|
52
|
-
this.esbuildTransform =
|
|
53
|
-
this.esbuildFormatMessages =
|
|
54
|
-
() => {
|
|
55
|
-
throw new Error('esbuild implementation missing');
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Determines whether the native variant of esbuild can be used on the current platform.
|
|
60
|
-
*
|
|
61
|
-
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
|
|
62
|
-
*/
|
|
63
|
-
static async hasNativeSupport() {
|
|
64
|
-
// Try to use native variant to ensure it is functional for the platform.
|
|
65
|
-
try {
|
|
66
|
-
const { formatMessages } = await Promise.resolve().then(() => __importStar(require('esbuild')));
|
|
67
|
-
await formatMessages([], { kind: 'error' });
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Initializes the esbuild transform and format messages functions.
|
|
76
|
-
*
|
|
77
|
-
* @returns A promise that fulfills when esbuild has been loaded and available for use.
|
|
78
|
-
*/
|
|
79
|
-
async ensureEsbuild() {
|
|
80
|
-
if (this.initialized) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// If the WASM variant was preferred at class construction or native is not supported, use WASM
|
|
84
|
-
if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {
|
|
85
|
-
await this.useWasm();
|
|
86
|
-
this.initialized = true;
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
// Use the faster native variant if available.
|
|
91
|
-
const { transform, build, formatMessages } = await Promise.resolve().then(() => __importStar(require('esbuild')));
|
|
92
|
-
this.esbuildTransform = transform;
|
|
93
|
-
this.esbuildFormatMessages = formatMessages;
|
|
94
|
-
this.esbuildBuild = build;
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// If the native variant is not installed then use the WASM-based variant
|
|
98
|
-
await this.useWasm();
|
|
99
|
-
}
|
|
100
|
-
this.initialized = true;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Transitions an executor instance to use the WASM-variant of esbuild.
|
|
104
|
-
*/
|
|
105
|
-
async useWasm() {
|
|
106
|
-
const { transform, build, formatMessages } = await Promise.resolve().then(() => __importStar(require('esbuild-wasm')));
|
|
107
|
-
this.esbuildTransform = transform;
|
|
108
|
-
this.esbuildFormatMessages = formatMessages;
|
|
109
|
-
this.esbuildBuild = build;
|
|
110
|
-
// The ESBUILD_BINARY_PATH environment variable cannot exist when attempting to use the
|
|
111
|
-
// WASM variant. If it is then the binary located at the specified path will be used instead
|
|
112
|
-
// of the WASM variant.
|
|
113
|
-
delete process.env.ESBUILD_BINARY_PATH;
|
|
114
|
-
this.alwaysUseWasm = true;
|
|
115
|
-
}
|
|
116
|
-
async transform(input, options) {
|
|
117
|
-
await this.ensureEsbuild();
|
|
118
|
-
return this.esbuildTransform(input, options);
|
|
119
|
-
}
|
|
120
|
-
async build(options) {
|
|
121
|
-
await this.ensureEsbuild();
|
|
122
|
-
return this.esbuildBuild(options);
|
|
123
|
-
}
|
|
124
|
-
async formatMessages(messages, options) {
|
|
125
|
-
await this.ensureEsbuild();
|
|
126
|
-
return this.esbuildFormatMessages(messages, options);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.EsbuildExecutor = EsbuildExecutor;
|
|
130
|
-
//# sourceMappingURL=esbuild-executor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-executor.js","sourceRoot":"","sources":["../../../src/lib/esbuild/esbuild-executor.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;AAWH;;;;;;G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;YACP,yEAAyE;YACzE,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO;QACnB,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,wDAAa,cAAc,GAAC,CAAC;QAC1E,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,qBAAqB,GAAG,cAAc,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,uFAAuF;QACvF,4FAA4F;QAC5F,uBAAuB;QACvB,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAEvC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,OAA0B;QACvD,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAA0B,EAAE,OAA8B;QAC7E,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF;AAxGD,0CAwGC","sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport type {\n BuildOptions,\n BuildResult,\n FormatMessagesOptions,\n PartialMessage,\n TransformOptions,\n TransformResult,\n} from 'esbuild';\n\n/**\n * Provides the ability to execute esbuild regardless of the current platform's support\n * for using the native variant of esbuild. The native variant will be preferred (assuming\n * the `alwaysUseWasm` constructor option is `false) due to its inherent performance advantages.\n * At first use of esbuild, a supportability test will be automatically performed and the\n * WASM-variant will be used if needed by the platform.\n */\nexport class EsbuildExecutor implements Pick<typeof import('esbuild'), 'transform' | 'formatMessages'> {\n private esbuildTransform: this['transform'];\n private esbuildBuild: this['build'];\n private esbuildFormatMessages: this['formatMessages'];\n private initialized = false;\n\n /**\n * Constructs an instance of the `EsbuildExecutor` class.\n *\n * @param alwaysUseWasm If true, the WASM-variant will be preferred and no support test will be\n * performed; if false (default), the native variant will be preferred.\n */\n constructor(private alwaysUseWasm = false) {\n this.esbuildBuild =\n this.esbuildTransform =\n this.esbuildFormatMessages =\n () => {\n throw new Error('esbuild implementation missing');\n };\n }\n\n /**\n * Determines whether the native variant of esbuild can be used on the current platform.\n *\n * @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.\n */\n static async hasNativeSupport(): Promise<boolean> {\n // Try to use native variant to ensure it is functional for the platform.\n try {\n const { formatMessages } = await import('esbuild');\n await formatMessages([], { kind: 'error' });\n\n return true;\n } catch {\n return false;\n }\n }\n /**\n * Initializes the esbuild transform and format messages functions.\n *\n * @returns A promise that fulfills when esbuild has been loaded and available for use.\n */\n private async ensureEsbuild(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // If the WASM variant was preferred at class construction or native is not supported, use WASM\n if (this.alwaysUseWasm || !(await EsbuildExecutor.hasNativeSupport())) {\n await this.useWasm();\n this.initialized = true;\n\n return;\n }\n\n try {\n // Use the faster native variant if available.\n const { transform, build, formatMessages } = await import('esbuild');\n\n this.esbuildTransform = transform;\n this.esbuildFormatMessages = formatMessages;\n this.esbuildBuild = build;\n } catch {\n // If the native variant is not installed then use the WASM-based variant\n await this.useWasm();\n }\n\n this.initialized = true;\n }\n\n /**\n * Transitions an executor instance to use the WASM-variant of esbuild.\n */\n private async useWasm(): Promise<void> {\n const { transform, build, formatMessages } = await import('esbuild-wasm');\n this.esbuildTransform = transform;\n this.esbuildFormatMessages = formatMessages;\n this.esbuildBuild = build;\n\n // The ESBUILD_BINARY_PATH environment variable cannot exist when attempting to use the\n // WASM variant. If it is then the binary located at the specified path will be used instead\n // of the WASM variant.\n delete process.env.ESBUILD_BINARY_PATH;\n\n this.alwaysUseWasm = true;\n }\n\n async transform(input: string, options?: TransformOptions): Promise<TransformResult> {\n await this.ensureEsbuild();\n\n return this.esbuildTransform(input, options);\n }\n\n async build(options: BuildOptions): Promise<BuildResult> {\n await this.ensureEsbuild();\n\n return this.esbuildBuild(options);\n }\n\n async formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]> {\n await this.ensureEsbuild();\n\n return this.esbuildFormatMessages(messages, options);\n }\n}\n"]}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.fileLoaderPlugin = void 0;
|
|
27
|
-
const log = __importStar(require("../utils/log"));
|
|
28
|
-
const path_1 = require("../utils/path");
|
|
29
|
-
/**
|
|
30
|
-
* Loads a file and it's map.
|
|
31
|
-
*/
|
|
32
|
-
function fileLoaderPlugin(fileCache) {
|
|
33
|
-
return {
|
|
34
|
-
name: 'file-loader',
|
|
35
|
-
load: function (id) {
|
|
36
|
-
log.debug(`file-loader ${id}`);
|
|
37
|
-
const data = fileCache.get((0, path_1.ensureUnixPath)(id));
|
|
38
|
-
if (!data) {
|
|
39
|
-
throw new Error(`Could not load '${id}' from memory.`);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
code: data.content,
|
|
43
|
-
map: data.map,
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.fileLoaderPlugin = fileLoaderPlugin;
|
|
49
|
-
//# sourceMappingURL=file-loader-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B;IACzD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,UAAU,EAAE;YAChB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YAE/B,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC,CAAC;YAC/C,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,IAAI,CAAC,GAAG;aACd,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAjBD,4CAiBC","sourcesContent":["import type { Plugin } from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache): Plugin {\n return {\n name: 'file-loader',\n load: function (id) {\n log.debug(`file-loader ${id}`);\n\n const data = fileCache.get(ensureUnixPath(id));\n if (!data) {\n throw new Error(`Could not load '${id}' from memory.`);\n }\n\n return {\n code: data.content,\n map: data.map,\n };\n },\n };\n}\n"]}
|
package/lib/flatten/rollup.d.ts
DELETED
|
@@ -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
|
-
sourceRoot: string;
|
|
14
|
-
cache?: RollupCache;
|
|
15
|
-
cacheDirectory?: string | false;
|
|
16
|
-
fileCache: OutputFileCache;
|
|
17
|
-
cacheKey: string;
|
|
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
|
-
}>;
|
package/lib/flatten/rollup.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.rollupBundleFile = void 0;
|
|
30
|
-
const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
|
|
31
|
-
const plugin_node_resolve_1 = __importDefault(require("@rollup/plugin-node-resolve"));
|
|
32
|
-
const path = __importStar(require("path"));
|
|
33
|
-
const cache_1 = require("../utils/cache");
|
|
34
|
-
const log = __importStar(require("../utils/log"));
|
|
35
|
-
const file_loader_plugin_1 = require("./file-loader-plugin");
|
|
36
|
-
let rollup;
|
|
37
|
-
/** Runs rollup over the given entry file, writes a bundle file. */
|
|
38
|
-
async function rollupBundleFile(opts) {
|
|
39
|
-
var _a;
|
|
40
|
-
await ensureRollup();
|
|
41
|
-
log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dir}`);
|
|
42
|
-
const cacheDirectory = opts.cacheDirectory;
|
|
43
|
-
// Create the bundle
|
|
44
|
-
const bundle = await rollup.rollup({
|
|
45
|
-
context: 'this',
|
|
46
|
-
external: moduleId => isExternalDependency(moduleId),
|
|
47
|
-
cache: (_a = opts.cache) !== null && _a !== void 0 ? _a : (cacheDirectory ? await (0, cache_1.readCacheEntry)(cacheDirectory, opts.cacheKey) : undefined),
|
|
48
|
-
input: opts.entry,
|
|
49
|
-
plugins: [(0, plugin_node_resolve_1.default)(), (0, plugin_json_1.default)(), (0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache)],
|
|
50
|
-
onwarn: warning => {
|
|
51
|
-
switch (warning.code) {
|
|
52
|
-
case 'CIRCULAR_DEPENDENCY':
|
|
53
|
-
case 'UNUSED_EXTERNAL_IMPORT':
|
|
54
|
-
case 'THIS_IS_UNDEFINED':
|
|
55
|
-
break;
|
|
56
|
-
default:
|
|
57
|
-
log.warn(warning.message);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
preserveSymlinks: true,
|
|
62
|
-
// Disable treeshaking when generating bundles
|
|
63
|
-
// see: https://github.com/angular/angular/pull/32069
|
|
64
|
-
treeshake: false,
|
|
65
|
-
});
|
|
66
|
-
// Output the bundle to disk
|
|
67
|
-
const output = await bundle.write({
|
|
68
|
-
name: opts.moduleName,
|
|
69
|
-
format: 'es',
|
|
70
|
-
dir: opts.dir,
|
|
71
|
-
inlineDynamicImports: false,
|
|
72
|
-
chunkFileNames: opts.entryName + '-[name]-[hash].mjs',
|
|
73
|
-
entryFileNames: opts.entryName + '.mjs',
|
|
74
|
-
banner: '',
|
|
75
|
-
sourcemap: true,
|
|
76
|
-
});
|
|
77
|
-
if (cacheDirectory) {
|
|
78
|
-
await (0, cache_1.saveCacheEntry)(cacheDirectory, opts.cacheKey, JSON.stringify(bundle.cache));
|
|
79
|
-
}
|
|
80
|
-
// Close the bundle to let plugins clean up their external processes or services
|
|
81
|
-
await bundle.close();
|
|
82
|
-
return {
|
|
83
|
-
files: output.output,
|
|
84
|
-
cache: bundle.cache,
|
|
85
|
-
};
|
|
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
|
-
}
|
|
101
|
-
function isExternalDependency(moduleId) {
|
|
102
|
-
// more information about why we don't check for 'node_modules' path
|
|
103
|
-
// https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632
|
|
104
|
-
if (moduleId.startsWith('.') || moduleId.startsWith('/') || path.isAbsolute(moduleId)) {
|
|
105
|
-
// if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=rollup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;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AC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtF,yGAAyG;QACzG,OAAO,KAAK,CAAC;IACf,CAAC;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"]}
|