Setup JSX runtime even if the file doesn't contain JSX (#12479)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
const foo = 2;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["transform-react-jsx", { "runtime": "automatic" }],
|
||||
"./plugin.js"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
const foo = /*#__PURE__*/undefined.jsx("p", {});
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = ({ types: t }) => ({
|
||||
visitor: {
|
||||
NumericLiteral(path) {
|
||||
path.replaceWith(
|
||||
t.jsxElement(
|
||||
t.jsxOpeningElement(t.jsxIdentifier("p"), []),
|
||||
t.jsxClosingElement(t.jsxIdentifier("p")),
|
||||
[]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
const foo = 2;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["transform-react-jsx", { "runtime": "classic" }],
|
||||
"./plugin.js"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
const foo = /*#__PURE__*/React.createElement("p", null);
|
||||
13
packages/babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-classic/plugin.js
vendored
Normal file
13
packages/babel-plugin-transform-react-jsx/test/fixtures/regression/issue-12478-classic/plugin.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = ({ types: t }) => ({
|
||||
visitor: {
|
||||
NumericLiteral(path) {
|
||||
path.replaceWith(
|
||||
t.jsxElement(
|
||||
t.jsxOpeningElement(t.jsxIdentifier("p"), []),
|
||||
t.jsxClosingElement(t.jsxIdentifier("p")),
|
||||
[]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user