From f5bc3f959ec113278e97b5e9d8bdde7fc6cdd8a0 Mon Sep 17 00:00:00 2001 From: tariqksoliman Date: Tue, 3 Oct 2023 17:43:55 -0700 Subject: [PATCH] Update ModuleScopePlugin --- configuration/webpack.config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/configuration/webpack.config.js b/configuration/webpack.config.js index 02c92bae..3f4c1e22 100644 --- a/configuration/webpack.config.js +++ b/configuration/webpack.config.js @@ -25,6 +25,15 @@ const postcssNormalize = require("postcss-normalize"); const appPackageJson = require(paths.appPackageJson); +const babelRuntimeEntry = require.resolve("babel-preset-react-app"); +const babelRuntimeEntryHelpers = require.resolve( + "@babel/runtime/helpers/esm/assertThisInitialized", + { paths: [babelRuntimeEntry] } +); +const babelRuntimeRegenerator = require.resolve("@babel/runtime/regenerator", { + paths: [babelRuntimeEntry], +}); + // This is a hack so that node v18+ can run. // "md4" hashes are no longer supported so before everything runs, we override them to be "sha256" const crypto = require("crypto"); @@ -285,7 +294,12 @@ module.exports = function (webpackEnv) { // To fix this, we prevent you from importing files out of src/ -- if you'd like to, // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. - new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), + new ModuleScopePlugin(paths.appSrc, [ + paths.appPackageJson, + babelRuntimeEntry, + babelRuntimeEntryHelpers, + babelRuntimeRegenerator, + ]), ], fallback: { fs: false,