mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
65
web/node_modules/@babel/plugin-transform-react-pure-annotations/lib/index.js
generated
vendored
Normal file
65
web/node_modules/@babel/plugin-transform-react-pure-annotations/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
||||
|
||||
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
|
||||
|
||||
var _core = require("@babel/core");
|
||||
|
||||
const PURE_CALLS = new Map([["react", ["cloneElement", "createContext", "createElement", "createFactory", "createRef", "forwardRef", "isValidElement", "memo", "lazy"]], ["react-dom", ["createPortal"]]]);
|
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
api.assertVersion(7);
|
||||
return {
|
||||
name: "transform-react-pure-annotations",
|
||||
visitor: {
|
||||
CallExpression(path) {
|
||||
if (isReactCall(path)) {
|
||||
(0, _helperAnnotateAsPure.default)(path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
|
||||
function isReactCall(path) {
|
||||
if (!_core.types.isMemberExpression(path.node.callee)) {
|
||||
const callee = path.get("callee");
|
||||
|
||||
for (const [module, methods] of PURE_CALLS) {
|
||||
for (const method of methods) {
|
||||
if (callee.referencesImport(module, method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const [module, methods] of PURE_CALLS) {
|
||||
const object = path.get("callee.object");
|
||||
|
||||
if (object.referencesImport(module, "default") || object.referencesImport(module, "*")) {
|
||||
for (const method of methods) {
|
||||
if (_core.types.isIdentifier(path.node.callee.property, {
|
||||
name: method
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue