d2ae7893910a462faef18b67f8f75a1caa8efe85.svn-base
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _pluginSyntaxJsx = _interopRequireDefault(require("@babel/plugin-syntax-jsx"));
var _helperBuilderReactJsxExperimental = require("@babel/helper-builder-react-jsx-experimental");
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _core = require("@babel/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)((api, options) => {
const PURE_ANNOTATION = options.pure;
const visitor = (0, _helperBuilderReactJsxExperimental.helper)(api, Object.assign({
pre(state) {
const tagName = state.tagName;
const args = state.args;
if (_core.types.react.isCompatTag(tagName)) {
args.push(_core.types.stringLiteral(tagName));
} else {
args.push(state.tagExpr);
}
},
post(state, pass) {
if (pass.get("@babel/plugin-react-jsx/runtime") === "classic") {
state.createElementCallee = pass.get("@babel/plugin-react-jsx/createElementIdentifier")();
state.pure = PURE_ANNOTATION != null ? PURE_ANNOTATION : !pass.get("@babel/plugin-react-jsx/pragmaSet");
} else {
state.jsxCallee = pass.get("@babel/plugin-react-jsx/jsxIdentifier")();
state.jsxStaticCallee = pass.get("@babel/plugin-react-jsx/jsxStaticIdentifier")();
state.createElementCallee = pass.get("@babel/plugin-react-jsx/createElementIdentifier")();
state.pure = PURE_ANNOTATION != null ? PURE_ANNOTATION : !pass.get("@babel/plugin-react-jsx/importSourceSet");
}
}
}, options, {
development: false
}));
return {
name: "transform-react-jsx",
inherits: _pluginSyntaxJsx.default,
visitor
};
});
exports.default = _default;