Skip to content

Commit 3ed2d03

Browse files
committed
Enable error code transform per package
Currently we're not consistent about which packages should have their errors minified in production and which ones should. This adds a field to the bundle configuration to control whether to apply the transform. We should decide what the criteria is going forward. I think it's probably a good idea to minify any package that gets sent over the network. So yes to modules that run in the browser, and no to modules that run on the server and during development only.
1 parent a6a6466 commit 3ed2d03

File tree

2 files changed

+70
-10
lines changed

2 files changed

+70
-10
lines changed

scripts/rollup/build.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ function getBabelConfig(
149149
bundleType,
150150
packageName,
151151
externals,
152-
isDevelopment
152+
isDevelopment,
153+
bundle
153154
) {
154155
const canAccessReactObject =
155156
packageName === 'react' || externals.indexOf('react') !== -1;
@@ -179,12 +180,6 @@ function getBabelConfig(
179180
case FB_WWW_DEV:
180181
case FB_WWW_PROD:
181182
case FB_WWW_PROFILING:
182-
return Object.assign({}, options, {
183-
plugins: options.plugins.concat([
184-
// Minify invariant messages
185-
require('../error-codes/transform-error-messages'),
186-
]),
187-
});
188183
case RN_OSS_DEV:
189184
case RN_OSS_PROD:
190185
case RN_OSS_PROFILING:
@@ -195,8 +190,9 @@ function getBabelConfig(
195190
plugins: options.plugins.concat([
196191
[
197192
require('../error-codes/transform-error-messages'),
198-
// Preserve full error messages in React Native build
199-
{noMinify: true},
193+
// Controls whether to replace error messages with error codes
194+
// in production. By default, error messages are replaced.
195+
{noMinify: bundle.minifyWithProdErrorCodes === false},
200196
],
201197
]),
202198
});
@@ -390,7 +386,8 @@ function getPlugins(
390386
bundleType,
391387
packageName,
392388
externals,
393-
!isProduction
389+
!isProduction,
390+
bundle
394391
)
395392
),
396393
// Remove 'use strict' from individual source files.

0 commit comments

Comments
 (0)