@modern-js/plugin-garfish 2.0.0-beta.6 → 2.0.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/CHANGELOG.md +39 -0
- package/dist/js/modern/cli/index.js +6 -17
- package/dist/js/modern/cli/utils.js +7 -4
- package/dist/js/modern/runtime/plugin.js +1 -1
- package/dist/js/modern/runtime/utils/apps.js +138 -124
- package/dist/js/node/cli/index.js +6 -23
- package/dist/js/node/cli/utils.js +7 -4
- package/dist/js/node/runtime/plugin.js +1 -1
- package/dist/js/node/runtime/utils/apps.js +140 -125
- package/dist/js/treeshaking/cli/index.js +5 -10
- package/dist/js/treeshaking/cli/utils.js +2 -2
- package/dist/js/treeshaking/runtime/plugin.js +1 -1
- package/dist/js/treeshaking/runtime/utils/apps.js +229 -287
- package/dist/types/cli/index.d.ts +4 -7
- package/dist/types/runtime/loadable.d.ts +1 -2
- package/dist/types/runtime/useModuleApps.d.ts +9 -9
- package/dist/types/runtime/utils/apps.d.ts +1 -0
- package/package.json +11 -10
- package/type.d.ts +5 -0
- package/dist/js/modern/cli/types.js +0 -0
- package/dist/js/node/cli/types.js +0 -0
- package/dist/js/treeshaking/cli/types.js +0 -1
- package/dist/types/cli/types.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 6bc7763: fix(plugin-garfish): 修复 assetPrefix 用户配置被 plugin-garfish 覆盖问题,自定义入口未正确传递节点参数
|
|
12
|
+
fix(plugin-garfish): Fix the problem that the assetPrefix user configuration is overwritten by plugin-garfish, and the custom entry does not pass the node parameters correctly
|
|
13
|
+
- 81b54f9: fix: garfish wrapped app missing props
|
|
14
|
+
fix: garfish 包装过的 APP 缺少 props
|
|
15
|
+
- Updated dependencies [c9e800d39a]
|
|
16
|
+
- Updated dependencies [edd1cfb1af]
|
|
17
|
+
- Updated dependencies [6bda14ed71]
|
|
18
|
+
- Updated dependencies [dda38c9c3e]
|
|
19
|
+
- Updated dependencies [8b8e1bb571]
|
|
20
|
+
- Updated dependencies [ffb2ed4]
|
|
21
|
+
- Updated dependencies [bbe4c4ab64]
|
|
22
|
+
- @modern-js/runtime@2.0.0
|
|
23
|
+
- @modern-js/utils@2.0.0
|
|
24
|
+
|
|
25
|
+
## 2.0.0-beta.7
|
|
26
|
+
|
|
27
|
+
### Major Changes
|
|
28
|
+
|
|
29
|
+
- dda38c9c3e: chore: v2
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [c9e800d39a]
|
|
34
|
+
- Updated dependencies [edd1cfb1af]
|
|
35
|
+
- Updated dependencies [6bda14ed71]
|
|
36
|
+
- Updated dependencies [dda38c9c3e]
|
|
37
|
+
- Updated dependencies [8b8e1bb571]
|
|
38
|
+
- Updated dependencies [bbe4c4ab64]
|
|
39
|
+
- @modern-js/runtime@2.0.0-beta.7
|
|
40
|
+
- @modern-js/utils@2.0.0-beta.7
|
|
41
|
+
|
|
3
42
|
## 2.0.0-beta.6
|
|
4
43
|
|
|
5
44
|
### Major Changes
|
|
@@ -34,7 +34,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
34
34
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
import path from "path";
|
|
38
37
|
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from "@modern-js/utils";
|
|
39
38
|
import { logger } from "../util";
|
|
40
39
|
import {
|
|
@@ -44,7 +43,6 @@ import {
|
|
|
44
43
|
setRuntimeConfig,
|
|
45
44
|
generateAsyncEntry
|
|
46
45
|
} from "./utils";
|
|
47
|
-
import "./types";
|
|
48
46
|
const externals = { "react-dom": "react-dom", react: "react" };
|
|
49
47
|
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
50
48
|
if (microFrontend === true) {
|
|
@@ -61,13 +59,11 @@ function getDefaultMicroFrontedConfig(microFrontend) {
|
|
|
61
59
|
}
|
|
62
60
|
var cli_default = ({
|
|
63
61
|
pluginName = "@modern-js/plugin-garfish",
|
|
64
|
-
runtimePluginName = "@modern-js/runtime/plugins"
|
|
65
|
-
mfPackagePath = path.resolve(__dirname, "../../../../")
|
|
62
|
+
runtimePluginName = "@modern-js/runtime/plugins"
|
|
66
63
|
} = {}) => ({
|
|
67
64
|
name: "@modern-js/plugin-garfish",
|
|
68
65
|
setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
|
|
69
66
|
let pluginsExportsUtils;
|
|
70
|
-
let runtimeExportsUtils;
|
|
71
67
|
return {
|
|
72
68
|
validateSchema() {
|
|
73
69
|
return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
|
|
@@ -108,10 +104,6 @@ var cli_default = ({
|
|
|
108
104
|
config.internalDirectory,
|
|
109
105
|
"plugins"
|
|
110
106
|
);
|
|
111
|
-
runtimeExportsUtils = createRuntimeExportsUtils(
|
|
112
|
-
config.internalDirectory,
|
|
113
|
-
"index"
|
|
114
|
-
);
|
|
115
107
|
let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
|
|
116
108
|
if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
|
|
117
109
|
const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
|
|
@@ -128,7 +120,7 @@ var cli_default = ({
|
|
|
128
120
|
source: {
|
|
129
121
|
alias: {
|
|
130
122
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
131
|
-
"@modern-js/runtime/garfish":
|
|
123
|
+
"@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
|
|
132
124
|
}
|
|
133
125
|
},
|
|
134
126
|
tools: {
|
|
@@ -142,11 +134,11 @@ var cli_default = ({
|
|
|
142
134
|
env = process.env.NODE_ENV || "development",
|
|
143
135
|
CHAIN_ID
|
|
144
136
|
}) => {
|
|
145
|
-
var _a2, _b2, _c2, _d;
|
|
137
|
+
var _a2, _b2, _c2, _d, _e;
|
|
146
138
|
const resolveOptions = useResolvedConfigContext();
|
|
147
139
|
if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
|
|
148
140
|
chain.output.libraryTarget("umd");
|
|
149
|
-
if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 :
|
|
141
|
+
if (!((_b2 = useConfig.dev) == null ? void 0 : _b2.assetPrefix) && ((_c2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _c2.port) && env === "development") {
|
|
150
142
|
chain.output.publicPath(
|
|
151
143
|
`//localhost:${resolveOptions.server.port}/`
|
|
152
144
|
);
|
|
@@ -155,7 +147,7 @@ var cli_default = ({
|
|
|
155
147
|
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
|
|
156
148
|
}
|
|
157
149
|
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
|
|
158
|
-
(
|
|
150
|
+
(_d = resolveOptions.deploy) == null ? void 0 : _d.microFrontend
|
|
159
151
|
);
|
|
160
152
|
if (externalBasicLibrary) {
|
|
161
153
|
chain.externals(externals);
|
|
@@ -174,7 +166,7 @@ var cli_default = ({
|
|
|
174
166
|
output: resolveWebpackConfig.output,
|
|
175
167
|
externals: resolveWebpackConfig.externals,
|
|
176
168
|
env,
|
|
177
|
-
alias: (
|
|
169
|
+
alias: (_e = resolveWebpackConfig.resolve) == null ? void 0 : _e.alias,
|
|
178
170
|
plugins: resolveWebpackConfig.plugins
|
|
179
171
|
});
|
|
180
172
|
}
|
|
@@ -185,9 +177,6 @@ var cli_default = ({
|
|
|
185
177
|
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
|
|
186
178
|
logger("exportStatement", addExportStatement);
|
|
187
179
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
188
|
-
runtimeExportsUtils.addExport(
|
|
189
|
-
`export * from '${mfPackagePath}/runtime'`
|
|
190
|
-
);
|
|
191
180
|
},
|
|
192
181
|
modifyEntryImports({ entrypoint, imports }) {
|
|
193
182
|
const config = useResolvedConfigContext();
|
|
@@ -67,11 +67,11 @@ function generateRouterPlugin (basename,routerConfig) {
|
|
|
67
67
|
return router(routerConfig);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function generateAppWrapperAndRootDom ({ App, props, dom }) {
|
|
70
|
+
function generateAppWrapperAndRootDom ({ App, props: garfishProps, dom }) {
|
|
71
71
|
let AppWrapper = App;
|
|
72
|
-
if (
|
|
73
|
-
AppWrapper = function () {
|
|
74
|
-
return React.createElement(App, props);
|
|
72
|
+
if (garfishProps) {
|
|
73
|
+
AppWrapper = function (props) {
|
|
74
|
+
return React.createElement(App, { ...garfishProps, ...props });
|
|
75
75
|
};
|
|
76
76
|
AppWrapper = hoistNonReactStatics(AppWrapper, App);
|
|
77
77
|
}
|
|
@@ -88,6 +88,9 @@ const makeRenderFunction = (code) => {
|
|
|
88
88
|
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
|
|
89
89
|
`bootstrap(AppWrapper, mountNode, root`,
|
|
90
90
|
"bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
|
|
91
|
+
).replace(
|
|
92
|
+
`customBootstrap(AppWrapper)`,
|
|
93
|
+
"customBootstrap(AppWrapper, mountNode)"
|
|
91
94
|
);
|
|
92
95
|
};
|
|
93
96
|
function getRuntimeConfig(config) {
|
|
@@ -140,7 +140,7 @@ var plugin_default = (config) => ({
|
|
|
140
140
|
logger("GarfishProvider state", this.state);
|
|
141
141
|
return /* @__PURE__ */ jsx(GarfishProvider, {
|
|
142
142
|
value: this.state,
|
|
143
|
-
children: /* @__PURE__ */ jsx(App, __spreadValues(
|
|
143
|
+
children: /* @__PURE__ */ jsx(App, __spreadValues({}, this.props))
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -50,147 +50,160 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
53
|
-
import
|
|
54
|
-
import
|
|
53
|
+
import { useContext, useState, useEffect, useRef } from "react";
|
|
54
|
+
import { RuntimeReactContext } from "@modern-js/runtime";
|
|
55
55
|
import Garfish from "garfish";
|
|
56
|
-
import { withRouter } from "@modern-js/plugin-router-v5/runtime";
|
|
57
56
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
58
57
|
import { Loadable } from "../loadable";
|
|
58
|
+
function pathJoin(...args) {
|
|
59
|
+
const res = args.reduce((res2, path) => {
|
|
60
|
+
let nPath = path;
|
|
61
|
+
if (!nPath || typeof nPath !== "string") {
|
|
62
|
+
return res2;
|
|
63
|
+
}
|
|
64
|
+
if (nPath[0] !== "/") {
|
|
65
|
+
nPath = `/${nPath}`;
|
|
66
|
+
}
|
|
67
|
+
const lastIndex = nPath.length - 1;
|
|
68
|
+
if (nPath[lastIndex] === "/") {
|
|
69
|
+
nPath = nPath.substring(0, lastIndex);
|
|
70
|
+
}
|
|
71
|
+
return res2 + nPath;
|
|
72
|
+
}, "");
|
|
73
|
+
return res || "/";
|
|
74
|
+
}
|
|
59
75
|
function getAppInstance(options, appInfo, manifest) {
|
|
60
76
|
let locationHref = "";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
function MicroApp(props) {
|
|
78
|
+
var _a, _b, _c, _d, _e, _f;
|
|
79
|
+
const appRef = useRef(null);
|
|
80
|
+
const domId = generateSubAppContainerKey(appInfo);
|
|
81
|
+
const [SubModuleComponent, setSubModuleComponent] = useState();
|
|
82
|
+
const context = useContext(RuntimeReactContext);
|
|
83
|
+
const match = (_b = (_a = context == null ? void 0 : context.router) == null ? void 0 : _a.useRouteMatch) == null ? void 0 : _b.call(_a);
|
|
84
|
+
const matchs = (_d = (_c = context == null ? void 0 : context.router) == null ? void 0 : _c.useMatches) == null ? void 0 : _d.call(_c);
|
|
85
|
+
const location = (_f = (_e = context == null ? void 0 : context.router) == null ? void 0 : _e.useLocation) == null ? void 0 : _f.call(_e);
|
|
86
|
+
let basename = (options == null ? void 0 : options.basename) || "/";
|
|
87
|
+
if (matchs && matchs.length > 0) {
|
|
88
|
+
basename = pathJoin(basename, matchs[matchs.length - 1].pathname || "/");
|
|
89
|
+
} else if (match) {
|
|
90
|
+
basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
|
|
71
91
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
logger("MicroApp customer destroy", props);
|
|
110
|
-
return destroy == null ? void 0 : destroy.apply(provider, props);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (location && locationHref !== location.pathname && !Garfish.running) {
|
|
94
|
+
locationHref = location.pathname;
|
|
95
|
+
const popStateEvent = new PopStateEvent("popstate");
|
|
96
|
+
popStateEvent.garfish = true;
|
|
97
|
+
dispatchEvent(popStateEvent);
|
|
98
|
+
logger(`MicroApp Garfish.loadApp popstate`);
|
|
99
|
+
}
|
|
100
|
+
}, [location]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const _a2 = props, { setLoadingState } = _a2, userProps = __objRest(_a2, ["setLoadingState"]);
|
|
103
|
+
const loadAppOptions = __spreadProps(__spreadValues({}, appInfo), {
|
|
104
|
+
insulationVariable: [
|
|
105
|
+
...appInfo.insulationVariable || [],
|
|
106
|
+
"_SERVER_DATA"
|
|
107
|
+
],
|
|
108
|
+
domGetter: `#${domId}`,
|
|
109
|
+
basename,
|
|
110
|
+
cache: true,
|
|
111
|
+
props: __spreadValues(__spreadValues({}, appInfo.props), userProps),
|
|
112
|
+
customLoader: (provider) => {
|
|
113
|
+
const {
|
|
114
|
+
render,
|
|
115
|
+
destroy,
|
|
116
|
+
SubModuleComponent: SubModuleComponent2,
|
|
117
|
+
jupiter_submodule_app_key
|
|
118
|
+
} = provider;
|
|
119
|
+
const componetRenderMode = (manifest == null ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
|
|
120
|
+
return {
|
|
121
|
+
mount: (...props2) => {
|
|
122
|
+
if (componetRenderMode) {
|
|
123
|
+
setSubModuleComponent(SubModuleComponent2);
|
|
124
|
+
return void 0;
|
|
125
|
+
} else {
|
|
126
|
+
logger("MicroApp customer render", props2);
|
|
127
|
+
return render == null ? void 0 : render.apply(provider, props2);
|
|
111
128
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
},
|
|
130
|
+
unmount(...props2) {
|
|
131
|
+
if (componetRenderMode) {
|
|
132
|
+
return void 0;
|
|
133
|
+
}
|
|
134
|
+
logger("MicroApp customer destroy", props2);
|
|
135
|
+
return destroy == null ? void 0 : destroy.apply(provider, props2);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
setLoadingState({
|
|
141
|
+
isLoading: true,
|
|
142
|
+
error: null
|
|
143
|
+
});
|
|
144
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}"`, {
|
|
145
|
+
loadAppOptions
|
|
146
|
+
});
|
|
147
|
+
function renderApp() {
|
|
148
|
+
return __async(this, null, function* () {
|
|
149
|
+
try {
|
|
150
|
+
const appInstance = yield Garfish.loadApp(
|
|
151
|
+
appInfo.name,
|
|
152
|
+
loadAppOptions
|
|
127
153
|
);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
logger(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
|
|
137
|
-
appInfo: appInstance.appInfo,
|
|
138
|
-
appInstance
|
|
154
|
+
if (!appInstance) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`MicroApp Garfish.loadApp "${appInfo.name}" result is null`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
appRef.current = appInstance;
|
|
160
|
+
setLoadingState({
|
|
161
|
+
isLoading: false
|
|
139
162
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
163
|
+
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
164
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
|
|
165
|
+
appInfo: appInstance.appInfo,
|
|
166
|
+
appInstance
|
|
167
|
+
});
|
|
168
|
+
yield appInstance == null ? void 0 : appInstance.show();
|
|
169
|
+
} else {
|
|
170
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
|
|
171
|
+
appInfo: appInstance.appInfo,
|
|
172
|
+
appInstance
|
|
173
|
+
});
|
|
174
|
+
yield appInstance == null ? void 0 : appInstance.mount();
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
setLoadingState({
|
|
178
|
+
isLoading: true,
|
|
179
|
+
error
|
|
145
180
|
});
|
|
146
|
-
yield appInstance == null ? void 0 : appInstance.mount();
|
|
147
181
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
} catch (error) {
|
|
157
|
-
setLoadingState({
|
|
158
|
-
isLoading: true,
|
|
159
|
-
error
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
componentWillUnmount() {
|
|
165
|
-
return __async(this, null, function* () {
|
|
166
|
-
var _a;
|
|
167
|
-
const { appInstance } = this.state;
|
|
168
|
-
(_a = this.unregisterHistoryListener) == null ? void 0 : _a.call(this);
|
|
169
|
-
if (appInstance) {
|
|
170
|
-
const { appInfo: appInfo2 } = appInstance;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
renderApp();
|
|
185
|
+
return () => {
|
|
186
|
+
var _a3, _b2;
|
|
187
|
+
if (appRef.current) {
|
|
188
|
+
const { appInfo: appInfo2 } = appRef.current;
|
|
171
189
|
if (appInfo2.cache) {
|
|
172
190
|
logger(`MicroApp Garfish.loadApp "${appInfo2.name}" hide`);
|
|
173
|
-
|
|
191
|
+
(_a3 = appRef.current) == null ? void 0 : _a3.hide();
|
|
174
192
|
} else {
|
|
175
193
|
logger(`MicroApp Garfish.loadApp "${appInfo2.name}" unmount`);
|
|
176
|
-
|
|
194
|
+
(_b2 = appRef.current) == null ? void 0 : _b2.unmount();
|
|
177
195
|
}
|
|
178
196
|
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
children: /* @__PURE__ */ jsx(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
});
|
|
189
|
-
}
|
|
197
|
+
};
|
|
198
|
+
}, []);
|
|
199
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
200
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
201
|
+
id: domId,
|
|
202
|
+
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
203
|
+
})
|
|
204
|
+
});
|
|
190
205
|
}
|
|
191
|
-
return Loadable(
|
|
192
|
-
manifest == null ? void 0 : manifest.loadable
|
|
193
|
-
);
|
|
206
|
+
return Loadable(MicroApp)(manifest == null ? void 0 : manifest.loadable);
|
|
194
207
|
}
|
|
195
208
|
function generateApps(options, manifest) {
|
|
196
209
|
var _a;
|
|
@@ -203,5 +216,6 @@ function generateApps(options, manifest) {
|
|
|
203
216
|
return { apps, appInfoList: options.apps || [] };
|
|
204
217
|
}
|
|
205
218
|
export {
|
|
206
|
-
generateApps
|
|
219
|
+
generateApps,
|
|
220
|
+
pathJoin
|
|
207
221
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -30,10 +28,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
30
28
|
}
|
|
31
29
|
return to;
|
|
32
30
|
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
32
|
var __async = (__this, __arguments, generator) => {
|
|
39
33
|
return new Promise((resolve, reject) => {
|
|
@@ -62,11 +56,9 @@ __export(cli_exports, {
|
|
|
62
56
|
getDefaultMicroFrontedConfig: () => getDefaultMicroFrontedConfig
|
|
63
57
|
});
|
|
64
58
|
module.exports = __toCommonJS(cli_exports);
|
|
65
|
-
var import_path = __toESM(require("path"));
|
|
66
59
|
var import_utils = require("@modern-js/utils");
|
|
67
60
|
var import_util = require("../util");
|
|
68
61
|
var import_utils2 = require("./utils");
|
|
69
|
-
var import_types = require("./types");
|
|
70
62
|
const externals = { "react-dom": "react-dom", react: "react" };
|
|
71
63
|
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
72
64
|
if (microFrontend === true) {
|
|
@@ -83,13 +75,11 @@ function getDefaultMicroFrontedConfig(microFrontend) {
|
|
|
83
75
|
}
|
|
84
76
|
var cli_default = ({
|
|
85
77
|
pluginName = "@modern-js/plugin-garfish",
|
|
86
|
-
runtimePluginName = "@modern-js/runtime/plugins"
|
|
87
|
-
mfPackagePath = import_path.default.resolve(__dirname, "../../../../")
|
|
78
|
+
runtimePluginName = "@modern-js/runtime/plugins"
|
|
88
79
|
} = {}) => ({
|
|
89
80
|
name: "@modern-js/plugin-garfish",
|
|
90
81
|
setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
|
|
91
82
|
let pluginsExportsUtils;
|
|
92
|
-
let runtimeExportsUtils;
|
|
93
83
|
return {
|
|
94
84
|
validateSchema() {
|
|
95
85
|
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
|
|
@@ -130,10 +120,6 @@ var cli_default = ({
|
|
|
130
120
|
config.internalDirectory,
|
|
131
121
|
"plugins"
|
|
132
122
|
);
|
|
133
|
-
runtimeExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
|
|
134
|
-
config.internalDirectory,
|
|
135
|
-
"index"
|
|
136
|
-
);
|
|
137
123
|
let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
|
|
138
124
|
if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
|
|
139
125
|
const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
|
|
@@ -150,7 +136,7 @@ var cli_default = ({
|
|
|
150
136
|
source: {
|
|
151
137
|
alias: {
|
|
152
138
|
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
153
|
-
"@modern-js/runtime/garfish":
|
|
139
|
+
"@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
|
|
154
140
|
}
|
|
155
141
|
},
|
|
156
142
|
tools: {
|
|
@@ -164,11 +150,11 @@ var cli_default = ({
|
|
|
164
150
|
env = process.env.NODE_ENV || "development",
|
|
165
151
|
CHAIN_ID
|
|
166
152
|
}) => {
|
|
167
|
-
var _a2, _b2, _c2, _d;
|
|
153
|
+
var _a2, _b2, _c2, _d, _e;
|
|
168
154
|
const resolveOptions = useResolvedConfigContext();
|
|
169
155
|
if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
|
|
170
156
|
chain.output.libraryTarget("umd");
|
|
171
|
-
if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 :
|
|
157
|
+
if (!((_b2 = useConfig.dev) == null ? void 0 : _b2.assetPrefix) && ((_c2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _c2.port) && env === "development") {
|
|
172
158
|
chain.output.publicPath(
|
|
173
159
|
`//localhost:${resolveOptions.server.port}/`
|
|
174
160
|
);
|
|
@@ -177,7 +163,7 @@ var cli_default = ({
|
|
|
177
163
|
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
|
|
178
164
|
}
|
|
179
165
|
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
|
|
180
|
-
(
|
|
166
|
+
(_d = resolveOptions.deploy) == null ? void 0 : _d.microFrontend
|
|
181
167
|
);
|
|
182
168
|
if (externalBasicLibrary) {
|
|
183
169
|
chain.externals(externals);
|
|
@@ -196,7 +182,7 @@ var cli_default = ({
|
|
|
196
182
|
output: resolveWebpackConfig.output,
|
|
197
183
|
externals: resolveWebpackConfig.externals,
|
|
198
184
|
env,
|
|
199
|
-
alias: (
|
|
185
|
+
alias: (_e = resolveWebpackConfig.resolve) == null ? void 0 : _e.alias,
|
|
200
186
|
plugins: resolveWebpackConfig.plugins
|
|
201
187
|
});
|
|
202
188
|
}
|
|
@@ -207,9 +193,6 @@ var cli_default = ({
|
|
|
207
193
|
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
|
|
208
194
|
(0, import_util.logger)("exportStatement", addExportStatement);
|
|
209
195
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
210
|
-
runtimeExportsUtils.addExport(
|
|
211
|
-
`export * from '${mfPackagePath}/runtime'`
|
|
212
|
-
);
|
|
213
196
|
},
|
|
214
197
|
modifyEntryImports({ entrypoint, imports }) {
|
|
215
198
|
const config = useResolvedConfigContext();
|
|
@@ -93,11 +93,11 @@ function generateRouterPlugin (basename,routerConfig) {
|
|
|
93
93
|
return router(routerConfig);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
function generateAppWrapperAndRootDom ({ App, props, dom }) {
|
|
96
|
+
function generateAppWrapperAndRootDom ({ App, props: garfishProps, dom }) {
|
|
97
97
|
let AppWrapper = App;
|
|
98
|
-
if (
|
|
99
|
-
AppWrapper = function () {
|
|
100
|
-
return React.createElement(App, props);
|
|
98
|
+
if (garfishProps) {
|
|
99
|
+
AppWrapper = function (props) {
|
|
100
|
+
return React.createElement(App, { ...garfishProps, ...props });
|
|
101
101
|
};
|
|
102
102
|
AppWrapper = hoistNonReactStatics(AppWrapper, App);
|
|
103
103
|
}
|
|
@@ -114,6 +114,9 @@ const makeRenderFunction = (code) => {
|
|
|
114
114
|
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
|
|
115
115
|
`bootstrap(AppWrapper, mountNode, root`,
|
|
116
116
|
"bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
|
|
117
|
+
).replace(
|
|
118
|
+
`customBootstrap(AppWrapper)`,
|
|
119
|
+
"customBootstrap(AppWrapper, mountNode)"
|
|
117
120
|
);
|
|
118
121
|
};
|
|
119
122
|
function getRuntimeConfig(config) {
|
|
@@ -166,7 +166,7 @@ var plugin_default = (config) => ({
|
|
|
166
166
|
(0, import_util.logger)("GarfishProvider state", this.state);
|
|
167
167
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Context.GarfishProvider, {
|
|
168
168
|
value: this.state,
|
|
169
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues(
|
|
169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadValues({}, this.props))
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
}
|