@angular/build 19.0.0-next.0 → 19.0.0-next.10
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/LICENSE +5 -5
- package/package.json +20 -16
- package/src/builders/application/build-action.js +9 -9
- package/src/builders/application/chunk-optimizer.js +1 -4
- package/src/builders/application/execute-build.js +19 -2
- package/src/builders/application/execute-post-bundle.d.ts +2 -2
- package/src/builders/application/execute-post-bundle.js +58 -20
- package/src/builders/application/i18n.d.ts +2 -2
- package/src/builders/application/i18n.js +6 -16
- package/src/builders/application/index.js +8 -5
- package/src/builders/application/options.d.ts +36 -1
- package/src/builders/application/options.js +60 -3
- package/src/builders/application/schema.d.ts +15 -0
- package/src/builders/application/schema.js +11 -1
- package/src/builders/application/schema.json +5 -0
- package/src/builders/application/setup-bundling.js +12 -9
- package/src/builders/dev-server/internal.d.ts +0 -1
- package/src/builders/dev-server/internal.js +1 -3
- package/src/builders/dev-server/vite-server.d.ts +8 -2
- package/src/builders/dev-server/vite-server.js +111 -56
- package/src/builders/extract-i18n/application-extraction.js +7 -3
- package/src/tools/angular/angular-host.d.ts +2 -1
- package/src/tools/angular/angular-host.js +20 -1
- package/src/tools/angular/compilation/angular-compilation.d.ts +1 -0
- package/src/tools/angular/compilation/aot-compilation.d.ts +1 -0
- package/src/tools/angular/compilation/aot-compilation.js +9 -1
- package/src/tools/angular/compilation/jit-compilation.js +2 -1
- package/src/tools/angular/compilation/parallel-compilation.d.ts +2 -1
- package/src/tools/angular/compilation/parallel-compilation.js +2 -10
- package/src/tools/angular/compilation/parallel-worker.d.ts +1 -0
- package/src/tools/angular/compilation/parallel-worker.js +2 -1
- package/src/tools/babel/plugins/add-code-coverage.d.ts +14 -0
- package/src/tools/babel/plugins/add-code-coverage.js +44 -0
- package/src/tools/babel/plugins/types.d.ts +20 -0
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +2 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +46 -4
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +8 -3
- package/src/tools/esbuild/angular/component-stylesheets.js +46 -11
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +1 -1
- package/src/tools/esbuild/application-code-bundle.d.ts +2 -6
- package/src/tools/esbuild/application-code-bundle.js +208 -92
- package/src/tools/esbuild/budget-stats.js +1 -1
- package/src/tools/esbuild/bundler-context.d.ts +4 -3
- package/src/tools/esbuild/bundler-context.js +21 -13
- package/src/tools/esbuild/bundler-execution-result.d.ts +5 -2
- package/src/tools/esbuild/bundler-execution-result.js +7 -3
- package/src/tools/esbuild/cache.d.ts +6 -1
- package/src/tools/esbuild/cache.js +7 -0
- package/src/tools/esbuild/compiler-plugin-options.js +3 -1
- package/src/tools/esbuild/i18n-inliner.js +4 -4
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +1 -0
- package/src/tools/esbuild/javascript-transformer-worker.js +5 -1
- package/src/tools/esbuild/javascript-transformer.d.ts +2 -2
- package/src/tools/esbuild/javascript-transformer.js +7 -12
- package/src/tools/esbuild/utils.d.ts +9 -0
- package/src/tools/esbuild/utils.js +21 -3
- package/src/tools/sass/sass-service.js +11 -13
- package/src/tools/sass/worker.d.ts +13 -32
- package/src/tools/sass/worker.js +1 -0
- package/src/tools/vite/middlewares/assets-middleware.d.ts +1 -1
- package/src/tools/vite/middlewares/assets-middleware.js +43 -4
- package/src/tools/vite/middlewares/headers-middleware.d.ts +19 -0
- package/src/tools/vite/middlewares/headers-middleware.js +34 -0
- package/src/tools/vite/middlewares/html-fallback-middleware.d.ts +1 -1
- package/src/tools/vite/middlewares/html-fallback-middleware.js +23 -7
- package/src/tools/vite/middlewares/index-html-middleware.js +1 -2
- package/src/tools/vite/middlewares/index.d.ts +2 -1
- package/src/tools/vite/middlewares/index.js +5 -2
- package/src/tools/vite/middlewares/ssr-middleware.d.ts +2 -4
- package/src/tools/vite/middlewares/ssr-middleware.js +75 -43
- package/src/tools/vite/plugins/angular-memory-plugin.d.ts +16 -0
- package/src/tools/vite/{angular-memory-plugin.js → plugins/angular-memory-plugin.js} +19 -40
- package/src/tools/vite/{i18n-locale-plugin.d.ts → plugins/i18n-locale-plugin.d.ts} +0 -4
- package/src/tools/vite/{i18n-locale-plugin.js → plugins/i18n-locale-plugin.js} +2 -3
- package/src/tools/vite/plugins/index.d.ts +12 -0
- package/src/tools/vite/plugins/index.js +21 -0
- package/src/tools/vite/plugins/setup-middlewares-plugin.d.ts +41 -0
- package/src/tools/vite/plugins/setup-middlewares-plugin.js +62 -0
- package/src/{utils/server-rendering/main-bundle-exports.js → tools/vite/plugins/ssr-transform-plugin.d.ts} +2 -2
- package/src/tools/vite/plugins/ssr-transform-plugin.js +38 -0
- package/src/tools/vite/utils.d.ts +0 -3
- package/src/tools/vite/utils.js +0 -12
- package/src/typings.d.ts +26 -0
- package/src/utils/environment-options.d.ts +2 -0
- package/src/utils/environment-options.js +5 -1
- package/src/utils/index-file/index-html-generator.js +5 -0
- package/src/utils/index-file/inline-critical-css.js +43 -33
- package/src/utils/index-file/ngcm-attribute.d.ts +15 -0
- package/src/utils/index-file/ngcm-attribute.js +37 -0
- package/src/utils/index-file/valid-self-closing-tags.js +28 -0
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/server-rendering/fetch-patch.d.ts +1 -1
- package/src/utils/server-rendering/fetch-patch.js +5 -6
- package/src/utils/server-rendering/launch-server.d.ts +14 -0
- package/src/utils/server-rendering/launch-server.js +63 -0
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +18 -2
- package/src/utils/server-rendering/manifest.d.ts +50 -0
- package/src/utils/server-rendering/manifest.js +126 -0
- package/src/utils/server-rendering/models.d.ts +27 -0
- package/src/utils/server-rendering/models.js +22 -0
- package/src/utils/server-rendering/prerender.d.ts +26 -10
- package/src/utils/server-rendering/prerender.js +126 -67
- package/src/utils/server-rendering/render-worker.d.ts +9 -8
- package/src/utils/server-rendering/render-worker.js +19 -14
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +6 -10
- package/src/utils/server-rendering/routes-extractor-worker.js +16 -33
- package/src/utils/server-rendering/utils.d.ts +11 -0
- package/src/utils/server-rendering/utils.js +17 -0
- package/src/utils/worker-pool.d.ts +12 -0
- package/src/utils/worker-pool.js +43 -0
- package/src/tools/vite/angular-memory-plugin.d.ts +0 -21
- package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
- package/src/utils/server-rendering/render-page.d.ts +0 -26
- package/src/utils/server-rendering/render-page.js +0 -114
- /package/src/tools/vite/{id-prefix-plugin.d.ts → plugins/id-prefix-plugin.d.ts} +0 -0
- /package/src/tools/vite/{id-prefix-plugin.js → plugins/id-prefix-plugin.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare module 'istanbul-lib-instrument' {
|
|
10
|
+
export interface Visitor {
|
|
11
|
+
enter(path: import('@babel/core').NodePath<types.Program>): void;
|
|
12
|
+
exit(path: import('@babel/core').NodePath<types.Program>): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function programVisitor(
|
|
16
|
+
types: typeof import('@babel/core').types,
|
|
17
|
+
filePath?: string,
|
|
18
|
+
options?: { inputSourceMap?: object | null },
|
|
19
|
+
): Visitor;
|
|
20
|
+
}
|
|
@@ -21,6 +21,8 @@ export interface CompilerPluginOptions {
|
|
|
21
21
|
sourceFileCache?: SourceFileCache;
|
|
22
22
|
loadResultCache?: LoadResultCache;
|
|
23
23
|
incremental: boolean;
|
|
24
|
+
externalRuntimeStyles?: boolean;
|
|
25
|
+
instrumentForCoverage?: (request: string) => boolean;
|
|
24
26
|
}
|
|
25
27
|
export declare function createCompilerPlugin(pluginOptions: CompilerPluginOptions, styleOptions: BundleStylesheetOptions & {
|
|
26
28
|
inlineStyleLanguage: string;
|
|
@@ -35,6 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createCompilerPlugin = createCompilerPlugin;
|
|
37
37
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
38
|
+
const node_crypto_1 = require("node:crypto");
|
|
38
39
|
const path = __importStar(require("node:path"));
|
|
39
40
|
const environment_options_1 = require("../../../utils/environment-options");
|
|
40
41
|
const compilation_1 = require("../../angular/compilation");
|
|
@@ -120,13 +121,14 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
120
121
|
// Angular compiler which does not have direct knowledge of transitive resource
|
|
121
122
|
// dependencies or web worker processing.
|
|
122
123
|
let modifiedFiles;
|
|
124
|
+
let invalidatedStylesheetEntries;
|
|
123
125
|
if (pluginOptions.sourceFileCache?.modifiedFiles.size &&
|
|
124
126
|
referencedFileTracker &&
|
|
125
127
|
!pluginOptions.noopTypeScriptCompilation) {
|
|
126
128
|
// TODO: Differentiate between changed input files and stale output files
|
|
127
129
|
modifiedFiles = referencedFileTracker.update(pluginOptions.sourceFileCache.modifiedFiles);
|
|
128
130
|
pluginOptions.sourceFileCache.invalidate(modifiedFiles);
|
|
129
|
-
stylesheetBundler.invalidate(modifiedFiles);
|
|
131
|
+
invalidatedStylesheetEntries = stylesheetBundler.invalidate(modifiedFiles);
|
|
130
132
|
}
|
|
131
133
|
if (!pluginOptions.noopTypeScriptCompilation &&
|
|
132
134
|
compilation.update &&
|
|
@@ -138,14 +140,26 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
138
140
|
fileReplacements: pluginOptions.fileReplacements,
|
|
139
141
|
modifiedFiles,
|
|
140
142
|
sourceFileCache: pluginOptions.sourceFileCache,
|
|
141
|
-
async transformStylesheet(data, containingFile, stylesheetFile) {
|
|
143
|
+
async transformStylesheet(data, containingFile, stylesheetFile, order) {
|
|
142
144
|
let stylesheetResult;
|
|
143
145
|
// Stylesheet file only exists for external stylesheets
|
|
144
146
|
if (stylesheetFile) {
|
|
145
147
|
stylesheetResult = await stylesheetBundler.bundleFile(stylesheetFile);
|
|
146
148
|
}
|
|
147
149
|
else {
|
|
148
|
-
stylesheetResult = await stylesheetBundler.bundleInline(data, containingFile,
|
|
150
|
+
stylesheetResult = await stylesheetBundler.bundleInline(data, containingFile,
|
|
151
|
+
// Inline stylesheets from a template style element are always CSS
|
|
152
|
+
containingFile.endsWith('.html') ? 'css' : styleOptions.inlineStyleLanguage,
|
|
153
|
+
// When external runtime styles are enabled, an identifier for the style that does not change
|
|
154
|
+
// based on the content is required to avoid emitted JS code changes. Any JS code changes will
|
|
155
|
+
// invalid the output and force a full page reload for HMR cases. The containing file and order
|
|
156
|
+
// of the style within the containing file is used.
|
|
157
|
+
pluginOptions.externalRuntimeStyles
|
|
158
|
+
? (0, node_crypto_1.createHash)('sha-256')
|
|
159
|
+
.update(containingFile)
|
|
160
|
+
.update((order ?? 0).toString())
|
|
161
|
+
.digest('hex')
|
|
162
|
+
: undefined);
|
|
149
163
|
}
|
|
150
164
|
const { contents, outputFiles, metafile, referencedFiles, errors, warnings } = stylesheetResult;
|
|
151
165
|
if (errors) {
|
|
@@ -199,6 +213,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
199
213
|
// Initialize the Angular compilation for the current build.
|
|
200
214
|
// In watch mode, previous build state will be reused.
|
|
201
215
|
let referencedFiles;
|
|
216
|
+
let externalStylesheets;
|
|
202
217
|
try {
|
|
203
218
|
const initializationResult = await compilation.initialize(pluginOptions.tsconfig, hostOptions, createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserveSymlinks));
|
|
204
219
|
shouldTsIgnoreJs = !initializationResult.compilerOptions.allowJs;
|
|
@@ -209,6 +224,7 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
209
224
|
!!initializationResult.compilerOptions.sourceMap ||
|
|
210
225
|
!!initializationResult.compilerOptions.inlineSourceMap;
|
|
211
226
|
referencedFiles = initializationResult.referencedFiles;
|
|
227
|
+
externalStylesheets = initializationResult.externalStylesheets;
|
|
212
228
|
}
|
|
213
229
|
catch (error) {
|
|
214
230
|
(result.errors ??= []).push({
|
|
@@ -229,6 +245,19 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
229
245
|
hasCompilationErrors = await sharedTSCompilationState.waitUntilReady;
|
|
230
246
|
return result;
|
|
231
247
|
}
|
|
248
|
+
if (externalStylesheets) {
|
|
249
|
+
// Process any new external stylesheets
|
|
250
|
+
for (const [stylesheetFile, externalId] of externalStylesheets) {
|
|
251
|
+
await bundleExternalStylesheet(stylesheetBundler, stylesheetFile, externalId, result, additionalResults);
|
|
252
|
+
}
|
|
253
|
+
// Process any updated stylesheets
|
|
254
|
+
if (invalidatedStylesheetEntries) {
|
|
255
|
+
for (const stylesheetFile of invalidatedStylesheetEntries) {
|
|
256
|
+
// externalId is already linked in the bundler context so only enabling is required here
|
|
257
|
+
await bundleExternalStylesheet(stylesheetBundler, stylesheetFile, true, result, additionalResults);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
232
261
|
// Update TypeScript file output cache for all affected files
|
|
233
262
|
try {
|
|
234
263
|
await (0, profiling_1.profileAsync)('NG_EMIT_TS', async () => {
|
|
@@ -310,7 +339,8 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
310
339
|
// A string indicates untransformed output from the TS/NG compiler.
|
|
311
340
|
// This step is unneeded when using esbuild transpilation.
|
|
312
341
|
const sideEffects = await hasSideEffects(request);
|
|
313
|
-
|
|
342
|
+
const instrumentForCoverage = pluginOptions.instrumentForCoverage?.(request);
|
|
343
|
+
contents = await javascriptTransformer.transformData(request, contents, true /* skipLinker */, sideEffects, instrumentForCoverage);
|
|
314
344
|
// Store as the returned Uint8Array to allow caching the fully transformed code
|
|
315
345
|
typeScriptFileCache.set(request, contents);
|
|
316
346
|
}
|
|
@@ -374,6 +404,17 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
|
|
|
374
404
|
},
|
|
375
405
|
};
|
|
376
406
|
}
|
|
407
|
+
async function bundleExternalStylesheet(stylesheetBundler, stylesheetFile, externalId, result, additionalResults) {
|
|
408
|
+
const { outputFiles, metafile, errors, warnings } = await stylesheetBundler.bundleFile(stylesheetFile, externalId);
|
|
409
|
+
if (errors) {
|
|
410
|
+
(result.errors ??= []).push(...errors);
|
|
411
|
+
}
|
|
412
|
+
(result.warnings ??= []).push(...warnings);
|
|
413
|
+
additionalResults.set(stylesheetFile, {
|
|
414
|
+
outputFiles,
|
|
415
|
+
metafile,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
377
418
|
function createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserveSymlinks) {
|
|
378
419
|
return (compilerOptions) => {
|
|
379
420
|
// target of 9 is ES2022 (using the number avoids an expensive import of typescript just for an enum)
|
|
@@ -431,6 +472,7 @@ function createCompilerOptionsTransformer(setupWarnings, pluginOptions, preserve
|
|
|
431
472
|
mapRoot: undefined,
|
|
432
473
|
sourceRoot: undefined,
|
|
433
474
|
preserveSymlinks,
|
|
475
|
+
externalRuntimeStyles: pluginOptions.externalRuntimeStyles,
|
|
434
476
|
};
|
|
435
477
|
};
|
|
436
478
|
}
|
|
@@ -22,7 +22,7 @@ export declare class ComponentStylesheetBundler {
|
|
|
22
22
|
* @param cache A load result cache to use when bundling.
|
|
23
23
|
*/
|
|
24
24
|
constructor(options: BundleStylesheetOptions, incremental: boolean);
|
|
25
|
-
bundleFile(entry: string): Promise<{
|
|
25
|
+
bundleFile(entry: string, externalId?: string | boolean): Promise<{
|
|
26
26
|
errors: import("esbuild").Message[] | undefined;
|
|
27
27
|
warnings: import("esbuild").Message[];
|
|
28
28
|
contents: string;
|
|
@@ -30,7 +30,7 @@ export declare class ComponentStylesheetBundler {
|
|
|
30
30
|
metafile: import("esbuild").Metafile | undefined;
|
|
31
31
|
referencedFiles: Set<string> | undefined;
|
|
32
32
|
}>;
|
|
33
|
-
bundleInline(data: string, filename: string, language: string): Promise<{
|
|
33
|
+
bundleInline(data: string, filename: string, language: string, externalId?: string): Promise<{
|
|
34
34
|
errors: import("esbuild").Message[] | undefined;
|
|
35
35
|
warnings: import("esbuild").Message[];
|
|
36
36
|
contents: string;
|
|
@@ -38,7 +38,12 @@ export declare class ComponentStylesheetBundler {
|
|
|
38
38
|
metafile: import("esbuild").Metafile | undefined;
|
|
39
39
|
referencedFiles: Set<string> | undefined;
|
|
40
40
|
}>;
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Invalidates both file and inline based component style bundling state for a set of modified files.
|
|
43
|
+
* @param files The group of files that have been modified
|
|
44
|
+
* @returns An array of file based stylesheet entries if any were invalidated; otherwise, undefined.
|
|
45
|
+
*/
|
|
46
|
+
invalidate(files: Iterable<string>): string[] | undefined;
|
|
42
47
|
dispose(): Promise<void>;
|
|
43
48
|
private extractResult;
|
|
44
49
|
}
|
|
@@ -11,6 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.ComponentStylesheetBundler = void 0;
|
|
14
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
14
15
|
const node_crypto_1 = require("node:crypto");
|
|
15
16
|
const node_path_1 = __importDefault(require("node:path"));
|
|
16
17
|
const bundler_context_1 = require("../bundler-context");
|
|
@@ -35,21 +36,31 @@ class ComponentStylesheetBundler {
|
|
|
35
36
|
this.options = options;
|
|
36
37
|
this.incremental = incremental;
|
|
37
38
|
}
|
|
38
|
-
async bundleFile(entry) {
|
|
39
|
+
async bundleFile(entry, externalId) {
|
|
39
40
|
const bundlerContext = await this.#fileContexts.getOrCreate(entry, () => {
|
|
40
41
|
return new bundler_context_1.BundlerContext(this.options.workspaceRoot, this.incremental, (loadCache) => {
|
|
41
42
|
const buildOptions = (0, bundle_options_1.createStylesheetBundleOptions)(this.options, loadCache);
|
|
42
|
-
|
|
43
|
+
if (externalId) {
|
|
44
|
+
(0, node_assert_1.default)(typeof externalId === 'string', 'Initial external component stylesheets must have a string identifier');
|
|
45
|
+
buildOptions.entryPoints = { [externalId]: entry };
|
|
46
|
+
delete buildOptions.publicPath;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
buildOptions.entryPoints = [entry];
|
|
50
|
+
}
|
|
43
51
|
return buildOptions;
|
|
44
52
|
});
|
|
45
53
|
});
|
|
46
|
-
return this.extractResult(await bundlerContext.bundle(), bundlerContext.watchFiles);
|
|
54
|
+
return this.extractResult(await bundlerContext.bundle(), bundlerContext.watchFiles, !!externalId);
|
|
47
55
|
}
|
|
48
|
-
async bundleInline(data, filename, language) {
|
|
56
|
+
async bundleInline(data, filename, language, externalId) {
|
|
49
57
|
// Use a hash of the inline stylesheet content to ensure a consistent identifier. External stylesheets will resolve
|
|
50
58
|
// to the actual stylesheet file path.
|
|
51
59
|
// TODO: Consider xxhash instead for hashing
|
|
52
|
-
const id = (0, node_crypto_1.createHash)('sha256')
|
|
60
|
+
const id = (0, node_crypto_1.createHash)('sha256')
|
|
61
|
+
.update(data)
|
|
62
|
+
.update(externalId ?? '')
|
|
63
|
+
.digest('hex');
|
|
53
64
|
const entry = [language, id, filename].join(';');
|
|
54
65
|
const bundlerContext = await this.#inlineContexts.getOrCreate(entry, () => {
|
|
55
66
|
const namespace = 'angular:styles/component';
|
|
@@ -57,7 +68,13 @@ class ComponentStylesheetBundler {
|
|
|
57
68
|
const buildOptions = (0, bundle_options_1.createStylesheetBundleOptions)(this.options, loadCache, {
|
|
58
69
|
[entry]: data,
|
|
59
70
|
});
|
|
60
|
-
|
|
71
|
+
if (externalId) {
|
|
72
|
+
buildOptions.entryPoints = { [externalId]: `${namespace};${entry}` };
|
|
73
|
+
delete buildOptions.publicPath;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
buildOptions.entryPoints = [`${namespace};${entry}`];
|
|
77
|
+
}
|
|
61
78
|
buildOptions.plugins.push({
|
|
62
79
|
name: 'angular-component-styles',
|
|
63
80
|
setup(build) {
|
|
@@ -83,19 +100,29 @@ class ComponentStylesheetBundler {
|
|
|
83
100
|
});
|
|
84
101
|
});
|
|
85
102
|
// Extract the result of the bundling from the output files
|
|
86
|
-
return this.extractResult(await bundlerContext.bundle(), bundlerContext.watchFiles);
|
|
103
|
+
return this.extractResult(await bundlerContext.bundle(), bundlerContext.watchFiles, !!externalId);
|
|
87
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Invalidates both file and inline based component style bundling state for a set of modified files.
|
|
107
|
+
* @param files The group of files that have been modified
|
|
108
|
+
* @returns An array of file based stylesheet entries if any were invalidated; otherwise, undefined.
|
|
109
|
+
*/
|
|
88
110
|
invalidate(files) {
|
|
89
111
|
if (!this.incremental) {
|
|
90
112
|
return;
|
|
91
113
|
}
|
|
92
114
|
const normalizedFiles = [...files].map(node_path_1.default.normalize);
|
|
93
|
-
|
|
94
|
-
|
|
115
|
+
let entries;
|
|
116
|
+
for (const [entry, bundler] of this.#fileContexts.entries()) {
|
|
117
|
+
if (bundler.invalidate(normalizedFiles)) {
|
|
118
|
+
entries ??= [];
|
|
119
|
+
entries.push(entry);
|
|
120
|
+
}
|
|
95
121
|
}
|
|
96
122
|
for (const bundler of this.#inlineContexts.values()) {
|
|
97
123
|
bundler.invalidate(normalizedFiles);
|
|
98
124
|
}
|
|
125
|
+
return entries;
|
|
99
126
|
}
|
|
100
127
|
async dispose() {
|
|
101
128
|
const contexts = [...this.#fileContexts.values(), ...this.#inlineContexts.values()];
|
|
@@ -103,7 +130,7 @@ class ComponentStylesheetBundler {
|
|
|
103
130
|
this.#inlineContexts.clear();
|
|
104
131
|
await Promise.allSettled(contexts.map((context) => context.dispose()));
|
|
105
132
|
}
|
|
106
|
-
extractResult(result, referencedFiles) {
|
|
133
|
+
extractResult(result, referencedFiles, external) {
|
|
107
134
|
let contents = '';
|
|
108
135
|
let metafile;
|
|
109
136
|
const outputFiles = [];
|
|
@@ -122,7 +149,15 @@ class ComponentStylesheetBundler {
|
|
|
122
149
|
outputFiles.push(clonedOutputFile);
|
|
123
150
|
}
|
|
124
151
|
else if (filename.endsWith('.css')) {
|
|
125
|
-
|
|
152
|
+
if (external) {
|
|
153
|
+
const clonedOutputFile = outputFile.clone();
|
|
154
|
+
clonedOutputFile.path = node_path_1.default.join(this.options.workspaceRoot, outputFile.path);
|
|
155
|
+
outputFiles.push(clonedOutputFile);
|
|
156
|
+
contents = node_path_1.default.posix.join(this.options.publicPath ?? '', filename);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
contents = outputFile.text;
|
|
160
|
+
}
|
|
126
161
|
}
|
|
127
162
|
else {
|
|
128
163
|
throw new Error(`Unexpected non CSS/Media file "${filename}" outputted during component stylesheet processing.`);
|
|
@@ -11,10 +11,6 @@ import { SourceFileCache } from './angular/source-file-cache';
|
|
|
11
11
|
import { BundlerOptionsFactory } from './bundler-context';
|
|
12
12
|
export declare function createBrowserCodeBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], sourceFileCache?: SourceFileCache): BuildOptions;
|
|
13
13
|
export declare function createBrowserPolyfillBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], sourceFileCache?: SourceFileCache): BuildOptions | BundlerOptionsFactory | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Create an esbuild 'build' options object for the server bundle.
|
|
16
|
-
* @param options The builder's user-provider normalized options.
|
|
17
|
-
* @returns An esbuild BuildOptions object.
|
|
18
|
-
*/
|
|
19
|
-
export declare function createServerCodeBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], sourceFileCache: SourceFileCache): BuildOptions;
|
|
20
14
|
export declare function createServerPolyfillBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], sourceFileCache?: SourceFileCache): BundlerOptionsFactory | undefined;
|
|
15
|
+
export declare function createServerMainCodeBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], sourceFileCache: SourceFileCache): BuildOptions;
|
|
16
|
+
export declare function createSsrEntryCodeBundleOptions(options: NormalizedApplicationBuildOptions, target: string[], sourceFileCache: SourceFileCache): BuildOptions;
|