Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/angular/build/src/builders/application/setup-bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function setupBundlerContexts(
angularCompilationContext,
templateUpdates,
),
true,
),
);

Expand All @@ -82,6 +83,7 @@ export function setupBundlerContexts(
workspaceRoot,
watch,
browserPolyfillBundleOptions,
true,
);
if (typeof browserPolyfillBundleOptions === 'function') {
otherContexts.push(browserPolyfillContext);
Expand All @@ -95,7 +97,9 @@ export function setupBundlerContexts(
for (const initial of [true, false]) {
const bundleOptions = createGlobalStylesBundleOptions(options, target, initial);
if (bundleOptions) {
otherContexts.push(new BundlerContext(workspaceRoot, watch, bundleOptions, () => initial));
otherContexts.push(
new BundlerContext(workspaceRoot, watch, bundleOptions, true, () => initial),
);
}
}
}
Expand All @@ -105,7 +109,9 @@ export function setupBundlerContexts(
for (const initial of [true, false]) {
const bundleOptions = createGlobalScriptsBundleOptions(options, target, initial);
if (bundleOptions) {
otherContexts.push(new BundlerContext(workspaceRoot, watch, bundleOptions, () => initial));
otherContexts.push(
new BundlerContext(workspaceRoot, watch, bundleOptions, true, () => initial),
);
}
}
}
Expand All @@ -125,6 +131,7 @@ export function setupBundlerContexts(
stylesheetBundler,
angularCompilationContext.createSecondaryContext(),
),
true,
),
);

Expand All @@ -141,6 +148,7 @@ export function setupBundlerContexts(
stylesheetBundler,
angularCompilationContext.createSecondaryContext(),
),
true,
),
);
}
Expand All @@ -153,7 +161,9 @@ export function setupBundlerContexts(
);

if (serverPolyfillBundleOptions) {
otherContexts.push(new BundlerContext(workspaceRoot, watch, serverPolyfillBundleOptions));
otherContexts.push(
new BundlerContext(workspaceRoot, watch, serverPolyfillBundleOptions, true),
);
}
}

Expand Down
12 changes: 11 additions & 1 deletion packages/angular/build/src/tools/esbuild/bundler-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class BundlerContext {
private workspaceRoot: string,
private incremental: boolean,
options: BuildOptions | BundlerOptionsFactory,
private alwaysUseContext = false,
private initialFilter?: (initial: Readonly<InitialFileRecord>) => boolean,
) {
// To cache the results an option factory is needed to capture the full set of dependencies
Expand Down Expand Up @@ -217,7 +218,7 @@ export class BundlerContext {
if (this.#esbuildContext) {
// Rebuild using the existing incremental build context
result = await this.#esbuildContext.rebuild();
} else {
} else if (this.incremental || this.alwaysUseContext) {
// Create a build context and perform the build.
// Context creation does not perform a build.
const esbuildContext = await context(this.#esbuildOptions);
Expand All @@ -227,6 +228,15 @@ export class BundlerContext {
}
this.#esbuildContext = esbuildContext;
result = await this.#esbuildContext.rebuild();
} else {
// For non-incremental builds, perform a single build
if (this.#disposed) {
throw new Error('BundlerContext was disposed during build.');
}
result = await build(this.#esbuildOptions);
if (this.#disposed) {
throw new Error('BundlerContext was disposed during build.');
}
}
Comment thread
clydin marked this conversation as resolved.
} catch (failure) {
// Build failures will throw an exception which contains errors/warnings
Expand Down
Loading