Repository: facebook/react
File: scripts/rollup/build.js (JavaScript)

Code before:
        bundleType,
        packageName,
        externals,
        !isProduction,
        bundle
      )
    ),
    // Remove 'use strict' from individual source files.
    {
      transform(source) {
        return source.replace(/['"]use strict["']/g, '');
      },
    },
    // Turn __DEV__ and process.env checks into constants.
    replace({
      preventAssignment: true,
      values: {
        __DEV__: isProduction ? 'false' : 'true',
        __PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
        __UMD__: isUMDBundle ? 'true' : 'false',
        'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
        __EXPERIMENTAL__,
        // Enable forked reconciler.
        // NOTE: I did not put much thought into how to configure this.
        __VARIANT__: bundle.enableNewReconciler === true,
      }
    }),
    // 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(
        Object.assign({}, closureOptions, {
          // Don't let it create global variables in the browser.
          // https://github.com/facebook/react/issues/10909
          assume_function_wrapper: !isUMDBundle,
          renaming: !shouldStayReadable,
        })
      ),
    // HACK to work around the fact that Rollup isn't removing unused, pure-module imports.
    // Note that this plugin must be called after closure applies DCE.
    isProduction && stripUnusedImports(pureExternalModules),
    // Add the whitespace back if necessary.
    shouldStayReadable &&
      prettier({
        parser: 'babel',
        singleQuote: false,
        trailingComma: 'none',
        bracketSpacing: true,

Review comment (suggestion):
- https://github.com/rollup/plugins/tree/master/packages/replace#preventassignment
- https://github.com/rollup/plugins/tree/master/packages/replace#values

Code after:
    // Use Node resolution mechanism.
    resolve({
      // skip: externals, // TODO: options.skip was removed in @rollup/plugin-node-resolve 3.0.0
    }),
    // Remove license headers from individual modules
    stripBanner({
      exclude: 'node_modules/**/*',
    }),
    // Compile to ES2015.
    babel(
      getBabelConfig(
        updateBabelOptions,
        bundleType,
        packageName,
        externals,
        !isProduction,
        bundle
      )
    ),
    // Remove 'use strict' from individual source files.
    {
      transform(source) {
        return source.replace(/['"]use strict["']/g, '');
      },
    },
    // Turn __DEV__ and process.env checks into constants.
    replace({
      preventAssignment: true,
      values: {
        __DEV__: isProduction ? 'false' : 'true',
        __PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
        __UMD__: isUMDBundle ? 'true' : 'false',
        'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
        __EXPERIMENTAL__,
      },
    }),
    // 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.
    // closure doesn't yet support leaving ESM imports intact
    isProduction &&
      bundleType !== NODE_ESM &&
      closure({
        compilation_level: 'SIMPLE',
        language_in: 'ECMASCRIPT_2018',
        language_out:
          bundleType === NODE_ES2015
            ? 'ECMASCRIPT_2018'
            : bundleType === BROWSER_SCRIPT