Skip to content

Commit a6867f5

Browse files
committed
fix(@angular-devkit/build-angular): shim node events builtin for dev server
The dev server requires a node 'events' builtin shim to function. The dev server as written only currently works with package managers that hoist the `events` shim package to an accessible location. Hoisting is unfortantely not standardized and the assumption within the dev server will not hold true for all package managers. Closes angular#13680
1 parent 81acdd7 commit a6867f5

File tree

1 file changed

+11
-0
lines changed
  • packages/angular_devkit/build_angular/src/dev-server

1 file changed

+11
-0
lines changed

packages/angular_devkit/build_angular/src/dev-server/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
149149
opnAddress = serverAddress + webpackDevServerConfig.publicPath;
150150
webpackConfig.devServer = webpackDevServerConfig;
151151

152+
// The dev server requires a node 'events' builtin shim to function.
153+
// The dev server as written only currently works with package managers
154+
// that hoist the `events` shim package to an accessible location.
155+
// Hoisting is unfortantely not standardized and the assumption within
156+
// the dev server will not hold true for all package managers.
157+
if (!webpackConfig.node) {
158+
webpackConfig.node = { events: true };
159+
} else if (typeof webpackConfig.node === 'object') {
160+
webpackConfig.node.events = true;
161+
}
162+
152163
return webpackDevServerBuilder.runWebpackDevServer(
153164
webpackConfig, undefined, getBrowserLoggingCb(browserOptions.verbose),
154165
);

0 commit comments

Comments
 (0)