feat: initial commit
This commit is contained in:
22
node_modules/@babel/plugin-transform-react-pure-annotations/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/plugin-transform-react-pure-annotations/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
node_modules/@babel/plugin-transform-react-pure-annotations/README.md
generated
vendored
Normal file
19
node_modules/@babel/plugin-transform-react-pure-annotations/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/plugin-transform-react-pure-annotations
|
||||
|
||||
> Mark top-level React method calls as pure for tree shaking
|
||||
|
||||
See our website [@babel/plugin-transform-react-pure-annotations](https://babeljs.io/docs/babel-plugin-transform-react-pure-annotations) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-react-pure-annotations
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-react-pure-annotations --dev
|
||||
```
|
49
node_modules/@babel/plugin-transform-react-pure-annotations/lib/index.js
generated
vendored
Normal file
49
node_modules/@babel/plugin-transform-react-pure-annotations/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
"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 = [["react", new Set(["cloneElement", "createContext", "createElement", "createFactory", "createRef", "forwardRef", "isValidElement", "memo", "lazy"])], ["react-dom", new Set(["createPortal"])]];
|
||||
var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
|
||||
api.assertVersion(7);
|
||||
return {
|
||||
name: "transform-react-pure-annotations",
|
||||
visitor: {
|
||||
CallExpression(path) {
|
||||
if (isReactCall(path)) {
|
||||
(0, _helperAnnotateAsPure.default)(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
function isReactCall(path) {
|
||||
const calleePath = path.get("callee");
|
||||
if (!calleePath.isMemberExpression()) {
|
||||
for (const [module, methods] of PURE_CALLS) {
|
||||
for (const method of methods) {
|
||||
if (calleePath.referencesImport(module, method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const object = calleePath.get("object");
|
||||
const callee = calleePath.node;
|
||||
if (!callee.computed && _core.types.isIdentifier(callee.property)) {
|
||||
const propertyName = callee.property.name;
|
||||
for (const [module, methods] of PURE_CALLS) {
|
||||
if (object.referencesImport(module, "default") || object.referencesImport(module, "*")) {
|
||||
return methods.has(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/plugin-transform-react-pure-annotations/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/plugin-transform-react-pure-annotations/lib/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"names":["_helperPluginUtils","require","_helperAnnotateAsPure","_core","PURE_CALLS","Set","_default","exports","default","declare","api","assertVersion","name","visitor","CallExpression","path","isReactCall","annotateAsPure","calleePath","get","isMemberExpression","module","methods","method","referencesImport","object","callee","node","computed","t","isIdentifier","property","propertyName","has"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport annotateAsPure from \"@babel/helper-annotate-as-pure\";\nimport { types as t, type NodePath } from \"@babel/core\";\n\n// Mapping of React top-level methods that are pure.\n// This plugin adds a /*#__PURE__#/ annotation to calls to these methods,\n// so that terser and other minifiers can safely remove them during dead\n// code elimination.\n// See https://reactjs.org/docs/react-api.html\nconst PURE_CALLS: [string, Set<string>][] = [\n [\n \"react\",\n new Set([\n \"cloneElement\",\n \"createContext\",\n \"createElement\",\n \"createFactory\",\n \"createRef\",\n \"forwardRef\",\n \"isValidElement\",\n \"memo\",\n \"lazy\",\n ]),\n ],\n [\"react-dom\", new Set([\"createPortal\"])],\n];\n\nexport default declare(api => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n return {\n name: \"transform-react-pure-annotations\",\n visitor: {\n CallExpression(path) {\n if (isReactCall(path)) {\n annotateAsPure(path);\n }\n },\n },\n };\n});\n\nfunction isReactCall(path: NodePath<t.CallExpression>) {\n // If the callee is not a member expression, then check if it matches\n // a named import, e.g. `import {forwardRef} from 'react'`.\n const calleePath = path.get(\"callee\");\n if (!calleePath.isMemberExpression()) {\n for (const [module, methods] of PURE_CALLS) {\n for (const method of methods) {\n if (calleePath.referencesImport(module, method)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n // Otherwise, check if the member expression's object matches\n // a default import (`import React from 'react'`) or namespace\n // import (`import * as React from 'react'), and check if the\n // property matches one of the pure methods.\n const object = calleePath.get(\"object\");\n const callee = calleePath.node;\n if (!callee.computed && t.isIdentifier(callee.property)) {\n const propertyName = callee.property.name;\n for (const [module, methods] of PURE_CALLS) {\n if (\n object.referencesImport(module, \"default\") ||\n object.referencesImport(module, \"*\")\n ) {\n return methods.has(propertyName);\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAOA,MAAMG,UAAmC,GAAG,CAC1C,CACE,OAAO,EACP,IAAIC,GAAG,CAAC,CACN,cAAc,EACd,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,MAAM,CACP,CAAC,CACH,EACD,CAAC,WAAW,EAAE,IAAIA,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CACzC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAkB,CAAE,CAAC;EAEtC,OAAO;IACLC,IAAI,EAAE,kCAAkC;IACxCC,OAAO,EAAE;MACPC,cAAcA,CAACC,IAAI,EAAE;QACnB,IAAIC,WAAW,CAACD,IAAI,CAAC,EAAE;UACrB,IAAAE,6BAAc,EAACF,IAAI,CAAC;QACtB;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAEF,SAASC,WAAWA,CAACD,IAAgC,EAAE;EAGrD,MAAMG,UAAU,GAAGH,IAAI,CAACI,GAAG,CAAC,QAAQ,CAAC;EACrC,IAAI,CAACD,UAAU,CAACE,kBAAkB,CAAC,CAAC,EAAE;IACpC,KAAK,MAAM,CAACC,MAAM,EAAEC,OAAO,CAAC,IAAIlB,UAAU,EAAE;MAC1C,KAAK,MAAMmB,MAAM,IAAID,OAAO,EAAE;QAC5B,IAAIJ,UAAU,CAACM,gBAAgB,CAACH,MAAM,EAAEE,MAAM,CAAC,EAAE;UAC/C,OAAO,IAAI;QACb;MACF;IACF;IAEA,OAAO,KAAK;EACd;EAMA,MAAME,MAAM,GAAGP,UAAU,CAACC,GAAG,CAAC,QAAQ,CAAC;EACvC,MAAMO,MAAM,GAAGR,UAAU,CAACS,IAAI;EAC9B,IAAI,CAACD,MAAM,CAACE,QAAQ,IAAIC,WAAC,CAACC,YAAY,CAACJ,MAAM,CAACK,QAAQ,CAAC,EAAE;IACvD,MAAMC,YAAY,GAAGN,MAAM,CAACK,QAAQ,CAACnB,IAAI;IACzC,KAAK,MAAM,CAACS,MAAM,EAAEC,OAAO,CAAC,IAAIlB,UAAU,EAAE;MAC1C,IACEqB,MAAM,CAACD,gBAAgB,CAACH,MAAM,EAAE,SAAS,CAAC,IAC1CI,MAAM,CAACD,gBAAgB,CAACH,MAAM,EAAE,GAAG,CAAC,EACpC;QACA,OAAOC,OAAO,CAACW,GAAG,CAACD,YAAY,CAAC;MAClC;IACF;EACF;EAEA,OAAO,KAAK;AACd","ignoreList":[]}
|
34
node_modules/@babel/plugin-transform-react-pure-annotations/package.json
generated
vendored
Normal file
34
node_modules/@babel/plugin-transform-react-pure-annotations/package.json
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-react-pure-annotations",
|
||||
"version": "7.24.7",
|
||||
"description": "Mark top-level React method calls as pure for tree shaking",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-react-pure-annotations"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-annotate-as-pure": "^7.24.7",
|
||||
"@babel/helper-plugin-utils": "^7.24.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.7",
|
||||
"@babel/helper-plugin-test-runner": "^7.24.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
20
node_modules/@babel/plugin-transform-react-pure-annotations/tsconfig.json
generated
vendored
Normal file
20
node_modules/@babel/plugin-transform-react-pure-annotations/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/* This file is automatically generated by scripts/generators/tsconfig.js */
|
||||
{
|
||||
"extends": [
|
||||
"../../tsconfig.base.json",
|
||||
"../../tsconfig.paths.json"
|
||||
],
|
||||
"include": [
|
||||
"../../packages/babel-plugin-transform-react-pure-annotations/src/**/*.ts",
|
||||
"../../lib/globals.d.ts",
|
||||
"../../scripts/repo-utils/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../packages/babel-helper-plugin-utils"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/babel-helper-annotate-as-pure"
|
||||
}
|
||||
]
|
||||
}
|
1
node_modules/@babel/plugin-transform-react-pure-annotations/tsconfig.tsbuildinfo
generated
vendored
Normal file
1
node_modules/@babel/plugin-transform-react-pure-annotations/tsconfig.tsbuildinfo
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user