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
4 changes: 2 additions & 2 deletions goldens/public-api/angular_devkit/build_webpack/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import { BuilderContext } from '@angular-devkit/architect';
import { BuilderOutput } from '@angular-devkit/architect';
import { Observable } from 'rxjs';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import type webpack from 'webpack';
import type WebpackDevServer from 'webpack-dev-server';

// @public (undocumented)
export type BuildResult = BuilderOutput & {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"terser": "5.43.1",
"tree-kill": "1.2.2",
"tslib": "2.8.1",
"webpack": "5.101.2",
"webpack": "5.104.1",
"webpack-dev-middleware": "7.4.2",
"webpack-dev-server": "5.2.2",
"webpack-merge": "6.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular_devkit/build_webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@angular-devkit/core": "workspace:0.0.0-PLACEHOLDER",
"@ngtools/webpack": "workspace:0.0.0-PLACEHOLDER",
"webpack": "5.101.2",
"webpack": "5.104.1",
"webpack-dev-server": "5.2.2"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { Builder, BuilderContext, createBuilder } from '@angular-devkit/architec
import assert from 'node:assert';
import { resolve as pathResolve } from 'node:path';
import { Observable, from, isObservable, of, switchMap } from 'rxjs';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import type webpack from 'webpack';
import type WebpackDevServer from 'webpack-dev-server';
import { getEmittedFiles, getWebpackConfig } from '../../utils';
import { BuildResult, WebpackFactory, WebpackLoggingCallback } from '../webpack';
import { Schema as WebpackDevServerBuilderSchema } from './schema';
Expand Down Expand Up @@ -44,7 +44,7 @@ export function runWebpackDevServer(
return of(result);
}
} else {
return of(webpack(c));
return from(import('webpack').then((mod) => mod.default(c)));
}
};

Expand All @@ -54,9 +54,9 @@ export function runWebpackDevServer(
) => {
if (options.webpackDevServerFactory) {
return new options.webpackDevServerFactory(config, webpack);
} else {
return from(import('webpack-dev-server').then((mod) => new mod.default(config, webpack)));
}

return new WebpackDevServer(config, webpack);
};

const {
Expand All @@ -70,16 +70,21 @@ export function runWebpackDevServer(
} = options;

return createWebpack({ ...config, watch: false }).pipe(
switchMap(async (webpackCompiler) => {
return [
webpackCompiler,
options.webpackDevServerFactory ?? (await import('webpack-dev-server')).default,
] as unknown as [webpack.Compiler | null, WebpackDevServerFactory];
}),
switchMap(
(webpackCompiler) =>
([webpackCompiler, webpackDevServerFactory]) =>
new Observable<DevServerBuildOutput>((obs) => {
assert(webpackCompiler, 'Webpack compiler factory did not return a compiler instance.');

const devServerConfig = options.devServerConfig || config.devServer || {};
devServerConfig.host ??= 'localhost';

let result: Partial<DevServerBuildOutput>;

const statsOptions = typeof config.stats === 'boolean' ? undefined : config.stats;

webpackCompiler.hooks.done.tap('build-webpack', (stats) => {
Expand All @@ -94,7 +99,7 @@ export function runWebpackDevServer(
} as unknown as DevServerBuildOutput);
});

const devServer = createWebpackDevServer(webpackCompiler, devServerConfig);
const devServer = new webpackDevServerFactory(devServerConfig, webpackCompiler);
devServer.startCallback((err) => {
if (err) {
obs.error(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Builder, BuilderContext, BuilderOutput, createBuilder } from '@angular-
import assert from 'node:assert';
import { resolve as pathResolve } from 'node:path';
import { Observable, from, isObservable, of, switchMap } from 'rxjs';
import webpack from 'webpack';
import type webpack from 'webpack';
import { EmittedFiles, getEmittedFiles, getWebpackConfig } from '../../utils';
import { Schema as RealWebpackBuilderSchema } from './schema';

Expand Down Expand Up @@ -57,7 +57,7 @@ export function runWebpack(
return of(result);
}
} else {
return of(webpack(c));
return from(import('webpack').then((mod) => mod.default(c)));
}
};

Expand Down Expand Up @@ -104,7 +104,7 @@ export function runWebpack(

// Teardown logic. Close the watcher when unsubscribed from.
return () => {
watching.close(() => {});
watching?.close(() => {});
webpackCompiler.close(() => {});
};
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"@angular/compiler": "20.3.7",
"@angular/compiler-cli": "20.3.7",
"typescript": "5.9.2",
"webpack": "5.101.2"
"webpack": "5.104.1"
}
}
Loading