Skip to content

Commit

Permalink
Combine createElement and JSX modules (#28320)
Browse files Browse the repository at this point in the history
Depends on:

- #28317

---

There's a ton of overlap between the createElement implementation and
the JSX implementation, so I combined them into a single module.

In the actual build output, the shared code between JSX and
createElement will get duplicated anyway, because react/jsx-runtime and
react (where createElement lives) are separate, flat build artifacts.

So this is more about code organization — with a few key exceptions, the
implementations of createElement and jsx are highly coupled.

DiffTrain build for [5fb2c93](5fb2c93)
  • Loading branch information
acdlite committed Feb 20, 2024
1 parent 3b13b94 commit 3f81ef2
Show file tree
Hide file tree
Showing 13 changed files with 7,007 additions and 8,347 deletions.
16 changes: 7 additions & 9 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ if (__DEV__) {
// $FlowFixMe[method-unbinding]
var hasOwnProperty = Object.prototype.hasOwnProperty;

var assign = Object.assign;

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
Expand Down Expand Up @@ -375,8 +377,6 @@ if (__DEV__) {
return isArrayImpl(a);
}

var assign = Object.assign;

// Helpers to patch console.logs to avoid logging during side-effect free
// replaying on render function. This currently only patches the object
// lazily which won't cover if the log function was extracted eagerly.
Expand Down Expand Up @@ -1389,13 +1389,11 @@ if (__DEV__) {
*/

function isValidElement(object) {
{
return (
typeof object === "object" &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE
);
}
return (
typeof object === "object" &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE
);
}
var ownerHasKeyUseWarning = {};
/**
Expand Down
16 changes: 7 additions & 9 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ if (__DEV__) {
// $FlowFixMe[method-unbinding]
var hasOwnProperty = Object.prototype.hasOwnProperty;

var assign = Object.assign;

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
* and Temporal.* types. See https://github.com/facebook/react/pull/22064.
Expand Down Expand Up @@ -375,8 +377,6 @@ if (__DEV__) {
return isArrayImpl(a);
}

var assign = Object.assign;

// Helpers to patch console.logs to avoid logging during side-effect free
// replaying on render function. This currently only patches the object
// lazily which won't cover if the log function was extracted eagerly.
Expand Down Expand Up @@ -1389,13 +1389,11 @@ if (__DEV__) {
*/

function isValidElement(object) {
{
return (
typeof object === "object" &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE
);
}
return (
typeof object === "object" &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE
);
}
var ownerHasKeyUseWarning = {};
/**
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ec160f32c28ccab798c73ecccbb36ce121e1640e
5fb2c93f3924ba980444da5698f60651b5ef0689
Loading

0 comments on commit 3f81ef2

Please sign in to comment.