Mark transpiled JSX elements as pure (#11126)

* Mark transpiled JSX elements as pure

* Avoid duble annotation

* Add "pure" option to the React preset

* Fix generator indentation

* Update tests

* Add tests for the "pure" option

* Update windows fixtures
This commit is contained in:
Nicolò Ribaudo
2020-03-19 15:43:54 +01:00
committed by GitHub
parent fa7ec81771
commit f3912ac08f
246 changed files with 613 additions and 314 deletions

View File

@@ -8,15 +8,19 @@ import transformReactJSXSelf from "@babel/plugin-transform-react-jsx-self";
export default declare((api, opts) => {
api.assertVersion(7);
const pragma = opts.pragma;
const pragmaFrag = opts.pragmaFrag;
const throwIfNamespace =
opts.throwIfNamespace === undefined ? true : !!opts.throwIfNamespace;
const {
pragma,
pragmaFrag,
pure,
throwIfNamespace = true,
useSpread,
runtime = "classic",
importSource,
} = opts;
// TODO: (Babel 8) Don't cast these options but validate it
const development = !!opts.development;
const useBuiltIns = !!opts.useBuiltIns;
const { useSpread } = opts;
const runtime = opts.runtime || "classic";
const importSource = opts.importSource;
if (typeof development !== "boolean") {
throw new Error(
@@ -41,6 +45,7 @@ export default declare((api, opts) => {
throwIfNamespace,
useBuiltIns,
useSpread,
pure,
},
],
transformReactDisplayName,