@modern-js/plugin-garfish 2.35.0 → 2.36.0
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/cli/index.js +75 -76
- package/dist/cjs/cli/utils.js +39 -32
- package/dist/cjs/deps/index.js +35 -9
- package/dist/cjs/index.js +37 -10
- package/dist/cjs/runtime/index.js +43 -28
- package/dist/cjs/runtime/loadable.js +37 -20
- package/dist/cjs/runtime/plugin.js +68 -54
- package/dist/cjs/runtime/useModuleApps.js +43 -24
- package/dist/cjs/runtime/utils/Context.js +37 -18
- package/dist/cjs/runtime/utils/MApp.js +69 -52
- package/dist/cjs/runtime/utils/apps.js +72 -61
- package/dist/cjs/runtime/utils/setExternal.js +40 -18
- package/dist/cjs/util.js +40 -23
- package/dist/esm/cli/index.js +50 -53
- package/dist/esm/cli/utils.js +20 -13
- package/dist/esm/deps/index.js +4 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/runtime/index.js +10 -3
- package/dist/esm/runtime/loadable.js +10 -7
- package/dist/esm/runtime/plugin.js +19 -18
- package/dist/esm/runtime/useModuleApps.js +8 -4
- package/dist/esm/runtime/utils/Context.js +4 -1
- package/dist/esm/runtime/utils/MApp.js +17 -23
- package/dist/esm/runtime/utils/apps.js +25 -26
- package/dist/esm/runtime/utils/setExternal.js +4 -1
- package/dist/esm/util.js +9 -5
- package/dist/esm-node/cli/index.js +36 -38
- package/dist/esm-node/cli/utils.js +20 -13
- package/dist/esm-node/deps/index.js +4 -1
- package/dist/esm-node/index.js +4 -1
- package/dist/esm-node/runtime/index.js +10 -3
- package/dist/esm-node/runtime/loadable.js +6 -3
- package/dist/esm-node/runtime/plugin.js +10 -10
- package/dist/esm-node/runtime/useModuleApps.js +6 -2
- package/dist/esm-node/runtime/utils/Context.js +4 -1
- package/dist/esm-node/runtime/utils/MApp.js +13 -19
- package/dist/esm-node/runtime/utils/apps.js +18 -21
- package/dist/esm-node/runtime/utils/setExternal.js +4 -1
- package/dist/esm-node/util.js +9 -5
- package/package.json +10 -10
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return pathJoin;
|
|
15
|
-
},
|
|
16
|
-
generateApps: function() {
|
|
17
|
-
return generateApps;
|
|
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 });
|
|
18
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 apps_exports = {};
|
|
30
|
+
__export(apps_exports, {
|
|
31
|
+
generateApps: () => generateApps,
|
|
32
|
+
pathJoin: () => pathJoin
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const _loadable = require("../loadable");
|
|
34
|
+
module.exports = __toCommonJS(apps_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_runtime = require("@modern-js/runtime");
|
|
38
|
+
var import_garfish = __toESM(require("garfish"));
|
|
39
|
+
var import_util = require("../../util");
|
|
40
|
+
var import_loadable = require("../loadable");
|
|
28
41
|
function pathJoin(...args) {
|
|
29
42
|
const res = args.reduce((res2, path) => {
|
|
30
43
|
let nPath = path;
|
|
@@ -43,18 +56,17 @@ function pathJoin(...args) {
|
|
|
43
56
|
return res || "/";
|
|
44
57
|
}
|
|
45
58
|
function getAppInstance(options, appInfo, manifest) {
|
|
46
|
-
var _manifest;
|
|
47
59
|
let locationHref = "";
|
|
48
60
|
function MicroApp(props) {
|
|
49
|
-
var _context_router_useRouteMatch, _context_router,
|
|
50
|
-
const appRef = (0,
|
|
51
|
-
const domId = (0,
|
|
52
|
-
const [SubModuleComponent, setSubModuleComponent] = (0,
|
|
53
|
-
const context = (0,
|
|
54
|
-
const match =
|
|
55
|
-
const matchs =
|
|
56
|
-
const location =
|
|
57
|
-
let basename = (
|
|
61
|
+
var _context_router_useRouteMatch, _context_router, _context_router_useMatches, _context_router1, _context_router_useLocation, _context_router2;
|
|
62
|
+
const appRef = (0, import_react.useRef)(null);
|
|
63
|
+
const domId = (0, import_util.generateSubAppContainerKey)(appInfo);
|
|
64
|
+
const [SubModuleComponent, setSubModuleComponent] = (0, import_react.useState)();
|
|
65
|
+
const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
|
|
66
|
+
const match = context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : (_context_router_useRouteMatch = _context_router.useRouteMatch) === null || _context_router_useRouteMatch === void 0 ? void 0 : _context_router_useRouteMatch.call(_context_router);
|
|
67
|
+
const matchs = context === null || context === void 0 ? void 0 : (_context_router1 = context.router) === null || _context_router1 === void 0 ? void 0 : (_context_router_useMatches = _context_router1.useMatches) === null || _context_router_useMatches === void 0 ? void 0 : _context_router_useMatches.call(_context_router1);
|
|
68
|
+
const location = context === null || context === void 0 ? void 0 : (_context_router2 = context.router) === null || _context_router2 === void 0 ? void 0 : (_context_router_useLocation = _context_router2.useLocation) === null || _context_router_useLocation === void 0 ? void 0 : _context_router_useLocation.call(_context_router2);
|
|
69
|
+
let basename = (options === null || options === void 0 ? void 0 : options.basename) || "/";
|
|
58
70
|
if (matchs && matchs.length > 0) {
|
|
59
71
|
const matchItem = {
|
|
60
72
|
...matchs[matchs.length - 1]
|
|
@@ -64,21 +76,20 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
64
76
|
}
|
|
65
77
|
basename = pathJoin(basename, matchItem.pathname || "/");
|
|
66
78
|
} else if (match) {
|
|
67
|
-
|
|
68
|
-
basename = pathJoin(basename, ((_match = match) === null || _match === void 0 ? void 0 : _match.path) || "/");
|
|
79
|
+
basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
|
|
69
80
|
}
|
|
70
|
-
(0,
|
|
71
|
-
if (location && locationHref !== location.pathname && !
|
|
81
|
+
(0, import_react.useEffect)(() => {
|
|
82
|
+
if (location && locationHref !== location.pathname && !import_garfish.default.running) {
|
|
72
83
|
locationHref = location.pathname;
|
|
73
84
|
const popStateEvent = new PopStateEvent("popstate");
|
|
74
85
|
popStateEvent.garfish = true;
|
|
75
86
|
dispatchEvent(popStateEvent);
|
|
76
|
-
(0,
|
|
87
|
+
(0, import_util.logger)(`MicroApp Garfish.loadApp popstate`);
|
|
77
88
|
}
|
|
78
89
|
}, [
|
|
79
90
|
location
|
|
80
91
|
]);
|
|
81
|
-
(0,
|
|
92
|
+
(0, import_react.useEffect)(() => {
|
|
82
93
|
const { setLoadingState, ...userProps } = props;
|
|
83
94
|
const loadAppOptions = {
|
|
84
95
|
...appInfo,
|
|
@@ -94,27 +105,24 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
94
105
|
...userProps
|
|
95
106
|
},
|
|
96
107
|
customLoader: (provider) => {
|
|
97
|
-
var _manifest2;
|
|
98
108
|
const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
|
|
99
|
-
const componetRenderMode = (
|
|
109
|
+
const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
|
|
100
110
|
return {
|
|
101
111
|
mount: (...props2) => {
|
|
102
112
|
if (componetRenderMode) {
|
|
103
113
|
setSubModuleComponent(SubModuleComponent2);
|
|
104
114
|
return void 0;
|
|
105
115
|
} else {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, props2);
|
|
116
|
+
(0, import_util.logger)("MicroApp customer render", props2);
|
|
117
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props2);
|
|
109
118
|
}
|
|
110
119
|
},
|
|
111
120
|
unmount(...props2) {
|
|
112
|
-
var _destroy;
|
|
113
121
|
if (componetRenderMode) {
|
|
114
122
|
return void 0;
|
|
115
123
|
}
|
|
116
|
-
(0,
|
|
117
|
-
return
|
|
124
|
+
(0, import_util.logger)("MicroApp customer destroy", props2);
|
|
125
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props2);
|
|
118
126
|
}
|
|
119
127
|
};
|
|
120
128
|
}
|
|
@@ -123,12 +131,12 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
123
131
|
isLoading: true,
|
|
124
132
|
error: null
|
|
125
133
|
});
|
|
126
|
-
(0,
|
|
134
|
+
(0, import_util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}"`, {
|
|
127
135
|
loadAppOptions
|
|
128
136
|
});
|
|
129
137
|
async function renderApp() {
|
|
130
138
|
try {
|
|
131
|
-
const appInstance = await
|
|
139
|
+
const appInstance = await import_garfish.default.loadApp(appInfo.name, loadAppOptions);
|
|
132
140
|
if (!appInstance) {
|
|
133
141
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
134
142
|
}
|
|
@@ -137,19 +145,17 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
137
145
|
isLoading: false
|
|
138
146
|
});
|
|
139
147
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
140
|
-
|
|
141
|
-
(0, _util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
|
|
148
|
+
(0, import_util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
|
|
142
149
|
appInfo: appInstance.appInfo,
|
|
143
150
|
appInstance
|
|
144
151
|
});
|
|
145
|
-
await (
|
|
152
|
+
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.show());
|
|
146
153
|
} else {
|
|
147
|
-
|
|
148
|
-
(0, _util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
|
|
154
|
+
(0, import_util.logger)(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
|
|
149
155
|
appInfo: appInstance.appInfo,
|
|
150
156
|
appInstance
|
|
151
157
|
});
|
|
152
|
-
await (
|
|
158
|
+
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
153
159
|
}
|
|
154
160
|
} catch (error) {
|
|
155
161
|
setLoadingState({
|
|
@@ -164,24 +170,24 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
164
170
|
const { appInfo: appInfo2 } = appRef.current;
|
|
165
171
|
if (appInfo2.cache) {
|
|
166
172
|
var _appRef_current;
|
|
167
|
-
(0,
|
|
173
|
+
(0, import_util.logger)(`MicroApp Garfish.loadApp "${appInfo2.name}" hide`);
|
|
168
174
|
(_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.hide();
|
|
169
175
|
} else {
|
|
170
176
|
var _appRef_current1;
|
|
171
|
-
(0,
|
|
177
|
+
(0, import_util.logger)(`MicroApp Garfish.loadApp "${appInfo2.name}" unmount`);
|
|
172
178
|
(_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.unmount();
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
};
|
|
176
182
|
}, []);
|
|
177
|
-
return /* @__PURE__ */ (0,
|
|
178
|
-
children: /* @__PURE__ */ (0,
|
|
183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
184
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
179
185
|
id: domId,
|
|
180
|
-
children: SubModuleComponent && /* @__PURE__ */ (0,
|
|
186
|
+
children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {})
|
|
181
187
|
})
|
|
182
188
|
});
|
|
183
189
|
}
|
|
184
|
-
return (0,
|
|
190
|
+
return (0, import_loadable.Loadable)(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
185
191
|
}
|
|
186
192
|
function generateApps(options, manifest) {
|
|
187
193
|
var _options_apps;
|
|
@@ -196,3 +202,8 @@ function generateApps(options, manifest) {
|
|
|
196
202
|
appInfoList: options.apps || []
|
|
197
203
|
};
|
|
198
204
|
}
|
|
205
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
206
|
+
0 && (module.exports = {
|
|
207
|
+
generateApps,
|
|
208
|
+
pathJoin
|
|
209
|
+
});
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 });
|
|
9
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 setExternal_exports = {};
|
|
30
|
+
__export(setExternal_exports, {
|
|
31
|
+
default: () => setExternal_default
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
(0,
|
|
18
|
-
react:
|
|
19
|
-
"react-dom":
|
|
33
|
+
module.exports = __toCommonJS(setExternal_exports);
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
36
|
+
var import_garfish = __toESM(require("garfish"));
|
|
37
|
+
var import_util = require("../../util");
|
|
38
|
+
var setExternal_default = () => {
|
|
39
|
+
(0, import_util.logger)("setExternal ", {
|
|
40
|
+
react: import_react.default,
|
|
41
|
+
"react-dom": import_react_dom.default
|
|
20
42
|
});
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
import_garfish.default.setExternal("react", import_react.default);
|
|
44
|
+
import_garfish.default.setExternal("react-dom", import_react_dom.default);
|
|
23
45
|
};
|
package/dist/cjs/util.js
CHANGED
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return logger;
|
|
15
|
-
},
|
|
16
|
-
SUBMODULE_APP_COMPONENT_KEY: function() {
|
|
17
|
-
return SUBMODULE_APP_COMPONENT_KEY;
|
|
18
|
-
},
|
|
19
|
-
generateSubAppContainerKey: function() {
|
|
20
|
-
return generateSubAppContainerKey;
|
|
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 });
|
|
21
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 util_exports = {};
|
|
30
|
+
__export(util_exports, {
|
|
31
|
+
SUBMODULE_APP_COMPONENT_KEY: () => SUBMODULE_APP_COMPONENT_KEY,
|
|
32
|
+
generateSubAppContainerKey: () => generateSubAppContainerKey,
|
|
33
|
+
logger: () => logger
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const logger = (0,
|
|
35
|
+
module.exports = __toCommonJS(util_exports);
|
|
36
|
+
var import_debug = __toESM(require("debug"));
|
|
37
|
+
const logger = (0, import_debug.default)("modern-js:plugin-garfish");
|
|
26
38
|
const SUBMODULE_APP_COMPONENT_KEY = "SubModuleComponent";
|
|
27
39
|
function generateSubAppContainerKey(moduleInfo) {
|
|
28
|
-
|
|
29
|
-
return moduleInfo ? `modern_sub_app_container_${decodeURIComponent((_moduleInfo = moduleInfo) === null || _moduleInfo === void 0 ? void 0 : _moduleInfo.name)}` : "modern_sub_app_container";
|
|
40
|
+
return moduleInfo ? `modern_sub_app_container_${decodeURIComponent(moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.name)}` : "modern_sub_app_container";
|
|
30
41
|
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
SUBMODULE_APP_COMPONENT_KEY,
|
|
45
|
+
generateSubAppContainerKey,
|
|
46
|
+
logger
|
|
47
|
+
});
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
4
|
import { createRuntimeExportsUtils } from "@modern-js/utils";
|
|
6
5
|
import { logger } from "../util";
|
|
7
6
|
import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig, generateAsyncEntry } from "./utils";
|
|
8
|
-
|
|
7
|
+
var externals = {
|
|
9
8
|
"react-dom": "react-dom",
|
|
10
9
|
react: "react"
|
|
11
10
|
};
|
|
12
|
-
|
|
11
|
+
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
13
12
|
if (microFrontend === true) {
|
|
14
13
|
return {
|
|
15
14
|
enableHtmlEntry: true,
|
|
@@ -22,7 +21,7 @@ export function getDefaultMicroFrontedConfig(microFrontend) {
|
|
|
22
21
|
externalBasicLibrary: false
|
|
23
22
|
}, microFrontend);
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
var garfishPlugin = function() {
|
|
26
25
|
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_pluginName = _ref.pluginName, pluginName = _ref_pluginName === void 0 ? "@modern-js/plugin-garfish" : _ref_pluginName, _ref_runtimePluginName = _ref.runtimePluginName, runtimePluginName = _ref_runtimePluginName === void 0 ? "@modern-js/runtime/plugins" : _ref_runtimePluginName;
|
|
27
26
|
return {
|
|
28
27
|
name: "@modern-js/plugin-garfish",
|
|
@@ -62,7 +61,7 @@ export var garfishPlugin = function() {
|
|
|
62
61
|
},
|
|
63
62
|
resolvedConfig: function() {
|
|
64
63
|
var _ref2 = _async_to_generator(function(config) {
|
|
65
|
-
var resolved, _getRuntimeConfig, masterApp, router, nConfig, _useConfig_server,
|
|
64
|
+
var resolved, _getRuntimeConfig, masterApp, router, nConfig, _useConfig_server, _router_historyOptions, useConfig, baseUrl;
|
|
66
65
|
return _ts_generator(this, function(_state) {
|
|
67
66
|
resolved = config.resolved;
|
|
68
67
|
_getRuntimeConfig = getRuntimeConfig(resolved), masterApp = _getRuntimeConfig.masterApp, router = _getRuntimeConfig.router;
|
|
@@ -72,12 +71,12 @@ export var garfishPlugin = function() {
|
|
|
72
71
|
if (masterApp) {
|
|
73
72
|
;
|
|
74
73
|
useConfig = useConfigContext();
|
|
75
|
-
baseUrl =
|
|
74
|
+
baseUrl = useConfig === null || useConfig === void 0 ? void 0 : (_useConfig_server = useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
|
|
76
75
|
if (Array.isArray(baseUrl)) {
|
|
77
76
|
throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
|
|
78
77
|
}
|
|
79
78
|
setRuntimeConfig(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? _object_spread({}, masterApp) : {}, {
|
|
80
|
-
basename: baseUrl || (
|
|
79
|
+
basename: baseUrl || (router === null || router === void 0 ? void 0 : (_router_historyOptions = router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || (router === null || router === void 0 ? void 0 : router.basename) || "/"
|
|
81
80
|
}));
|
|
82
81
|
}
|
|
83
82
|
logger("resolvedConfig", {
|
|
@@ -112,7 +111,7 @@ export var garfishPlugin = function() {
|
|
|
112
111
|
}
|
|
113
112
|
return {
|
|
114
113
|
output: {
|
|
115
|
-
disableCssExtract
|
|
114
|
+
disableCssExtract
|
|
116
115
|
},
|
|
117
116
|
source: {
|
|
118
117
|
alias: {
|
|
@@ -126,42 +125,34 @@ export var garfishPlugin = function() {
|
|
|
126
125
|
"Access-Control-Allow-Origin": "*"
|
|
127
126
|
}
|
|
128
127
|
},
|
|
129
|
-
webpackChain: function(chain, param2) {
|
|
130
|
-
var webpack = param2.webpack, CHAIN_ID = param2.CHAIN_ID;
|
|
131
|
-
if (webpack.BannerPlugin) {
|
|
132
|
-
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [
|
|
133
|
-
{
|
|
134
|
-
banner: "Micro front-end"
|
|
135
|
-
}
|
|
136
|
-
]);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
128
|
rspack: function(config3) {
|
|
140
|
-
var _resolveOptions_deploy
|
|
129
|
+
var _resolveOptions_deploy;
|
|
141
130
|
var _config;
|
|
142
131
|
var _builtins;
|
|
143
132
|
(_builtins = (_config = config3).builtins) !== null && _builtins !== void 0 ? _builtins : _config.builtins = {};
|
|
144
133
|
var resolveOptions = useResolvedConfigContext();
|
|
145
|
-
if ((
|
|
134
|
+
if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config3.externalsType) {
|
|
146
135
|
config3.externalsType = "commonjs";
|
|
147
136
|
}
|
|
148
|
-
var banner = config3.builtins.banner || [];
|
|
149
|
-
config3.builtins.banner = _to_consumable_array(Array.isArray(banner) ? banner : [
|
|
150
|
-
banner
|
|
151
|
-
]).concat([
|
|
152
|
-
{
|
|
153
|
-
banner: "Micro front-end"
|
|
154
|
-
}
|
|
155
|
-
]);
|
|
156
137
|
},
|
|
157
138
|
bundlerChain: function(chain, param2) {
|
|
158
|
-
var env = param2.env, CHAIN_ID = param2.CHAIN_ID;
|
|
159
|
-
var _resolveOptions_deploy,
|
|
139
|
+
var env = param2.env, CHAIN_ID = param2.CHAIN_ID, bundler = param2.bundler;
|
|
140
|
+
var _resolveOptions_deploy, _resolveConfig_resolve;
|
|
141
|
+
if (bundler.BannerPlugin) {
|
|
142
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(bundler.BannerPlugin, [
|
|
143
|
+
{
|
|
144
|
+
banner: "Micro front-end"
|
|
145
|
+
}
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
160
148
|
var resolveOptions = useResolvedConfigContext();
|
|
161
|
-
if (
|
|
162
|
-
var _useConfig_dev, _resolveOptions_server,
|
|
149
|
+
if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
|
|
150
|
+
var _resolveOptions_dev, _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
|
|
163
151
|
chain.output.libraryTarget("umd");
|
|
164
|
-
|
|
152
|
+
var DEFAULT_ASSET_PREFIX = "/";
|
|
153
|
+
var resolvedAssetPrefix = (_resolveOptions_dev = resolveOptions.dev) === null || _resolveOptions_dev === void 0 ? void 0 : _resolveOptions_dev.assetPrefix;
|
|
154
|
+
var isUsingDefaultAssetPrefix = !((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && (!resolvedAssetPrefix || resolvedAssetPrefix === DEFAULT_ASSET_PREFIX);
|
|
155
|
+
if (isUsingDefaultAssetPrefix && (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_server = resolveOptions.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
|
|
165
156
|
chain.output.publicPath("//localhost:".concat(resolveOptions.server.port, "/"));
|
|
166
157
|
}
|
|
167
158
|
var _getDefaultMicroFrontedConfig = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend), enableHtmlEntry2 = _getDefaultMicroFrontedConfig.enableHtmlEntry, externalBasicLibrary = _getDefaultMicroFrontedConfig.externalBasicLibrary;
|
|
@@ -185,7 +176,7 @@ export var garfishPlugin = function() {
|
|
|
185
176
|
logger("bundlerConfig", {
|
|
186
177
|
output: resolveConfig.output,
|
|
187
178
|
externals: resolveConfig.externals,
|
|
188
|
-
env
|
|
179
|
+
env,
|
|
189
180
|
alias: (_resolveConfig_resolve = resolveConfig.resolve) === null || _resolveConfig_resolve === void 0 ? void 0 : _resolveConfig_resolve.alias,
|
|
190
181
|
plugins: resolveConfig.plugins
|
|
191
182
|
});
|
|
@@ -247,8 +238,8 @@ export var garfishPlugin = function() {
|
|
|
247
238
|
]
|
|
248
239
|
});
|
|
249
240
|
return {
|
|
250
|
-
imports
|
|
251
|
-
entrypoint
|
|
241
|
+
imports,
|
|
242
|
+
entrypoint
|
|
252
243
|
};
|
|
253
244
|
},
|
|
254
245
|
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param2) {
|
|
@@ -264,63 +255,69 @@ export var garfishPlugin = function() {
|
|
|
264
255
|
});
|
|
265
256
|
}
|
|
266
257
|
return {
|
|
267
|
-
entrypoint
|
|
268
|
-
plugins
|
|
258
|
+
entrypoint,
|
|
259
|
+
plugins
|
|
269
260
|
};
|
|
270
261
|
},
|
|
271
262
|
modifyEntryRenderFunction: function modifyEntryRenderFunction(param2) {
|
|
272
263
|
var entrypoint = param2.entrypoint, code = param2.code;
|
|
273
|
-
var _config_deploy
|
|
264
|
+
var _config_deploy;
|
|
274
265
|
var config = useResolvedConfigContext();
|
|
275
|
-
if (!(
|
|
266
|
+
if (!(config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
|
|
276
267
|
return {
|
|
277
|
-
entrypoint
|
|
278
|
-
code
|
|
268
|
+
entrypoint,
|
|
269
|
+
code
|
|
279
270
|
};
|
|
280
271
|
}
|
|
281
272
|
var nCode = makeRenderFunction(code);
|
|
282
273
|
logger("makeRenderFunction", nCode);
|
|
283
274
|
return {
|
|
284
|
-
entrypoint
|
|
275
|
+
entrypoint,
|
|
285
276
|
code: nCode
|
|
286
277
|
};
|
|
287
278
|
},
|
|
288
279
|
modifyAsyncEntry: function modifyAsyncEntry(param2) {
|
|
289
280
|
var entrypoint = param2.entrypoint, code = param2.code;
|
|
290
|
-
var _config_deploy,
|
|
281
|
+
var _config_deploy, _config_source;
|
|
291
282
|
var config = useResolvedConfigContext();
|
|
292
283
|
var finalCode = code;
|
|
293
|
-
if ((
|
|
284
|
+
if ((config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && (config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
|
|
294
285
|
finalCode = generateAsyncEntry(code);
|
|
295
286
|
return {
|
|
296
|
-
entrypoint
|
|
287
|
+
entrypoint,
|
|
297
288
|
code: "".concat(finalCode)
|
|
298
289
|
};
|
|
299
290
|
}
|
|
300
291
|
return {
|
|
301
|
-
entrypoint
|
|
292
|
+
entrypoint,
|
|
302
293
|
code: finalCode
|
|
303
294
|
};
|
|
304
295
|
},
|
|
305
296
|
modifyEntryExport: function modifyEntryExport(param2) {
|
|
306
297
|
var entrypoint = param2.entrypoint, exportStatement = param2.exportStatement;
|
|
307
|
-
var _config_deploy
|
|
298
|
+
var _config_deploy;
|
|
308
299
|
var config = useResolvedConfigContext();
|
|
309
|
-
if (
|
|
300
|
+
if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
|
|
310
301
|
var exportStatementCode = makeProvider();
|
|
311
302
|
logger("exportStatement", exportStatementCode);
|
|
312
303
|
return {
|
|
313
|
-
entrypoint
|
|
304
|
+
entrypoint,
|
|
314
305
|
exportStatement: exportStatementCode
|
|
315
306
|
};
|
|
316
307
|
}
|
|
317
308
|
return {
|
|
318
|
-
entrypoint
|
|
319
|
-
exportStatement
|
|
309
|
+
entrypoint,
|
|
310
|
+
exportStatement
|
|
320
311
|
};
|
|
321
312
|
}
|
|
322
313
|
};
|
|
323
314
|
}
|
|
324
315
|
};
|
|
325
316
|
};
|
|
326
|
-
|
|
317
|
+
var cli_default = garfishPlugin;
|
|
318
|
+
export {
|
|
319
|
+
cli_default as default,
|
|
320
|
+
externals,
|
|
321
|
+
garfishPlugin,
|
|
322
|
+
getDefaultMicroFrontedConfig
|
|
323
|
+
};
|