Skip to content

Commit

Permalink
Remove object-assign polyfill
Browse files Browse the repository at this point in the history
We really rely on a more modern environment where this is typically
polyfilled anyway and we don't officially support IE with more extensive
polyfilling anyway. So all environments should have the native version
by now.
  • Loading branch information
sebmarkbage committed Feb 23, 2022
1 parent 4035157 commit 4b72d2e
Show file tree
Hide file tree
Showing 26 changed files with 12 additions and 140 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"minimist": "^1.2.3",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"object-assign": "^4.1.1",
"pacote": "^10.3.0",
"prettier": "1.19.1",
"prop-types": "^15.6.2",
Expand Down
3 changes: 0 additions & 3 deletions packages/jest-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
"react": "^17.0.0",
"react-test-renderer": "^17.0.0"
},
"dependencies": {
"object-assign": "^4.1.1"
},
"files": [
"LICENSE",
"README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/npm/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

'use strict';

var assign = require('object-assign');
var assign = Object.assign;
var PropTypes = require('prop-types');
var React = require('react');
var ReactART = require('react-art');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/npm/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

'use strict';

var assign = require('object-assign');
var assign = Object.assign;
var PropTypes = require('prop-types');
var React = require('react');
var ReactART = require('react-art');
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/npm/Wedge.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

'use strict';

var assign = require('object-assign');
var assign = Object.assign;
var PropTypes = require('prop-types');
var React = require('react');
var ReactART = require('react-art');
Expand Down
1 change: 0 additions & 1 deletion packages/react-art/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"art": "^0.10.1",
"create-react-class": "^15.6.2",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"scheduler": "^0.20.1"
},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"react": "^17.0.0"
},
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
Expand Down
3 changes: 1 addition & 2 deletions packages/react-debug-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"react": "^17.0.0"
},
"dependencies": {
"error-stack-parser": "^2.0.2",
"object-assign": "^4.1.1"
"error-stack-parser": "^2.0.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
* @flow
*/

import assign from 'object-assign';
import {getElementDimensions, getNestedBoundingClientRect} from '../utils';

const assign = Object.assign;

import type {DevToolsHook} from 'react-devtools-shared/src/backend/types';
import type {Rect} from '../utils';

Expand Down
1 change: 0 additions & 1 deletion packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"homepage": "https://reactjs.org/",
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"scheduler": "^0.20.1"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/react-native-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"directory": "packages/react-native-renderer"
},
"dependencies": {
"object-assign": "^4.1.1",
"scheduler": "^0.11.0"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/react-noop-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
},
"license": "MIT",
"dependencies": {
"object-assign": "^4.1.1",
"react-reconciler": "*",
"react-client": "*",
"react-server": "*"
Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"scheduler": "^0.20.1"
},
"browserify": {
Expand Down
1 change: 0 additions & 1 deletion packages/react-server-dom-relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"directory": "packages/react-server-dom-relay"
},
"dependencies": {
"object-assign": "^4.1.1",
"scheduler": "^0.11.0"
},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/react-server-dom-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
"dependencies": {
"acorn": "^6.2.1",
"neo-async": "^2.6.1",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
Expand Down
1 change: 0 additions & 1 deletion packages/react-server-native-relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"directory": "packages/react-server-native-relay"
},
"dependencies": {
"object-assign": "^4.1.1",
"scheduler": "^0.11.0"
},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/react-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"react": "^17.0.0"
},
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
Expand Down
1 change: 0 additions & 1 deletion packages/react-test-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
},
"homepage": "https://reactjs.org/",
"dependencies": {
"object-assign": "^4.1.1",
"react-is": "^17.0.3",
"react-shallow-renderer": "^16.13.1",
"scheduler": "^0.20.1"
Expand Down
3 changes: 1 addition & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"node": ">=0.10.0"
},
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/ReactSharedInternals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import assign from 'object-assign';
import ReactCurrentDispatcher from './ReactCurrentDispatcher';
import ReactCurrentBatchConfig from './ReactCurrentBatchConfig';
import ReactCurrentActQueue from './ReactCurrentActQueue';
Expand All @@ -16,8 +15,6 @@ const ReactSharedInternals = {
ReactCurrentDispatcher,
ReactCurrentBatchConfig,
ReactCurrentOwner,
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
assign,
};

if (__DEV__) {
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/forks/ReactSharedInternals.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import assign from 'object-assign';
import * as Scheduler from 'scheduler';
import ReactCurrentDispatcher from '../ReactCurrentDispatcher';
import ReactCurrentActQueue from '../ReactCurrentActQueue';
Expand All @@ -17,8 +16,6 @@ const ReactSharedInternals = {
ReactCurrentDispatcher,
ReactCurrentOwner,
ReactCurrentBatchConfig,
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
assign,

// Re-export the schedule API(s) for UMD bundles.
// This avoids introducing a dependency on a new UMD global in a minor update,
Expand Down
3 changes: 1 addition & 2 deletions packages/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
},
"homepage": "https://reactjs.org/",
"dependencies": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
"loose-envify": "^1.1.0"
},
"files": [
"LICENSE",
Expand Down
3 changes: 0 additions & 3 deletions packages/use-subscription/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
"cjs/"
],
"license": "MIT",
"dependencies": {
"object-assign": "^4.1.1"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0"
},
Expand Down
54 changes: 0 additions & 54 deletions scripts/babel/transform-object-assign-require.js

This file was deleted.

18 changes: 1 addition & 17 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const prettier = require('rollup-plugin-prettier');
const replace = require('rollup-plugin-replace');
const stripBanner = require('rollup-plugin-strip-banner');
const chalk = require('chalk');
const path = require('path');
const resolve = require('rollup-plugin-node-resolve');
const fs = require('fs');
const argv = require('minimist')(process.argv.slice(2));
Expand Down Expand Up @@ -177,22 +176,7 @@ function getBabelConfig(
options.plugins.push(require('../error-codes/transform-error-messages'));
}

switch (bundleType) {
case UMD_DEV:
case UMD_PROD:
case UMD_PROFILING:
case NODE_DEV:
case NODE_PROD:
case NODE_PROFILING:
return Object.assign({}, options, {
plugins: options.plugins.concat([
// Use object-assign polyfill in open source
path.resolve('./scripts/babel/transform-object-assign-require'),
]),
});
default:
return options;
}
return options;
}

function getRollupOutputOptions(
Expand Down
32 changes: 0 additions & 32 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,6 @@ const __EXPERIMENTAL__ =
// algorithm because 1) require.resolve doesn't work with ESM modules, and 2)
// the behavior is easier to predict.
const forks = Object.freeze({
// Optimization: for UMDs, use a version that we can inline into the React bundle.
// Use that from all other bundles.

// NOTE: This is hard-coded to the main entry point of the (third-party)
// object-assign package.
'./node_modules/object-assign/index.js': (
bundleType,
entry,
dependencies
) => {
if (
bundleType !== UMD_DEV &&
bundleType !== UMD_PROD &&
bundleType !== UMD_PROFILING
) {
// It's only relevant for UMD bundles since that's where the duplication
// happens. Other bundles just require('object-assign') anyway.
return null;
}
if (entry === 'react' || entry === 'react/src/ReactSharedSubset.js') {
// Use the forked version that uses ES modules instead of CommonJS.
return './packages/shared/forks/object-assign.inline-umd.js';
}
if (dependencies.indexOf('react') === -1) {
// We can only apply the optimizations to bundle that depend on React
// because we read assign() from an object exposed on React internals.
return null;
}
// We can use the fork that reads the secret export!
return './packages/shared/forks/object-assign.umd.js';
},

// NOTE: This is hard-coded to the main entry point of the (third-party)
// react-shallow-renderer package.
'./node_modules/react-shallow-renderer/index.js': () => {
Expand Down

0 comments on commit 4b72d2e

Please sign in to comment.