summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
commitaa773172311dcada759dfbaac485f4bc6e00bc21 (patch)
treeca6d9a5eff3ab8f689f9acb4f0df791d9486813d /node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js')
-rw-r--r--node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js b/node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js
new file mode 100644
index 00000000..fb62ea2b
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-modules-commonjs/lib/lazy.js
@@ -0,0 +1,44 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.lazyImportsHook = void 0;
+var _core = require("@babel/core");
+var _helperModuleTransforms = require("@babel/helper-module-transforms");
+const lazyImportsHook = lazy => ({
+ name: `${"@babel/plugin-transform-modules-commonjs"}/lazy`,
+ version: "7.23.0",
+ getWrapperPayload(source, metadata) {
+ if ((0, _helperModuleTransforms.isSideEffectImport)(metadata) || metadata.reexportAll) {
+ return null;
+ }
+ if (lazy === true) {
+ return /\./.test(source) ? null : "lazy/function";
+ }
+ if (Array.isArray(lazy)) {
+ return lazy.indexOf(source) === -1 ? null : "lazy/function";
+ }
+ if (typeof lazy === "function") {
+ return lazy(source) ? "lazy/function" : null;
+ }
+ },
+ buildRequireWrapper(name, init, payload, referenced) {
+ if (payload === "lazy/function") {
+ if (!referenced) return false;
+ return _core.template.statement.ast`
+ function ${name}() {
+ const data = ${init};
+ ${name} = function(){ return data; };
+ return data;
+ }
+ `;
+ }
+ },
+ wrapReference(ref, payload) {
+ if (payload === "lazy/function") return _core.types.callExpression(ref, []);
+ }
+});
+exports.lazyImportsHook = lazyImportsHook;
+
+//# sourceMappingURL=lazy.js.map