@module-federation/modern-js 0.0.0-next-20240909083238 → 0.0.0-next-20240909101028
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{runtime/withMFRouteId.js → cli/constant.js} +6 -9
- package/dist/cjs/cli/index.js +1 -6
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +10 -7
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +38 -40
- package/dist/cjs/cli/ssrPlugin.js +1 -1
- package/dist/cjs/cli/utils.js +4 -8
- package/dist/cjs/cli/utils.spec.js +1 -1
- package/dist/cjs/constant.js +2 -32
- package/dist/cjs/runtime/index.js +1 -4
- package/dist/cjs/ssr-runtime/plugin.js +7 -7
- package/dist/esm/cli/constant.js +4 -0
- package/dist/esm/cli/index.js +1 -6
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +10 -7
- package/dist/esm/cli/ssrPlugin.js +1 -1
- package/dist/esm/cli/utils.js +3 -6
- package/dist/esm/cli/utils.spec.js +1 -1
- package/dist/esm/constant.js +1 -21
- package/dist/esm/runtime/index.js +1 -3
- package/dist/esm/ssr-runtime/plugin.js +10 -7
- package/dist/esm-node/cli/constant.js +4 -0
- package/dist/esm-node/cli/index.js +1 -6
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +10 -7
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +38 -40
- package/dist/esm-node/cli/ssrPlugin.js +1 -1
- package/dist/esm-node/cli/utils.js +3 -6
- package/dist/esm-node/cli/utils.spec.js +1 -1
- package/dist/esm-node/constant.js +1 -21
- package/dist/esm-node/runtime/index.js +1 -3
- package/dist/esm-node/ssr-runtime/plugin.js +7 -7
- package/dist/types/cli/constant.d.ts +1 -0
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +2 -2
- package/dist/types/cli/utils.d.ts +0 -2
- package/dist/types/constant.d.ts +0 -10
- package/dist/types/runtime/index.d.ts +0 -1
- package/dist/types/types/index.d.ts +0 -10
- package/package.json +11 -40
- package/dist/cjs/cli/dataLoader/ast/constant.js +0 -49
- package/dist/cjs/cli/dataLoader/ast/generateRoutes.js +0 -142
- package/dist/cjs/cli/dataLoader/ast/generateSelfRoutes.js +0 -48
- package/dist/cjs/cli/dataLoader/ast/generateSerializableRoutes.js +0 -90
- package/dist/cjs/cli/dataLoader/ast/generateSlimRoutes.js +0 -104
- package/dist/cjs/cli/dataLoader/ast/index.js +0 -37
- package/dist/cjs/cli/dataLoader/generateRouteFile.js +0 -143
- package/dist/cjs/cli/dataLoader/patchMFConfig.js +0 -137
- package/dist/cjs/cli/dataLoader/plugin.js +0 -205
- package/dist/cjs/cli/mfRuntimePlugins/node.js +0 -44
- package/dist/cjs/cli/server/dataLoaderPlugin.js +0 -82
- package/dist/cjs/cli/server/fetchRemoteFullRoutesMap.js +0 -68
- package/dist/cjs/interfaces/route.js +0 -16
- package/dist/cjs/runtime/dataLoader/plugin.js +0 -73
- package/dist/cjs/runtime/dataLoader/utils.js +0 -89
- package/dist/cjs/runtime/utils.js +0 -38
- package/dist/esm/cli/dataLoader/ast/constant.js +0 -18
- package/dist/esm/cli/dataLoader/ast/generateRoutes.js +0 -109
- package/dist/esm/cli/dataLoader/ast/generateSelfRoutes.js +0 -17
- package/dist/esm/cli/dataLoader/ast/generateSerializableRoutes.js +0 -57
- package/dist/esm/cli/dataLoader/ast/generateSlimRoutes.js +0 -73
- package/dist/esm/cli/dataLoader/ast/index.js +0 -10
- package/dist/esm/cli/dataLoader/generateRouteFile.js +0 -293
- package/dist/esm/cli/dataLoader/patchMFConfig.js +0 -103
- package/dist/esm/cli/dataLoader/plugin.js +0 -216
- package/dist/esm/cli/mfRuntimePlugins/node.js +0 -16
- package/dist/esm/cli/server/dataLoaderPlugin.js +0 -105
- package/dist/esm/cli/server/fetchRemoteFullRoutesMap.js +0 -86
- package/dist/esm/interfaces/route.js +0 -0
- package/dist/esm/runtime/dataLoader/plugin.js +0 -92
- package/dist/esm/runtime/dataLoader/utils.js +0 -63
- package/dist/esm/runtime/utils.js +0 -13
- package/dist/esm/runtime/withMFRouteId.js +0 -7
- package/dist/esm-node/cli/dataLoader/ast/constant.js +0 -18
- package/dist/esm-node/cli/dataLoader/ast/generateRoutes.js +0 -108
- package/dist/esm-node/cli/dataLoader/ast/generateSelfRoutes.js +0 -14
- package/dist/esm-node/cli/dataLoader/ast/generateSerializableRoutes.js +0 -56
- package/dist/esm-node/cli/dataLoader/ast/generateSlimRoutes.js +0 -70
- package/dist/esm-node/cli/dataLoader/ast/index.js +0 -10
- package/dist/esm-node/cli/dataLoader/generateRouteFile.js +0 -108
- package/dist/esm-node/cli/dataLoader/patchMFConfig.js +0 -103
- package/dist/esm-node/cli/dataLoader/plugin.js +0 -169
- package/dist/esm-node/cli/mfRuntimePlugins/node.js +0 -14
- package/dist/esm-node/cli/server/dataLoaderPlugin.js +0 -62
- package/dist/esm-node/cli/server/fetchRemoteFullRoutesMap.js +0 -43
- package/dist/esm-node/interfaces/route.js +0 -0
- package/dist/esm-node/runtime/dataLoader/plugin.js +0 -49
- package/dist/esm-node/runtime/dataLoader/utils.js +0 -63
- package/dist/esm-node/runtime/utils.js +0 -13
- package/dist/esm-node/runtime/withMFRouteId.js +0 -7
- package/dist/types/cli/dataLoader/ast/constant.d.ts +0 -8
- package/dist/types/cli/dataLoader/ast/generateRoutes.d.ts +0 -7
- package/dist/types/cli/dataLoader/ast/generateSelfRoutes.d.ts +0 -7
- package/dist/types/cli/dataLoader/ast/generateSerializableRoutes.d.ts +0 -5
- package/dist/types/cli/dataLoader/ast/generateSlimRoutes.d.ts +0 -7
- package/dist/types/cli/dataLoader/ast/index.d.ts +0 -4
- package/dist/types/cli/dataLoader/generateRouteFile.d.ts +0 -7
- package/dist/types/cli/dataLoader/patchMFConfig.d.ts +0 -11
- package/dist/types/cli/dataLoader/plugin.d.ts +0 -6
- package/dist/types/cli/mfRuntimePlugins/node.d.ts +0 -3
- package/dist/types/cli/server/dataLoaderPlugin.d.ts +0 -10
- package/dist/types/cli/server/fetchRemoteFullRoutesMap.d.ts +0 -10
- package/dist/types/interfaces/route.d.ts +0 -13
- package/dist/types/runtime/dataLoader/plugin.d.ts +0 -2
- package/dist/types/runtime/dataLoader/utils.d.ts +0 -19
- package/dist/types/runtime/utils.d.ts +0 -2
- package/dist/types/runtime/withMFRouteId.d.ts +0 -1
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var generateSlimRoutes_exports = {};
|
|
30
|
-
__export(generateSlimRoutes_exports, {
|
|
31
|
-
generateSlimRoutes: () => generateSlimRoutes
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(generateSlimRoutes_exports);
|
|
34
|
-
var import_fs = __toESM(require("fs"));
|
|
35
|
-
var import_traverse = __toESM(require("@babel/traverse"));
|
|
36
|
-
var babelParser = __toESM(require("@babel/parser"));
|
|
37
|
-
var import_generator = __toESM(require("@babel/generator"));
|
|
38
|
-
var t = __toESM(require("@babel/types"));
|
|
39
|
-
var import_constant = require("./constant");
|
|
40
|
-
function generateSlimRoutes({ sourceCode, filePath, prefix, baseName }) {
|
|
41
|
-
const ast = babelParser.parse(sourceCode, {
|
|
42
|
-
sourceType: "module"
|
|
43
|
-
});
|
|
44
|
-
const removedKeys = [
|
|
45
|
-
import_constant.COMPONENT,
|
|
46
|
-
import_constant.SHOULD_REVALIDATE,
|
|
47
|
-
import_constant.LAZY_COMPONENT,
|
|
48
|
-
import_constant.PRIVATE_COMPONENT
|
|
49
|
-
];
|
|
50
|
-
(0, import_traverse.default)(ast, {
|
|
51
|
-
// ImportDeclaration(path) {
|
|
52
|
-
// const source = path.node.source.value;
|
|
53
|
-
// const routeIdMatch = source.match(/routeId=([^&]+)/);
|
|
54
|
-
// if (routeIdMatch) {
|
|
55
|
-
// const originalRouteId = routeIdMatch[1];
|
|
56
|
-
// const newRouteId = `${prefix}${originalRouteId}`;
|
|
57
|
-
// const newSource = source.replace(
|
|
58
|
-
// /routeId=[^&]+/,
|
|
59
|
-
// `routeId=${newRouteId}`,
|
|
60
|
-
// );
|
|
61
|
-
// path.node.source = t.stringLiteral(newSource);
|
|
62
|
-
// }
|
|
63
|
-
// },
|
|
64
|
-
ObjectExpression(path) {
|
|
65
|
-
if (!Array.isArray(path.node.properties)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
path.node.properties = path.node.properties.filter((p) => {
|
|
69
|
-
if (t.isObjectProperty(p) && t.isStringLiteral(p.key)) {
|
|
70
|
-
return !removedKeys.includes(p.key.value);
|
|
71
|
-
} else {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const tempCode = (0, import_generator.default)(ast).code;
|
|
78
|
-
const tempAst = babelParser.parse(tempCode, {
|
|
79
|
-
sourceType: "module"
|
|
80
|
-
});
|
|
81
|
-
const usedIdentifiers = /* @__PURE__ */ new Set();
|
|
82
|
-
(0, import_traverse.default)(tempAst, {
|
|
83
|
-
Identifier(path) {
|
|
84
|
-
if (t.isProperty(path.parent)) {
|
|
85
|
-
usedIdentifiers.add(path.node.name);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
(0, import_traverse.default)(tempAst, {
|
|
90
|
-
ImportDeclaration(path) {
|
|
91
|
-
path.node.specifiers = path.node.specifiers.filter((specifier) => usedIdentifiers.has(specifier.local.name));
|
|
92
|
-
if (!path.node.specifiers.length) {
|
|
93
|
-
path.remove();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
const { code: newCode } = (0, import_generator.default)(tempAst);
|
|
98
|
-
const finalCode = `${newCode}export const baseName = '${baseName}';`;
|
|
99
|
-
import_fs.default.writeFileSync(filePath, finalCode);
|
|
100
|
-
}
|
|
101
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
-
0 && (module.exports = {
|
|
103
|
-
generateSlimRoutes
|
|
104
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var ast_exports = {};
|
|
20
|
-
__export(ast_exports, {
|
|
21
|
-
generateRoutes: () => import_generateRoutes.generateRoutes,
|
|
22
|
-
generateSelfRoutes: () => import_generateSelfRoutes.generateSelfRoutes,
|
|
23
|
-
generateSerializableRoutes: () => import_generateSerializableRoutes.generateSerializableRoutes,
|
|
24
|
-
generateSlimRoutes: () => import_generateSlimRoutes.generateSlimRoutes
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(ast_exports);
|
|
27
|
-
var import_generateRoutes = require("./generateRoutes");
|
|
28
|
-
var import_generateSlimRoutes = require("./generateSlimRoutes");
|
|
29
|
-
var import_generateSerializableRoutes = require("./generateSerializableRoutes");
|
|
30
|
-
var import_generateSelfRoutes = require("./generateSelfRoutes");
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
generateRoutes,
|
|
34
|
-
generateSelfRoutes,
|
|
35
|
-
generateSerializableRoutes,
|
|
36
|
-
generateSlimRoutes
|
|
37
|
-
});
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var generateRouteFile_exports = {};
|
|
30
|
-
__export(generateRouteFile_exports, {
|
|
31
|
-
calcPathName: () => calcPathName,
|
|
32
|
-
generateRouteFile: () => generateRouteFile
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(generateRouteFile_exports);
|
|
35
|
-
var import_utils = require("@modern-js/utils");
|
|
36
|
-
var import_path = __toESM(require("path"));
|
|
37
|
-
var import_constant = require("../../constant");
|
|
38
|
-
var import_utils2 = require("../../runtime/dataLoader/utils");
|
|
39
|
-
const ROUTES = "routes";
|
|
40
|
-
function calcPathName(filePath, rootDir, entry) {
|
|
41
|
-
const relativePath = import_path.default.relative(rootDir, filePath);
|
|
42
|
-
const conditionalReg = /^\[(.*)\]$/;
|
|
43
|
-
const splitPaths = relativePath.split("/").reduce((sum, cur) => {
|
|
44
|
-
if (cur.includes(".")) {
|
|
45
|
-
const split = cur.split(".").map((i) => {
|
|
46
|
-
const match = i.match(conditionalReg);
|
|
47
|
-
if (match) {
|
|
48
|
-
return `:${match[1]}`;
|
|
49
|
-
}
|
|
50
|
-
return i.startsWith("__") ? "" : i;
|
|
51
|
-
});
|
|
52
|
-
sum.push(...split);
|
|
53
|
-
} else {
|
|
54
|
-
const match = cur.match(conditionalReg);
|
|
55
|
-
if (match) {
|
|
56
|
-
sum.push(`:${match[1]}`);
|
|
57
|
-
} else {
|
|
58
|
-
if (!cur.startsWith("__")) {
|
|
59
|
-
sum.push(cur);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return sum;
|
|
64
|
-
}, []);
|
|
65
|
-
return import_path.default.join(entry, splitPaths.filter((p) => !!p).join("/"));
|
|
66
|
-
}
|
|
67
|
-
async function generateRouteFile(options) {
|
|
68
|
-
const { appDirectory } = options;
|
|
69
|
-
const entries = [];
|
|
70
|
-
const remotePathMap = {};
|
|
71
|
-
const srcPath = `${appDirectory}/src`;
|
|
72
|
-
const traverse = async (filepath, rootDir, entry) => {
|
|
73
|
-
if (!await import_utils.fs.pathExists(filepath)) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
const isDirectory = (await import_utils.fs.stat(filepath)).isDirectory();
|
|
77
|
-
if (!isDirectory) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const items = await import_utils.fs.readdir(filepath);
|
|
81
|
-
const mfJson = items.find((i) => i === import_constant.MF_JSON);
|
|
82
|
-
if (mfJson) {
|
|
83
|
-
const mfJsonContent = await import_utils.fs.readJSON((0, import_utils.normalizeToPosixPath)(import_path.default.join(filepath, mfJson)));
|
|
84
|
-
const { remoteName } = mfJsonContent;
|
|
85
|
-
const remoteLayoutId = (0, import_utils2.getRemoteLayoutId)(remoteName);
|
|
86
|
-
const writeFile = async (id, type, pathname) => {
|
|
87
|
-
const generatedFilePath = (0, import_utils.normalizeToPosixPath)(import_path.default.join(filepath, `${type}.tsx`));
|
|
88
|
-
const content = [
|
|
89
|
-
"// Do not edit this file. It is a auto generated.",
|
|
90
|
-
`// It will render ${remoteName}'s ${type}.`,
|
|
91
|
-
`// The ${type} pathname is: ${pathname}`,
|
|
92
|
-
`// The ${type} route id is: ${id}`
|
|
93
|
-
];
|
|
94
|
-
await import_utils.fs.writeFile(generatedFilePath, content.join("\n"));
|
|
95
|
-
};
|
|
96
|
-
if (remoteLayoutId) {
|
|
97
|
-
const pathname = calcPathName(filepath, rootDir, entry);
|
|
98
|
-
writeFile(remoteLayoutId, "layout", pathname);
|
|
99
|
-
remotePathMap[pathname] = remoteName;
|
|
100
|
-
}
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
await Promise.all(items.map(async (item) => {
|
|
104
|
-
await traverse((0, import_utils.normalizeToPosixPath)(import_path.default.join(filepath, item)), rootDir, entry);
|
|
105
|
-
}));
|
|
106
|
-
};
|
|
107
|
-
const traverseRoutes = async (dir, level = 1) => {
|
|
108
|
-
if (level > 3) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const isDirectory = (await import_utils.fs.stat(dir)).isDirectory();
|
|
112
|
-
if (!isDirectory) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const items = await import_utils.fs.readdir(dir);
|
|
116
|
-
if (items.find((i) => i === ROUTES)) {
|
|
117
|
-
const entry = import_path.default.relative(srcPath, dir);
|
|
118
|
-
entries.push(entry);
|
|
119
|
-
const rootDir = `${dir}/${ROUTES}`;
|
|
120
|
-
await traverse(rootDir, rootDir, entry);
|
|
121
|
-
} else {
|
|
122
|
-
await Promise.all(items.map(async (item) => {
|
|
123
|
-
await traverseRoutes(import_path.default.join(dir, item), level++);
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
await traverseRoutes(srcPath);
|
|
128
|
-
const normalizedEntries = entries.map((entry) => {
|
|
129
|
-
if (entry === "") {
|
|
130
|
-
return "main";
|
|
131
|
-
}
|
|
132
|
-
return entry;
|
|
133
|
-
});
|
|
134
|
-
return {
|
|
135
|
-
entries: normalizedEntries,
|
|
136
|
-
remotePathMap
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
-
0 && (module.exports = {
|
|
141
|
-
calcPathName,
|
|
142
|
-
generateRouteFile
|
|
143
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var patchMFConfig_exports = {};
|
|
30
|
-
__export(patchMFConfig_exports, {
|
|
31
|
-
patchMFConfig: () => patchMFConfig
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(patchMFConfig_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
|
-
var import_utils = require("@modern-js/utils");
|
|
36
|
-
var import_utils2 = require("../../runtime/utils");
|
|
37
|
-
var import_constant = require("../../constant");
|
|
38
|
-
var import_constant2 = require("../../constant");
|
|
39
|
-
var import_ast = require("./ast");
|
|
40
|
-
function generateExtraExposeFiles(options) {
|
|
41
|
-
const { internalDirectory, mfConfig, isServer, baseName, entries } = options;
|
|
42
|
-
const entryMap = {};
|
|
43
|
-
const outputDir = import_path.default.resolve(process.cwd(), "node_modules/.federation/data-loader");
|
|
44
|
-
import_utils.fs.ensureDirSync(outputDir);
|
|
45
|
-
const addSuffix = (fileName, ext = ".jsx") => {
|
|
46
|
-
if (!isServer) {
|
|
47
|
-
return `${fileName}${ext}`;
|
|
48
|
-
}
|
|
49
|
-
return `${fileName}.server${ext}`;
|
|
50
|
-
};
|
|
51
|
-
const generateEntryRoutes = (entry) => {
|
|
52
|
-
const outputEntryDir = import_path.default.resolve(outputDir, entry);
|
|
53
|
-
import_utils.fs.ensureDirSync(outputEntryDir);
|
|
54
|
-
const sourceDir = import_path.default.resolve(internalDirectory, entry);
|
|
55
|
-
const routesFilePath = import_path.default.resolve(sourceDir, addSuffix(import_constant2.MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME, ".js"));
|
|
56
|
-
const routesFileContent = import_utils.fs.readFileSync(routesFilePath, "utf-8");
|
|
57
|
-
const outputFullRoutesPath = import_path.default.resolve(outputEntryDir, addSuffix(import_constant2.MF_ROUTES));
|
|
58
|
-
(0, import_ast.generateRoutes)({
|
|
59
|
-
sourceCode: routesFileContent,
|
|
60
|
-
filePath: outputFullRoutesPath,
|
|
61
|
-
prefix: (0, import_utils2.transformName2Prefix)(mfConfig.name),
|
|
62
|
-
baseName
|
|
63
|
-
});
|
|
64
|
-
const routeServerLoaderPath = import_path.default.resolve(sourceDir, `${import_constant.MODERN_JS_ROUTE_SERVER_LOADER}.js`);
|
|
65
|
-
const outputRouteServerLoaderPath = import_path.default.resolve(outputEntryDir, `${import_constant.MODERN_JS_ROUTE_SERVER_LOADER}.js`);
|
|
66
|
-
if (isServer) {
|
|
67
|
-
const routeServerLoaderContent = import_utils.fs.readFileSync(routeServerLoaderPath, "utf-8");
|
|
68
|
-
(0, import_ast.generateRoutes)({
|
|
69
|
-
sourceCode: routeServerLoaderContent,
|
|
70
|
-
filePath: outputRouteServerLoaderPath,
|
|
71
|
-
prefix: (0, import_utils2.transformName2Prefix)(mfConfig.name),
|
|
72
|
-
baseName
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
entryMap[entry] = {
|
|
76
|
-
routesPath: outputFullRoutesPath,
|
|
77
|
-
routeServerLoaderPath: outputRouteServerLoaderPath
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
entries.forEach((entry) => {
|
|
81
|
-
generateEntryRoutes(entry);
|
|
82
|
-
});
|
|
83
|
-
return {
|
|
84
|
-
entryMap
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function addExpose(options) {
|
|
88
|
-
const { mfConfig, isServer } = options;
|
|
89
|
-
if (mfConfig.remotes && mfConfig.exposes) {
|
|
90
|
-
throw new Error(`dataLoader only support for pure provider/consumer !`);
|
|
91
|
-
}
|
|
92
|
-
const { entryMap } = generateExtraExposeFiles(options);
|
|
93
|
-
const addExposeByEntry = (entry, routesPath, routeServerLoaderPath) => {
|
|
94
|
-
if (!mfConfig.exposes) {
|
|
95
|
-
mfConfig.exposes = {};
|
|
96
|
-
}
|
|
97
|
-
const routesKey = `./${entry}/${import_constant2.MF_ROUTES}`;
|
|
98
|
-
if (!mfConfig.exposes[routesKey]) {
|
|
99
|
-
mfConfig.exposes[routesKey] = routesPath;
|
|
100
|
-
}
|
|
101
|
-
const routeServerLoaderKey = `./${entry}/${import_constant.MODERN_JS_ROUTE_SERVER_LOADER}`;
|
|
102
|
-
if (isServer && !mfConfig.exposes[routeServerLoaderKey]) {
|
|
103
|
-
mfConfig.exposes[routeServerLoaderKey] = routeServerLoaderPath;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
Object.keys(entryMap).forEach((entry) => {
|
|
107
|
-
const { routesPath, routeServerLoaderPath } = entryMap[entry];
|
|
108
|
-
addExposeByEntry(entry, routesPath, routeServerLoaderPath);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function addShared(options) {
|
|
112
|
-
const { metaName, mfConfig } = options;
|
|
113
|
-
const alias = `@${metaName}/runtime/router`;
|
|
114
|
-
if (!mfConfig.shared) {
|
|
115
|
-
mfConfig.shared = {
|
|
116
|
-
[alias]: {
|
|
117
|
-
singleton: true
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
} else {
|
|
121
|
-
if (!Array.isArray(mfConfig.shared)) {
|
|
122
|
-
mfConfig.shared[alias] = {
|
|
123
|
-
singleton: true
|
|
124
|
-
};
|
|
125
|
-
} else {
|
|
126
|
-
mfConfig.shared.push(alias);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function patchMFConfig(options) {
|
|
131
|
-
addShared(options);
|
|
132
|
-
addExpose(options);
|
|
133
|
-
}
|
|
134
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
-
0 && (module.exports = {
|
|
136
|
-
patchMFConfig
|
|
137
|
-
});
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var plugin_exports = {};
|
|
30
|
-
__export(plugin_exports, {
|
|
31
|
-
default: () => plugin_default,
|
|
32
|
-
generateRoutes: () => import_ast.generateRoutes,
|
|
33
|
-
generateSlimRoutes: () => import_ast.generateSlimRoutes,
|
|
34
|
-
moduleFederationDataLoaderPlugin: () => moduleFederationDataLoaderPlugin
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(plugin_exports);
|
|
37
|
-
var import_utils = require("../../runtime/utils");
|
|
38
|
-
var import_constant = require("../../constant");
|
|
39
|
-
var import_constant2 = require("../../constant");
|
|
40
|
-
var import_ast = require("./ast");
|
|
41
|
-
var import_generateRouteFile = require("./generateRouteFile");
|
|
42
|
-
var import_patchMFConfig = require("./patchMFConfig");
|
|
43
|
-
var import_path = __toESM(require("path"));
|
|
44
|
-
function _transformRuntimeOptions(buildOptions) {
|
|
45
|
-
const remotes = buildOptions.remotes || {};
|
|
46
|
-
const runtimeRemotes = Object.entries(remotes).map((remote) => {
|
|
47
|
-
const [alias, nameAndEntry] = remote;
|
|
48
|
-
const [name, entry] = nameAndEntry.split("@");
|
|
49
|
-
return {
|
|
50
|
-
name,
|
|
51
|
-
entry,
|
|
52
|
-
alias
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
name: buildOptions.name,
|
|
57
|
-
remotes: runtimeRemotes
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) => ({
|
|
61
|
-
name: "@modern-js/plugin-module-federation-data-loader",
|
|
62
|
-
pre: [
|
|
63
|
-
"@modern-js/plugin-module-federation-config"
|
|
64
|
-
],
|
|
65
|
-
post: [
|
|
66
|
-
"@modern-js/plugin-router",
|
|
67
|
-
"@modern-js/plugin-module-federation"
|
|
68
|
-
],
|
|
69
|
-
setup: async ({ useConfigContext, useAppContext }) => {
|
|
70
|
-
var _modernjsConfig_server, _modernjsConfig_server1, _modernjsConfig_server2, _modernjsConfig_server3, _modernjsConfig_server4;
|
|
71
|
-
if (!enable) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const {
|
|
75
|
-
baseName,
|
|
76
|
-
partialSSRRemotes = [],
|
|
77
|
-
// patchMFConfig,
|
|
78
|
-
metaName = import_constant2.META_NAME,
|
|
79
|
-
serverPlugin = "@module-federation/modern-js/data-loader-server",
|
|
80
|
-
transformRuntimeOptions
|
|
81
|
-
} = userConfig;
|
|
82
|
-
if (!baseName) {
|
|
83
|
-
throw new Error(`${import_constant.PLUGIN_IDENTIFIER} 'baseName' is required if you enable 'dataLoader'!`);
|
|
84
|
-
}
|
|
85
|
-
const modernjsConfig = useConfigContext();
|
|
86
|
-
const appContext = useAppContext();
|
|
87
|
-
const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
88
|
-
const name = internalOptions.csrConfig.name;
|
|
89
|
-
const internalDirectory = appContext.internalDirectory.replace(import_constant2.META_NAME, metaName || import_constant2.META_NAME);
|
|
90
|
-
const transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
91
|
-
const baseUrls = ((_modernjsConfig_server1 = modernjsConfig.server) === null || _modernjsConfig_server1 === void 0 ? void 0 : _modernjsConfig_server1.baseUrl) ? Array.isArray((_modernjsConfig_server2 = modernjsConfig.server) === null || _modernjsConfig_server2 === void 0 ? void 0 : _modernjsConfig_server2.baseUrl) ? (_modernjsConfig_server3 = modernjsConfig.server) === null || _modernjsConfig_server3 === void 0 ? void 0 : _modernjsConfig_server3.baseUrl : [
|
|
92
|
-
(_modernjsConfig_server4 = modernjsConfig.server) === null || _modernjsConfig_server4 === void 0 ? void 0 : _modernjsConfig_server4.baseUrl
|
|
93
|
-
] : [];
|
|
94
|
-
const entries = /* @__PURE__ */ new Set();
|
|
95
|
-
let remotePathMap = {};
|
|
96
|
-
const ssrByRouteIdsMap = {};
|
|
97
|
-
const serverPluginOptions = {
|
|
98
|
-
runtimeOptions: transformRuntimeFn(internalOptions.csrConfig),
|
|
99
|
-
partialSSRRemotes,
|
|
100
|
-
ssrByRouteIdsMap
|
|
101
|
-
};
|
|
102
|
-
const csrConfig = internalOptions.csrConfig;
|
|
103
|
-
if (typeof csrConfig.remotes === "object" && Object.keys(csrConfig.remotes).length) {
|
|
104
|
-
const { entries: scanEntries, remotePathMap: scanRemotePathMap } = await (0, import_generateRouteFile.generateRouteFile)({
|
|
105
|
-
appDirectory: appContext.appDirectory
|
|
106
|
-
});
|
|
107
|
-
scanEntries.forEach((e) => entries.add(e));
|
|
108
|
-
remotePathMap = scanRemotePathMap;
|
|
109
|
-
} else {
|
|
110
|
-
entries.add(import_constant.DEFAULT_ENTRY);
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
_internalRuntimePlugins: ({ entrypoint, plugins }) => {
|
|
114
|
-
plugins.push({
|
|
115
|
-
name: "ssrDataLoader",
|
|
116
|
-
path: "@module-federation/modern-js/data-loader",
|
|
117
|
-
config: {}
|
|
118
|
-
});
|
|
119
|
-
return {
|
|
120
|
-
entrypoint,
|
|
121
|
-
plugins
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
_internalServerPlugins({ plugins }) {
|
|
125
|
-
plugins.push({
|
|
126
|
-
name: serverPlugin,
|
|
127
|
-
options: serverPluginOptions
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
plugins
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
async modifyFileSystemRoutes(options) {
|
|
134
|
-
const { routes, entrypoint } = options;
|
|
135
|
-
const { entryName } = entrypoint;
|
|
136
|
-
const prefix = (0, import_utils.transformName2Prefix)(internalOptions.csrConfig.name);
|
|
137
|
-
const modifyRouteIds = (route, pathName) => {
|
|
138
|
-
const currentPathName = route.path ? import_path.default.join(pathName, route.path) : pathName;
|
|
139
|
-
if (route.id) {
|
|
140
|
-
var _route_children;
|
|
141
|
-
const originalId = route.id;
|
|
142
|
-
route.originalId = originalId;
|
|
143
|
-
const remoteName = remotePathMap[currentPathName];
|
|
144
|
-
if (remoteName) {
|
|
145
|
-
const remoteIdPrefix = (0, import_utils.transformName2Prefix)(remoteName);
|
|
146
|
-
const isLayout = Boolean(route.children);
|
|
147
|
-
const newId = `${remoteIdPrefix}${isLayout ? "layout" : "page"}`;
|
|
148
|
-
ssrByRouteIdsMap[originalId] = newId;
|
|
149
|
-
route.id = newId;
|
|
150
|
-
} else {
|
|
151
|
-
route.id = `${prefix}${route.id}`;
|
|
152
|
-
}
|
|
153
|
-
(_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.forEach((r) => {
|
|
154
|
-
modifyRouteIds(r, currentPathName);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
routes.forEach((route) => {
|
|
159
|
-
modifyRouteIds(route, entryName);
|
|
160
|
-
});
|
|
161
|
-
return options;
|
|
162
|
-
},
|
|
163
|
-
config: async () => {
|
|
164
|
-
return {
|
|
165
|
-
tools: {
|
|
166
|
-
// bundlerChain can not keep target order
|
|
167
|
-
rspack(config, { isServer }) {
|
|
168
|
-
(0, import_patchMFConfig.patchMFConfig)({
|
|
169
|
-
mfConfig: isServer ? internalOptions.ssrConfig : internalOptions.csrConfig,
|
|
170
|
-
baseName,
|
|
171
|
-
metaName,
|
|
172
|
-
isServer,
|
|
173
|
-
internalDirectory,
|
|
174
|
-
entries
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
// bundlerChain can not keep target order
|
|
178
|
-
webpack(config, { isServer }) {
|
|
179
|
-
(0, import_patchMFConfig.patchMFConfig)({
|
|
180
|
-
mfConfig: isServer ? internalOptions.ssrConfig : internalOptions.csrConfig,
|
|
181
|
-
baseName,
|
|
182
|
-
metaName,
|
|
183
|
-
isServer,
|
|
184
|
-
internalDirectory,
|
|
185
|
-
entries
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
source: {
|
|
190
|
-
define: {
|
|
191
|
-
MODERN_ROUTER_ID_PREFIX: JSON.stringify((0, import_utils.transformName2Prefix)(name))
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
var plugin_default = moduleFederationDataLoaderPlugin;
|
|
200
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
-
0 && (module.exports = {
|
|
202
|
-
generateRoutes,
|
|
203
|
-
generateSlimRoutes,
|
|
204
|
-
moduleFederationDataLoaderPlugin
|
|
205
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var node_exports = {};
|
|
30
|
-
__export(node_exports, {
|
|
31
|
-
default: () => node_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(node_exports);
|
|
34
|
-
var import_node_fetch = __toESM(require("node-fetch"));
|
|
35
|
-
const injectNodeFetchPlugin = () => ({
|
|
36
|
-
name: "inject-node-fetch-plugin",
|
|
37
|
-
beforeInit(args) {
|
|
38
|
-
if (!globalThis.fetch) {
|
|
39
|
-
globalThis.fetch = import_node_fetch.default;
|
|
40
|
-
}
|
|
41
|
-
return args;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
var node_default = injectNodeFetchPlugin;
|