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>
This commit is contained in:
Joe Haddad
2020-08-31 15:16:47 -04:00
committed by GitHub
parent ce6a7f1d98
commit 371e152cd2
5 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
{
"plugins": [
"./plugin.js",
["transform-react-jsx-development", { "runtime": "automatic" }]
]
}

View File

@@ -0,0 +1,6 @@
// empty
var _reactJsxDevRuntime = require("react/jsx-dev-runtime");
/*#__PURE__*/
_reactJsxDevRuntime.jsxDEV("div", {}, void 0, false, void 0, this)

View File

@@ -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")),
[]
)
);
}
}
}
};
};