Skip to content

Commit

Permalink
Update rollup to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
ymqy committed Jan 30, 2023
1 parent 4f5365b commit 7e08a9d
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 353 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"@babel/preset-flow": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"@babel/traverse": "^7.11.0",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.7.5",
"art": "0.10.1",
Expand Down Expand Up @@ -64,6 +68,7 @@
"filesize": "^6.0.1",
"flow-bin": "^0.196.3",
"flow-remove-types": "^2.196.1",
"fs-extra": "^11.1.0",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20200517.0.0",
Expand All @@ -86,13 +91,9 @@
"random-seed": "^0.3.0",
"react-lifecycles-compat": "^3.0.4",
"rimraf": "^3.0.0",
"rollup": "^1.19.4",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^2.1.1",
"rollup-plugin-prettier": "^0.6.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-strip-banner": "^0.2.0",
"rollup": "^3.12.0",
"rollup-plugin-prettier": "^3.0.0",
"rollup-plugin-strip-banner": "^3.0.0",
"semver": "^7.1.1",
"targz": "^1.0.1",
"through2": "^3.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

export * from 'react-client/src/ReactFlightClientHostConfigBrowser';
export * from 'react-client/src/ReactFlightClientHostConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig';
export * from 'react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js';
4 changes: 0 additions & 4 deletions packages/react-devtools-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
"os-name": "^3.1.0",
"parse-filepath": "^1.0.2",
"raw-loader": "^3.1.0",
"rollup": "^1.19.4",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^2.1.1",
"source-map-js": "^0.6.2",
"sourcemap-codec": "^1.4.8",
"style-loader": "^0.23.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const {
const {emptyDirSync} = require('fs-extra');
const {resolve} = require('path');
const rollup = require('rollup');
const babel = require('rollup-plugin-babel');
const commonjs = require('rollup-plugin-commonjs');
const babel = require('@rollup/plugin-babel').babel;
const commonjs = require('@rollup/plugin-commonjs');
const jsx = require('acorn-jsx');
const rollupResolve = require('rollup-plugin-node-resolve');
const rollupResolve = require('@rollup/plugin-node-resolve');
const {encode, decode} = require('sourcemap-codec');
const {generateEncodedHookMap} = require('../generateHookMap');
const {parse} = require('@babel/parser');
Expand Down Expand Up @@ -323,7 +323,11 @@ async function bundle() {
plugins: [
rollupResolve(),
commonjs(),
babel({presets: ['@babel/preset-react'], sourceMap: true}),
babel({
presets: ['@babel/preset-react'],
sourceMap: true,
babelHelpers: 'bundled',
}),
],
external: ['react'],
});
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dom/src/server/ReactDOMFizzStaticNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import type {ReactNodeList} from 'shared/ReactTypes';
import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/ReactDOMServerFormatConfig';

import {Writable, Readable} from 'stream';
import type {Writable} from 'stream';
import {Readable} from 'stream';

import ReactVersion from 'shared/ReactVersion';

Expand Down
9 changes: 5 additions & 4 deletions packages/react-dom/src/test-utils/FizzTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import * as tmp from 'tmp';
import * as fs from 'fs';
import replace from 'rollup-plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import {rollup} from 'rollup';
import path from 'path';

Expand All @@ -30,15 +30,16 @@ async function getRollupResult(scriptSrc: string): Promise<string | null> {
input: require.resolve(scriptSrc),
onwarn: console.warn,
plugins: [
replace({__DEV__: 'true'}),
replace({preventAssignment: true, values: {__DEV__: 'true'}}),
resolve({
rootDir: path.join(__dirname, '..', '..', '..'),
}),
],
output: {
externalLiveBindings: false,
freeze: false,
interop: false,
interop: 'auto',
exports: 'auto',
esModule: false,
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/unstable_server-external-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* @flow
*/

export * from 'react-dom-bindings/src/server/ReactDOMServerExternalRuntime';
module.exports = require('react-dom-bindings/src/server/ReactDOMServerExternalRuntime');
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js';
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
*/

export * from '../ReactFlightServerConfigStream';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig';
export * from 'react-server-dom-webpack/src/ReactFlightServerWebpackBundlerConfig.js';
35 changes: 21 additions & 14 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

const rollup = require('rollup');
const babel = require('rollup-plugin-babel');
const babel = require('@rollup/plugin-babel').babel;
const closure = require('./plugins/closure-plugin');
const commonjs = require('rollup-plugin-commonjs');
const commonjs = require('@rollup/plugin-commonjs');
const flowRemoveTypes = require('flow-remove-types');
const prettier = require('rollup-plugin-prettier');
const replace = require('rollup-plugin-replace');
const replace = require('@rollup/plugin-replace');
const stripBanner = require('rollup-plugin-strip-banner');
const chalk = require('chalk');
const resolve = require('rollup-plugin-node-resolve');
const resolve = require('@rollup/plugin-node-resolve');
const fs = require('fs');
const argv = require('minimist')(process.argv.slice(2));
const Modules = require('./modules');
Expand Down Expand Up @@ -144,6 +144,7 @@ function getBabelConfig(
exclude: '/**/node_modules/**',
babelrc: false,
configFile: false,
babelHelpers: 'bundled',
presets: [],
plugins: [...babelPlugins],
};
Expand Down Expand Up @@ -185,7 +186,8 @@ function getRollupOutputOptions(
format,
globals,
freeze: !isProduction,
interop: false,
interop: 'auto',
exports: 'auto',
name: globalName,
sourcemap: false,
esModule: false,
Expand Down Expand Up @@ -366,11 +368,14 @@ function getPlugins(
},
// Turn __DEV__ and process.env checks into constants.
replace({
__DEV__: isProduction ? 'false' : 'true',
__PROFILE__: isProfiling || !isProduction ? 'true' : 'false',
__UMD__: isUMDBundle ? 'true' : 'false',
'process.env.NODE_ENV': isProduction ? "'production'" : "'development'",
__EXPERIMENTAL__,
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.
Expand Down Expand Up @@ -550,14 +555,15 @@ async function createBundle(bundle, bundleType) {
}

const importSideEffects = Modules.getImportSideEffects();
const pureExternalModules = Object.keys(importSideEffects).filter(
const moduleSideEffects = Object.keys(importSideEffects).filter(
module => !importSideEffects[module]
);

const rollupConfig = {
strictDeprecations: true,
input: resolvedEntry,
treeshake: {
pureExternalModules,
moduleSideEffects,
},
external(id) {
const containsThisModule = pkg => id === pkg || id.startsWith(pkg + '/');
Expand Down Expand Up @@ -588,13 +594,14 @@ async function createBundle(bundle, bundleType) {
bundleType,
bundle.global,
bundle.moduleType,
pureExternalModules,
moduleSideEffects,
bundle
),
output: {
externalLiveBindings: false,
freeze: false,
interop: false,
interop: 'auto',
exports: 'auto',
esModule: false,
},
};
Expand Down
Loading

0 comments on commit 7e08a9d

Please sign in to comment.