From 8ccfce460f141299d61290f877745407e05e531e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Fri, 28 Feb 2020 16:46:17 -0800 Subject: [PATCH] Only use Rollup's CommonJS plugin for "react-art" (#18186) * Only use Rollup's CommonJS plugin for "react-art" We still need it for the "art" UMD builds but nothing else should have CommonJS dependencies anymore. * react-debug-tools and jest-react should leave object-assign as an external dep This avoids it being compiled into the output. --- packages/jest-react/package.json | 3 +++ packages/react-debug-tools/package.json | 3 ++- scripts/rollup/build.js | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/jest-react/package.json b/packages/jest-react/package.json index bbb1a34a8279d..506eb22a8e35a 100644 --- a/packages/jest-react/package.json +++ b/packages/jest-react/package.json @@ -23,6 +23,9 @@ "react": "^16.0.0", "react-test-renderer": "^16.0.0" }, + "dependencies": { + "object-assign": "^4.1.1" + }, "files": [ "LICENSE", "README.md", diff --git a/packages/react-debug-tools/package.json b/packages/react-debug-tools/package.json index 1a2e787d12bc4..0d69a5f55f509 100644 --- a/packages/react-debug-tools/package.json +++ b/packages/react-debug-tools/package.json @@ -29,6 +29,7 @@ "react": "^16.0.0" }, "dependencies": { - "error-stack-parser": "^2.0.2" + "error-stack-parser": "^2.0.2", + "object-assign": "^4.1.1" } } diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 2bf93d8e18558..c3e7d8c7c73a8 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -392,8 +392,10 @@ function getPlugins( 'process.env.NODE_ENV': isProduction ? "'production'" : "'development'", __EXPERIMENTAL__, }), - // We still need CommonJS for external deps like object-assign. - commonjs(), + // The CommonJS plugin *only* exists to pull "art" into "react-art". + // I'm going to port "art" to ES modules to avoid this problem. + // Please don't enable this for anything else! + isUMDBundle && entry === 'react-art' && commonjs(), // Apply dead code elimination and/or minification. isProduction && closure(