From 1ea4a5ffa5986bf066db4b2fecf51eb2f7329abe Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 12 Sep 2019 20:44:32 +0200 Subject: [PATCH] feat(@angular-devkit/build-angular): ignore express and hapi depedency expresstion (#15586) In version 9 universal express and hapi `server.ts` will be bundled using the CLI server builder. We need to add this to avoid `the request of a dependency is an expression` warnings See: https://github.com/angular/universal/pull/1237 --- .../angular-cli-files/models/webpack-configs/server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/server.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/server.ts index 6079bf1c16bd..200cac43c5c1 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/server.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/server.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import { isAbsolute } from 'path'; -import { Configuration } from 'webpack'; +import { Configuration, ContextReplacementPlugin } from 'webpack'; import { WebpackConfigOptions } from '../build-options'; import { getSourceMapDevTool } from './utils'; @@ -30,7 +30,12 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration { output: { libraryTarget: 'commonjs', }, - plugins: extraPlugins, + plugins: [ + // Fixes Critical dependency: the request of a dependency is an expression + new ContextReplacementPlugin(/@?hapi(\\|\/)/), + new ContextReplacementPlugin(/express(\\|\/)/), + ...extraPlugins, + ], node: false, };