Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsx): do not throw on generated element in development mode (#12017)
* Fix `jsxDEV` for generated elements * Throw invariant error * Add test * test: revise test layout * fix: node 6 does not support trailing comma * Use undefined node Co-authored-by: Hu谩ng J霉nli脿ng <jlhwung@gmail.com>
- Loading branch information
Showing
5 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...lugin-transform-react-jsx-development/test/fixtures/cross-platform/generated-jsx/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// empty |
6 changes: 6 additions & 0 deletions
6
...n-transform-react-jsx-development/test/fixtures/cross-platform/generated-jsx/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": [ | ||
"./plugin.js", | ||
["transform-react-jsx-development", { "runtime": "automatic" }] | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
...ugin-transform-react-jsx-development/test/fixtures/cross-platform/generated-jsx/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// empty | ||
|
||
var _reactJsxDevRuntime = require("react/jsx-dev-runtime"); | ||
|
||
/*#__PURE__*/ | ||
_reactJsxDevRuntime.jsxDEV("div", {}, void 0, false, void 0, this) |
18 changes: 18 additions & 0 deletions
18
...ugin-transform-react-jsx-development/test/fixtures/cross-platform/generated-jsx/plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = function ({ types: t }) { | ||
return { | ||
visitor: { | ||
Program: { | ||
enter(path) { | ||
path.pushContainer( | ||
"body", | ||
t.JSXElement( | ||
t.JSXOpeningElement(t.JSXIdentifier("div"), [], false), | ||
t.JSXClosingElement(t.JSXIdentifier("div")), | ||
[] | ||
) | ||
); | ||
} | ||
} | ||
} | ||
}; | ||
}; |