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

Code before:
    forbidFBJSImports(),
    // 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.
    {
      name: "remove 'use strict'",
      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
    needsMinifiedByClosure &&
      closure(
        {
          compilation_level: 'SIMPLE',
          language_in: 'ECMASCRIPT_2020',
          language_out:
            bundleType === NODE_ES2015

Review comment (suggestion):
As I explored/proposed on a different PR, this step could make use of `@rollup/plugin-replace`, and then it wouldn't break/misalign sourcemaps emitted from earlier steps, etc:

- https://github.com/facebook/react/pull/21946#discussion_r917341160

Code after:
      // Ensure we don't try to bundle any fbjs modules.
      forbidFBJSImports(),
      // 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.
      {
        name: "remove 'use strict'",
        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(),
      // License and haste headers, top-level `if` blocks.
      {
        name: 'license-and-headers',
        renderChunk(source) {
          return Wrappers.wrapBundle(
            source,