From 68519b13292c629e0decb009201deb42da6ec565 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 8 Jun 2023 15:22:24 +0200 Subject: [PATCH] add the required polyfills so jest-mock doesn't cause angular to fail building --- code/builders/builder-webpack5/package.json | 1 + .../builder-webpack5/src/preview/iframe-webpack.config.ts | 3 +++ code/yarn.lock | 1 + 3 files changed, 5 insertions(+) diff --git a/code/builders/builder-webpack5/package.json b/code/builders/builder-webpack5/package.json index c7d65f043dd6..8443b49c35af 100644 --- a/code/builders/builder-webpack5/package.json +++ b/code/builders/builder-webpack5/package.json @@ -82,6 +82,7 @@ "babel-plugin-named-exports-order": "^0.0.2", "browser-assert": "^1.2.1", "case-sensitive-paths-webpack-plugin": "^2.4.0", + "constants-browserify": "^1.0.0", "css-loader": "^6.7.1", "express": "^4.17.3", "fork-ts-checker-webpack-plugin": "^8.0.0", diff --git a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts index 35a25c4b93d9..44eff2e63bc9 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -308,10 +308,13 @@ export default async ( mainFields: ['browser', 'module', 'main'].filter(Boolean), alias: storybookPaths, fallback: { + stream: false, path: require.resolve('path-browserify'), assert: require.resolve('browser-assert'), util: require.resolve('util'), url: require.resolve('url'), + fs: false, + constants: require.resolve('constants-browserify'), }, // Set webpack to resolve symlinks based on whether the user has asked node to. // This feels like it should be default out-of-the-box in webpack :shrug: diff --git a/code/yarn.lock b/code/yarn.lock index ddcb6886fa43..349322ee4944 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5898,6 +5898,7 @@ __metadata: babel-plugin-named-exports-order: ^0.0.2 browser-assert: ^1.2.1 case-sensitive-paths-webpack-plugin: ^2.4.0 + constants-browserify: ^1.0.0 css-loader: ^6.7.1 express: ^4.17.3 fork-ts-checker-webpack-plugin: ^8.0.0