Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rollup to v3 #26078

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"@babel/preset-flow": "^7.10.4",
"@babel/preset-react": "^7.10.4",
"@babel/traverse": "^7.11.0",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.1",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.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",
"abortcontroller-polyfill": "^1.7.5",
"art": "0.10.1",
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
Expand Down Expand Up @@ -89,9 +89,9 @@
"random-seed": "^0.3.0",
"react-lifecycles-compat": "^3.0.4",
"rimraf": "^3.0.0",
"rollup": "^2.76.0",
"rollup": "^3.17.1",
"rollup-plugin-prettier": "^3.0.0",
"rollup-plugin-strip-banner": "^2.0.0",
"rollup-plugin-strip-banner": "^3.0.0",
"semver": "^7.1.1",
"targz": "^1.0.1",
"through2": "^3.0.1",
Expand Down
4 changes: 0 additions & 4 deletions packages/react-devtools-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-react-jsx-source": "^7.10.5",
"@babel/preset-react": "^7.10.4",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.1",
"@rollup/plugin-node-resolve": "^13.3.0",
"acorn-jsx": "^5.2.0",
"archiver": "^3.0.0",
"babel-core": "^7.0.0-bridge",
Expand Down Expand Up @@ -58,7 +55,6 @@
"os-name": "^3.1.0",
"parse-filepath": "^1.0.2",
"raw-loader": "^3.1.0",
"rollup": "^2.76.0",
"source-map-js": "^0.6.2",
"sourcemap-codec": "^1.4.8",
"style-loader": "^0.23.1",
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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix build error
image


import ReactVersion from 'shared/ReactVersion';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/test-utils/FizzTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function getRollupResult(scriptSrc: string): Promise<string | null> {
output: {
externalLiveBindings: false,
freeze: false,
interop: false,
interop: 'default',
esModule: false,
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server-dom-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"./server.node.unbundled": "./server.node.unbundled.js",
"./node-loader": "./esm/react-server-dom-webpack-node-loader.production.min.js",
"./node-register": "./node-register.js",
"./src/*": "./src/*",
"./src/*": "./src/*.js",
"./package.json": "./package.json"
},
"main": "index.js",
Expand Down
6 changes: 4 additions & 2 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const sizes = require('./plugins/sizes-plugin');
const useForks = require('./plugins/use-forks-plugin');
const stripUnusedImports = require('./plugins/strip-unused-imports');
const dynamicImports = require('./plugins/dynamic-imports');
const disableTreeshake = require('./plugins/disable-treeshake');
const Packaging = require('./packaging');
const {asyncRimRaf} = require('./utils');
const codeFrame = require('@babel/code-frame');
Expand Down Expand Up @@ -188,7 +189,7 @@ function getRollupOutputOptions(
format,
globals,
freeze: !isProduction,
interop: false,
interop: 'default',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interop configuration uses the default values to minimize the size increase of the production bundles and pass the ci, and to be honest I'm not very confident about this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From looking at the generated output files, I think this looks mostly right.

There's still a bit of extra code here (you can see the diffs in this comment #26078 (comment) )

Example larger build where the change is visible: https://react-builds.vercel.app/commits/cc7dbd62a503bf502eb911b82a28926cf4d177e9/files/oss-stable/react-debug-tools/cjs/react-debug-tools.development.js?compare=4a4ef2706cfb51db96d48fe20dadcb4fb8e3cb17

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this should be 'esModule' instead of 'default'

name: globalName,
sourcemap: false,
esModule: false,
Expand Down Expand Up @@ -333,6 +334,7 @@ function getPlugins(
bundleType === RN_FB_PROFILING;
const shouldStayReadable = isFBWWWBundle || isRNBundle || forcePrettyOutput;
return [
disableTreeshake(),
// Keep dynamic imports as externals
dynamicImports(),
{
Expand Down Expand Up @@ -616,7 +618,7 @@ async function createBundle(bundle, bundleType) {
output: {
externalLiveBindings: false,
freeze: false,
interop: false,
interop: 'default',
esModule: false,
},
};
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ const bundles = [
{
bundleTypes: [NODE_ES2015],
moduleType: RENDERER_UTILS,
entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister.js',
entry: 'react-server-dom-webpack/src/ReactFlightWebpackNodeRegister',
name: 'react-server-dom-webpack-node-register',
global: 'ReactFlightWebpackNodeRegister',
minifyWithProdErrorCodes: false,
Expand Down
23 changes: 23 additions & 0 deletions scripts/rollup/plugins/disable-treeshake.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';

module.exports = function disableTreeshake() {
return {
name: 'scripts/rollup/plugins/disable-treeshake',
transform(code, id) {
if (id.endsWith('DOMProperty.js')) {
return {
code,
map: null,
moduleSideEffects: 'no-treeshake',
};
}
return null;
},
};
};
Loading