From 433ba94ac78ff4ddfd6c19c179cd931eda29f7ab Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Fri, 7 Jun 2024 16:39:17 -0400 Subject: [PATCH] Minify DEV bundles with closure The goal is to improve speed of the development by inlining and DCE unused branches. We have the ability to preserve some variable names and pretty print in the production version so might as well do the same with DEV. --- packages/shared/CheckStringCoercion.js | 1 + scripts/rollup/build.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/shared/CheckStringCoercion.js b/packages/shared/CheckStringCoercion.js index 1a061b660177b..a186d6755d99e 100644 --- a/packages/shared/CheckStringCoercion.js +++ b/packages/shared/CheckStringCoercion.js @@ -43,6 +43,7 @@ function willCoercionThrow(value: mixed): boolean { } } +/** @noinline */ function testStringCoercion(value: mixed) { // If you ended up here by following an exception call stack, here's what's // happened: you supplied an object or symbol value to React (as a prop, key, diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 2ade58493a5f2..df9fb00b09424 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -361,7 +361,8 @@ function getPlugins( const isProduction = isProductionBundleType(bundleType); const isProfiling = isProfilingBundleType(bundleType); - const needsMinifiedByClosure = isProduction && bundleType !== ESM_PROD; + const needsMinifiedByClosure = + bundleType !== ESM_PROD && bundleType !== ESM_DEV; return [ // Keep dynamic imports as externals