Skip to content

Commit

Permalink
[babel 8] Use the JSX automatic runtime by default (#12630)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Arun Kumar Mohan <arunmohandm@gmail.com>
  • Loading branch information
nicolo-ribaudo and arku committed Jan 19, 2021
1 parent 6e8250a commit 10978bb
Show file tree
Hide file tree
Showing 103 changed files with 217 additions and 93 deletions.
2 changes: 1 addition & 1 deletion packages/babel-node/test/config.json
@@ -1,7 +1,7 @@
{
"presets": [
"../../babel-preset-env",
["../../babel-preset-react"]
["../../babel-preset-react", { "runtime": "classic" }]
],
"plugins": [
"../../babel-plugin-transform-strict-mode",
Expand Down
Expand Up @@ -2,7 +2,7 @@
"plugins": [
"external-helpers",
"transform-async-to-generator",
"transform-react-jsx",
["transform-react-jsx", { "runtime": "classic" }],
"transform-react-constant-elements"
]
}
Expand Up @@ -2,7 +2,7 @@
"plugins": [
"transform-block-scoping",
"syntax-jsx",
"transform-react-jsx",
["transform-react-jsx", { "runtime": "classic" }],
"transform-block-scoped-functions",
"transform-arrow-functions"
]
Expand Down
@@ -1,4 +1,7 @@
{
"plugins": ["external-helpers", "proposal-class-properties"],
"presets": [["env", { "targets": { "browsers": "ie 6" } }], "react"]
"presets": [
["env", { "targets": { "browsers": "ie 6" } }],
["react", { "runtime": "classic" }]
]
}
@@ -1,3 +1,6 @@
{
"presets": [["env", { "targets": { "browsers": "ie 6" } }], "react"]
"presets": [
["env", { "targets": { "browsers": "ie 6" } }],
["react", { "runtime": "classic" }]
]
}
@@ -1,3 +1,6 @@
{
"plugins": ["transform-react-jsx", "transform-react-constant-elements"]
"plugins": [
["transform-react-jsx", { "runtime": "classic" }],
"transform-react-constant-elements"
]
}
@@ -1,3 +1,6 @@
{
"plugins": ["transform-react-jsx", "transform-react-constant-elements"]
"plugins": [
["transform-react-jsx", { "runtime": "classic" }],
"transform-react-constant-elements"
]
}
Expand Up @@ -3,7 +3,7 @@
"external-helpers",
"syntax-jsx",
"transform-react-inline-elements",
"transform-react-jsx",
["transform-react-jsx", { "runtime": "classic" }],
"transform-modules-commonjs"
]
}
Expand Up @@ -3,7 +3,7 @@
"external-helpers",
"syntax-jsx",
"transform-react-inline-elements",
"transform-react-jsx",
["transform-react-jsx", { "runtime": "classic" }],
"transform-modules-commonjs"
]
}
Expand Up @@ -3,6 +3,6 @@
"external-helpers",
"syntax-jsx",
"transform-react-inline-elements",
"transform-react-jsx"
["transform-react-jsx", { "runtime": "classic" }]
]
}
Expand Up @@ -30,7 +30,11 @@ export default function createPlugin({ name, development }) {
// TODO (Babel 8): It should throw if this option is used with the automatic runtime
filter,

runtime: RUNTIME_DEFAULT = development ? "automatic" : "classic",
runtime: RUNTIME_DEFAULT = process.env.BABEL_8_BREAKING
? "automatic"
: development
? "automatic"
: "classic",

importSource: IMPORT_SOURCE_DEFAULT = DEFAULT.importSource,
pragma: PRAGMA_DEFAULT = DEFAULT.pragma,
Expand Down
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pure": false, "runtime": "automatic" }]
]
}
@@ -0,0 +1,3 @@
var _reactJsxRuntime = require("react/jsx-runtime");

_reactJsxRuntime.jsx("div", {});
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pure": false, "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1,6 @@
{
"plugins": [
["transform-react-jsx", { "pure": false, "runtime": "automatic" }]
],
"throws": "pragma and pragmaFrag cannot be set when runtime is automatic"
}
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pure": false, "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1,6 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "h", "pure": false, "runtime": "automatic" }]
],
"throws": "pragma and pragmaFrag cannot be set when runtime is automatic."
}
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "h", "pure": false, "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pure": true, "runtime": "automatic" }]
]
}
@@ -0,0 +1,4 @@
var _reactJsxRuntime = require("react/jsx-runtime");

/*#__PURE__*/
_reactJsxRuntime.jsx("div", {});
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pure": true, "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1,6 @@
{
"plugins": [
["transform-react-jsx", { "pure": true, "runtime": "automatic" }]
],
"throws": "pragma and pragmaFrag cannot be set when runtime is automatic"
}
@@ -0,0 +1,3 @@
/* @jsx h */

<div />;
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pure": true, "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1 @@
<div />;
@@ -0,0 +1,6 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "h", "pure": true, "runtime": "automatic" }]
],
"throws": "pragma and pragmaFrag cannot be set when runtime is automatic."
}
@@ -0,0 +1 @@
<div />;
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "h", "pure": true, "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1 @@
<div />;
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "runtime": "automatic" }]
]
}
@@ -0,0 +1,4 @@
var _reactJsxRuntime = require("react/jsx-runtime");

/*#__PURE__*/
_reactJsxRuntime.jsx("div", {});
@@ -0,0 +1 @@
<div />;
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1,3 @@
/* @jsx h */

<div />;
@@ -0,0 +1,6 @@
{
"plugins": [
["transform-react-jsx", { "runtime": "automatic" }]
],
"throws": "pragma and pragmaFrag cannot be set when runtime is automatic"
}
@@ -0,0 +1,3 @@
/* @jsx h */

<div />;
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "runtime": "classic" }]
]
}

This file was deleted.

@@ -0,0 +1 @@
<div />;
@@ -0,0 +1,6 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "h", "runtime": "automatic" }]
],
"throws": "pragma and pragmaFrag cannot be set when runtime is automatic."
}
@@ -0,0 +1 @@
<div />;
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "h", "runtime": "classic" }]
]
}

This file was deleted.

@@ -1,3 +1,3 @@
{
"plugins": [["transform-react-jsx", { "pragma": "foo.bar" }]]
"plugins": [["transform-react-jsx", { "pragma": "foo.bar", "runtime": "classic" }]]
}
@@ -1,3 +1,3 @@
{
"plugins": [["transform-react-jsx", { "pragma": "dom" }]]
"plugins": [["transform-react-jsx", { "pragma": "dom", "runtime": "classic" }]]
}
Expand Up @@ -2,7 +2,7 @@
"plugins": [
"external-helpers",
"syntax-jsx",
"transform-react-jsx",
["transform-react-jsx", { "runtime": "classic" }],
"transform-arrow-functions"
]
}
@@ -1,3 +1,6 @@
{
"plugins": ["transform-react-jsx", "transform-property-literals"]
"plugins": [
["transform-react-jsx", { "runtime": "classic" }],
"transform-property-literals"
]
}
Expand Up @@ -4,6 +4,7 @@
"transform-react-jsx",
{
"pragma": "h",
"runtime": "classic",
"throwIfNamespace": false
}
]
Expand Down
Expand Up @@ -4,6 +4,7 @@
"transform-react-jsx",
{
"pragma": "h",
"runtime": "classic",
"throwIfNamespace": true
}
]
Expand Down
@@ -0,0 +1,5 @@
{
"plugins": [
["transform-react-jsx", { "runtime": "classic" }]
]
}

This file was deleted.

@@ -1,3 +1,4 @@
{
"BABEL_8_BREAKING": true,
"plugins": ["transform-react-jsx"]
}
@@ -0,0 +1,5 @@
var _reactJsxRuntime = require("react/jsx-runtime");

var x = /*#__PURE__*/_reactJsxRuntime.jsx("div", {
children: /*#__PURE__*/_reactJsxRuntime.jsx("span", {})
});
@@ -0,0 +1 @@
var x = (<div><span /></div>);
@@ -0,0 +1,4 @@
{
"BABEL_8_BREAKING": false,
"plugins": ["transform-react-jsx"]
}
@@ -1,6 +1,7 @@
{
"plugins": ["transform-react-jsx", ["proposal-object-rest-spread", {
"loose": true,
"useBuiltIns": false
}], "external-helpers"]
"plugins": [
["transform-react-jsx", { "runtime": "classic" }],
["proposal-object-rest-spread", { "loose": true, "useBuiltIns": false }],
"external-helpers"
]
}
@@ -1,3 +1,5 @@
var div = /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
var _reactJsxRuntime = require("react/jsx-runtime");

var div = /*#__PURE__*/_reactJsxRuntime.jsx(Component, Object.assign({}, props, {
foo: "bar"
}));

0 comments on commit 10978bb

Please sign in to comment.