Skip to content

Commit 6b6d061

Browse files
Update Rollup and related plugins to their most recent versions (#24916)
Update Rollup and related plugins to their most recent versions + resolve any breaking changes/deprecations/etc along the way. I made each change piece by piece, so the commit history tells a pretty good story of what was changed where/how/why. fixes #24894 For the full deepdive/context, see: - #24894 The inspiration for this came from @jasonwilliams 's PR for attempting to add sourcemap output support to React's builds: - #20186 - #21946 But I figured that it would be useful to minimise the scope of changes in that PR, and to modernise the build tooling along the way. If any of these updates rely on a node version later than `10.x`, then the following PR may have to land first, otherwise things might break on AppVeyor: - #24891 - #24892 Co-authored-by: Sebastian Markbage <[email protected]>
1 parent bc38a3d commit 6b6d061

File tree

6 files changed

+167
-322
lines changed

6 files changed

+167
-322
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
"@babel/preset-flow": "^7.10.4",
3737
"@babel/preset-react": "^7.10.4",
3838
"@babel/traverse": "^7.11.0",
39+
"@rollup/plugin-babel": "^5.3.1",
40+
"@rollup/plugin-commonjs": "^22.0.1",
41+
"@rollup/plugin-node-resolve": "^13.3.0",
42+
"@rollup/plugin-replace": "^4.0.0",
3943
"abortcontroller-polyfill": "^1.7.5",
4044
"art": "0.10.1",
4145
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
@@ -85,13 +89,9 @@
8589
"random-seed": "^0.3.0",
8690
"react-lifecycles-compat": "^3.0.4",
8791
"rimraf": "^3.0.0",
88-
"rollup": "^1.19.4",
89-
"rollup-plugin-babel": "^4.0.1",
90-
"rollup-plugin-commonjs": "^9.3.4",
91-
"rollup-plugin-node-resolve": "^2.1.1",
92+
"rollup": "^2.76.0",
9293
"rollup-plugin-prettier": "^3.0.0",
93-
"rollup-plugin-replace": "^2.2.0",
94-
"rollup-plugin-strip-banner": "^0.2.0",
94+
"rollup-plugin-strip-banner": "^2.0.0",
9595
"semver": "^7.1.1",
9696
"targz": "^1.0.1",
9797
"through2": "^3.0.1",

packages/react-devtools-extensions/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
2828
"@babel/plugin-transform-react-jsx-source": "^7.10.5",
2929
"@babel/preset-react": "^7.10.4",
30+
"@rollup/plugin-babel": "^5.3.1",
31+
"@rollup/plugin-commonjs": "^22.0.1",
32+
"@rollup/plugin-node-resolve": "^13.3.0",
3033
"acorn-jsx": "^5.2.0",
3134
"archiver": "^3.0.0",
3235
"babel-core": "^7.0.0-bridge",
@@ -55,10 +58,7 @@
5558
"os-name": "^3.1.0",
5659
"parse-filepath": "^1.0.2",
5760
"raw-loader": "^3.1.0",
58-
"rollup": "^1.19.4",
59-
"rollup-plugin-babel": "^4.0.1",
60-
"rollup-plugin-commonjs": "^9.3.4",
61-
"rollup-plugin-node-resolve": "^2.1.1",
61+
"rollup": "^2.76.0",
6262
"source-map-js": "^0.6.2",
6363
"sourcemap-codec": "^1.4.8",
6464
"style-loader": "^0.23.1",

packages/react-devtools-shared/src/hooks/__tests__/updateMockSourceMaps.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const {
1010
const {emptyDirSync} = require('fs-extra');
1111
const {resolve} = require('path');
1212
const rollup = require('rollup');
13-
const babel = require('rollup-plugin-babel');
14-
const commonjs = require('rollup-plugin-commonjs');
13+
const babel = require('@rollup/plugin-babel').babel;
14+
const commonjs = require('@rollup/plugin-commonjs');
1515
const jsx = require('acorn-jsx');
16-
const rollupResolve = require('rollup-plugin-node-resolve');
16+
const rollupResolve = require('@rollup/plugin-node-resolve').nodeResolve;
1717
const {encode, decode} = require('sourcemap-codec');
1818
const {generateEncodedHookMap} = require('../generateHookMap');
1919
const {parse} = require('@babel/parser');
@@ -323,7 +323,11 @@ async function bundle() {
323323
plugins: [
324324
rollupResolve(),
325325
commonjs(),
326-
babel({presets: ['@babel/preset-react'], sourceMap: true}),
326+
babel({
327+
babelHelpers: 'bundled',
328+
presets: ['@babel/preset-react'],
329+
sourceMap: true,
330+
}),
327331
],
328332
external: ['react'],
329333
});

packages/react-dom/src/test-utils/FizzTestUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
import * as tmp from 'tmp';
1212
import * as fs from 'fs';
13-
import replace from 'rollup-plugin-replace';
14-
import resolve from 'rollup-plugin-node-resolve';
13+
import replace from '@rollup/plugin-replace';
14+
import resolve from '@rollup/plugin-node-resolve';
1515
import {rollup} from 'rollup';
1616
import path from 'path';
1717

@@ -30,7 +30,7 @@ async function getRollupResult(scriptSrc: string): Promise<string | null> {
3030
input: require.resolve(scriptSrc),
3131
onwarn: console.warn,
3232
plugins: [
33-
replace({__DEV__: 'true'}),
33+
replace({__DEV__: 'true', preventAssignment: true}),
3434
resolve({
3535
rootDir: path.join(__dirname, '..', '..', '..'),
3636
}),

scripts/rollup/build.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

33
const rollup = require('rollup');
4-
const babel = require('rollup-plugin-babel');
4+
const babel = require('@rollup/plugin-babel').babel;
55
const closure = require('./plugins/closure-plugin');
6-
const commonjs = require('rollup-plugin-commonjs');
6+
const commonjs = require('@rollup/plugin-commonjs');
77
const flowRemoveTypes = require('flow-remove-types');
88
const prettier = require('rollup-plugin-prettier');
9-
const replace = require('rollup-plugin-replace');
9+
const replace = require('@rollup/plugin-replace');
1010
const stripBanner = require('rollup-plugin-strip-banner');
1111
const chalk = require('chalk');
12-
const resolve = require('rollup-plugin-node-resolve');
12+
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
1313
const fs = require('fs');
1414
const argv = require('minimist')(process.argv.slice(2));
1515
const Modules = require('./modules');
@@ -146,6 +146,7 @@ function getBabelConfig(
146146
configFile: false,
147147
presets: [],
148148
plugins: [...babelPlugins],
149+
babelHelpers: 'bundled',
149150
};
150151
if (isDevelopment) {
151152
options.plugins.push(
@@ -189,6 +190,7 @@ function getRollupOutputOptions(
189190
name: globalName,
190191
sourcemap: false,
191192
esModule: false,
193+
exports: 'auto',
192194
};
193195
}
194196

@@ -342,7 +344,7 @@ function getPlugins(
342344
forbidFBJSImports(),
343345
// Use Node resolution mechanism.
344346
resolve({
345-
skip: externals,
347+
// skip: externals, // TODO: options.skip was removed in @rollup/plugin-node-resolve 3.0.0
346348
}),
347349
// Remove license headers from individual modules
348350
stripBanner({
@@ -367,11 +369,14 @@ function getPlugins(
367369
},
368370
// Turn __DEV__ and process.env checks into constants.
369371
replace({
370-
__DEV__: isProduction ? 'false' : 'true',
371-
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
372-
__UMD__: isUMDBundle ? 'true' : 'false',
373-
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
374-
__EXPERIMENTAL__,
372+
preventAssignment: true,
373+
values: {
374+
__DEV__: isProduction ? 'false' : 'true',
375+
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
376+
__UMD__: isUMDBundle ? 'true' : 'false',
377+
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
378+
__EXPERIMENTAL__,
379+
},
375380
}),
376381
// The CommonJS plugin *only* exists to pull "art" into "react-art".
377382
// I'm going to port "art" to ES modules to avoid this problem.
@@ -566,6 +571,7 @@ async function createBundle(bundle, bundleType) {
566571
treeshake: {
567572
moduleSideEffects: (id, external) =>
568573
!(external && pureExternalModules.includes(id)),
574+
propertyReadSideEffects: false,
569575
},
570576
external(id) {
571577
const containsThisModule = pkg => id === pkg || id.startsWith(pkg + '/');
@@ -655,7 +661,7 @@ async function createBundle(bundle, bundleType) {
655661

656662
function handleRollupWarning(warning) {
657663
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
658-
const match = warning.message.match(/external module '([^']+)'/);
664+
const match = warning.message.match(/external module "([^"]+)"/);
659665
if (!match || typeof match[1] !== 'string') {
660666
throw new Error(
661667
'Could not parse a Rollup warning. ' + 'Fix this method.'

0 commit comments

Comments
 (0)