Skip to content

fix(@angular-devkit/build-angular): shim node events builtin for dev server #13725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 13 additions & 0 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,19 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
}
if (!webpackConfig.entry.main) { webpackConfig.entry.main = []; }
webpackConfig.entry.main.unshift(...entryPoints);

// The dev server live reload 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 unfortunately not standardized and the assumption within
// the dev server will not hold true for all package managers.
// The actual code is only accessed when hmr is enabled which allows
// the 'events' import to be ignored in the non-hmr case.
if (!webpackConfig.node) {
webpackConfig.node = { events: options.hmr || false };
} else if (typeof webpackConfig.node === 'object') {
webpackConfig.node.events = webpackConfig.node.events || options.hmr || false;
}
}

private _addSslConfig(
Expand Down