From 8be84529e453f0b75720bd576a6edac0630f971b Mon Sep 17 00:00:00 2001 From: Sibiraj Date: Mon, 3 Dec 2018 21:47:22 +0530 Subject: [PATCH 1/4] feat: set jsonpFunction by default --- packages/react-scripts/config/webpack.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 746884a03eb..a76505da425 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -178,6 +178,9 @@ module.exports = function(webpackEnv) { .replace(/\\/g, '/') : isEnvDevelopment && (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')), + // Added to prevent conflicts within app when multiple webpack runtimes + // (from different compilation) are used on the same webpage. + jsonpFunction: '__REACT_APP', }, optimization: { minimize: isEnvProduction, From 2af593035f6902e88bbf0c37885a961b674e47b5 Mon Sep 17 00:00:00 2001 From: sibiraj-s Date: Thu, 1 Aug 2019 20:50:26 +0530 Subject: [PATCH 2/4] Use App Name for jsonpFunction --- packages/react-scripts/config/webpack.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 5736d79aeea..ade538a9fb7 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -39,6 +39,8 @@ const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier'); // @remove-on-eject-end const postcssNormalize = require('postcss-normalize'); +const appPackageJson = require(paths.appPackageJson); + // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; // Some apps do not need the benefits of saving a web request, so not inlining the chunk @@ -191,7 +193,7 @@ module.exports = function(webpackEnv) { (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')), // Added to prevent conflicts within app when multiple webpack runtimes // (from different compilation) are used on the same webpage. - jsonpFunction: '__REACT_APP', + jsonpFunction: appPackageJson.name, }, optimization: { minimize: isEnvProduction, From 24f25fae095dfa3c8e1b0e076e791917388738df Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Mon, 5 Aug 2019 11:05:31 +0300 Subject: [PATCH 3/4] Prefix jsonpFunction with webpackJsonp --- packages/react-scripts/config/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index ade538a9fb7..d8c9c3d6f5f 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -193,7 +193,7 @@ module.exports = function(webpackEnv) { (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')), // Added to prevent conflicts within app when multiple webpack runtimes // (from different compilation) are used on the same webpage. - jsonpFunction: appPackageJson.name, + jsonpFunction: `webpackJsonp${appPackageJson.name}`, }, optimization: { minimize: isEnvProduction, From 5af1526565cb65d718bbaa8b65156b2bda64d809 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Mon, 5 Aug 2019 11:07:08 +0300 Subject: [PATCH 4/4] Update webpack.config.js --- packages/react-scripts/config/webpack.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index d8c9c3d6f5f..83257ea02e9 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -191,8 +191,8 @@ module.exports = function(webpackEnv) { .replace(/\\/g, '/') : isEnvDevelopment && (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')), - // Added to prevent conflicts within app when multiple webpack runtimes - // (from different compilation) are used on the same webpage. + // Prevents conflicts when multiple Webpack runtimes (from different apps) + // are used on the same page. jsonpFunction: `webpackJsonp${appPackageJson.name}`, }, optimization: { @@ -202,7 +202,7 @@ module.exports = function(webpackEnv) { new TerserPlugin({ terserOptions: { parse: { - // we want terser to parse ecma 8 code. However, we don't want it + // We want terser to parse ecma 8 code. However, we don't want it // to apply any minification steps that turns valid ecma 5 code // into invalid ecma 5 code. This is why the 'compress' and 'output' // sections only apply transformations that are ecma 5 safe