Skip to content

Commit 950c302

Browse files
committed
fix(@angular-devkit/build-angular): support pnpm with ng serve
Webpack and its development server assume the presence of two node builtins (`events` & `querystring`). Do to package hoisting npm/yarn will usually place the shims for those two builtins at locations that webpack find them. This is however not guaranteed nor will it work with pnpm which strictly follows the prescribed dependency tree. To remedy this, the specific node shims are enabled only for the specific internal webpack files that are used within the development server. This ensures that the requirements of these files does not pollute the entire application. Fixes #13680
1 parent 77f2af0 commit 950c302

File tree

2 files changed

+9
-1
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs

2 files changed

+9
-1
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
107107
},
108108
} as webpack.Options.Optimization,
109109
plugins: extraPlugins,
110-
node: false,
110+
node: { },
111111
};
112112
}

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

+8
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
402402
test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
403403
parser: { system: true },
404404
},
405+
{
406+
test: /[\/\\]hot[\/\\]emitter.js$/,
407+
parser: { node: { events: true } },
408+
},
409+
{
410+
test: /[\/\\]webpack-dev-server[\/\\]client[\/\\]utils[\/\\]createSocketUrl.js$/,
411+
parser: { node: { querystring: true } },
412+
},
405413
{
406414
test: /\.js$/,
407415
...buildOptimizerUseRule,

0 commit comments

Comments
 (0)