@modern-js/plugin-garfish 2.0.0-beta.3 → 2.0.0-beta.5
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 +67 -0
- package/dist/js/modern/cli/index.js +167 -157
- package/dist/js/modern/cli/types.js +0 -0
- package/dist/js/modern/cli/utils.js +31 -23
- package/dist/js/modern/global.d.js +0 -0
- package/dist/js/modern/index.js +5 -2
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/runtime/global.d.js +0 -0
- package/dist/js/modern/runtime/index.js +12 -4
- package/dist/js/modern/runtime/loadable.js +74 -56
- package/dist/js/modern/runtime/plugin.js +114 -79
- package/dist/js/modern/runtime/useModuleApps.js +40 -26
- package/dist/js/modern/runtime/utils/Context.js +6 -3
- package/dist/js/modern/runtime/utils/MApp.js +76 -72
- package/dist/js/modern/runtime/utils/apps.js +181 -132
- package/dist/js/modern/runtime/utils/setExternal.js +11 -11
- package/dist/js/modern/util.js +11 -9
- package/dist/js/node/cli/index.js +191 -169
- package/dist/js/node/cli/types.js +0 -0
- package/dist/js/node/cli/utils.js +53 -30
- package/dist/js/node/global.d.js +0 -0
- package/dist/js/node/index.js +31 -24
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/runtime/global.d.js +0 -0
- package/dist/js/node/runtime/index.js +42 -43
- package/dist/js/node/runtime/loadable.js +97 -61
- package/dist/js/node/runtime/plugin.js +147 -95
- package/dist/js/node/runtime/useModuleApps.js +67 -34
- package/dist/js/node/runtime/utils/Context.js +35 -10
- package/dist/js/node/runtime/utils/MApp.js +109 -84
- package/dist/js/node/runtime/utils/apps.js +210 -135
- package/dist/js/node/runtime/utils/setExternal.js +37 -18
- package/dist/js/node/util.js +40 -19
- package/dist/js/treeshaking/cli/index.js +403 -284
- package/dist/js/treeshaking/cli/types.js +1 -0
- package/dist/js/treeshaking/cli/utils.js +28 -31
- package/dist/js/treeshaking/global.d.js +1 -0
- package/dist/js/treeshaking/index.js +3 -2
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/runtime/global.d.js +1 -0
- package/dist/js/treeshaking/runtime/index.js +5 -4
- package/dist/js/treeshaking/runtime/loadable.js +230 -109
- package/dist/js/treeshaking/runtime/plugin.js +469 -168
- package/dist/js/treeshaking/runtime/useModuleApps.js +55 -31
- package/dist/js/treeshaking/runtime/utils/Context.js +3 -3
- package/dist/js/treeshaking/runtime/utils/MApp.js +348 -180
- package/dist/js/treeshaking/runtime/utils/apps.js +472 -224
- package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
- package/dist/js/treeshaking/util.js +7 -9
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/types.d.ts +6 -0
- package/dist/types/runtime/index.d.ts +1 -1
- package/dist/types/runtime/loadable.d.ts +1 -2
- package/dist/types/runtime/plugin.d.ts +2 -0
- package/dist/types/runtime/utils/apps.d.ts +1 -0
- package/dist/types/runtime/utils/setExternal.d.ts +1 -0
- package/package.json +25 -20
- package/type.d.ts +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 6604f1b: feat: support router basename
|
|
12
|
+
feat: router 插件支持设置 basename
|
|
13
|
+
- 21d2ddb59c: feat: support async export provider for module federation
|
|
14
|
+
支持模块联邦场景异步导出 provider
|
|
15
|
+
- cce8ecee2d: fix: handle some `TODO` & `FIXME`, change some tests
|
|
16
|
+
fix: 处理一些 `TODO` 和 `FIXME`, 修改了一些 tests
|
|
17
|
+
- 2344eb26ed: fix: loadApp when dom is mount
|
|
18
|
+
修复 dom 未渲染时挂载子应用行为
|
|
19
|
+
- Updated dependencies [2344eb26ed]
|
|
20
|
+
- Updated dependencies [a11fcf8b50]
|
|
21
|
+
- Updated dependencies [a931594]
|
|
22
|
+
- Updated dependencies [e7ce063]
|
|
23
|
+
- Updated dependencies [b18fa8f3ed]
|
|
24
|
+
- Updated dependencies [7879e8f]
|
|
25
|
+
- Updated dependencies [50d4675]
|
|
26
|
+
- Updated dependencies [c9e800d39a]
|
|
27
|
+
- Updated dependencies [6604f1b]
|
|
28
|
+
- Updated dependencies [6aca875]
|
|
29
|
+
- Updated dependencies [fda836f]
|
|
30
|
+
- Updated dependencies [d6bc321]
|
|
31
|
+
- Updated dependencies [3e57f2bd58]
|
|
32
|
+
- Updated dependencies [2e6031955e]
|
|
33
|
+
- Updated dependencies [c5798d2]
|
|
34
|
+
- Updated dependencies [fbf5eed5aa]
|
|
35
|
+
- Updated dependencies [a2509bfbdb]
|
|
36
|
+
- Updated dependencies [a7c6883]
|
|
37
|
+
- Updated dependencies [425e57092d]
|
|
38
|
+
- Updated dependencies [e4357f1856]
|
|
39
|
+
- Updated dependencies [7b7d12c]
|
|
40
|
+
- Updated dependencies [4369648ae2]
|
|
41
|
+
- Updated dependencies [92f0eade39]
|
|
42
|
+
- Updated dependencies [92c0994468]
|
|
43
|
+
- Updated dependencies [2cc2eb3]
|
|
44
|
+
- Updated dependencies [edd1cfb1af]
|
|
45
|
+
- Updated dependencies [cc971eabfc]
|
|
46
|
+
- Updated dependencies [5b9049f2e9]
|
|
47
|
+
- Updated dependencies [6bda14ed71]
|
|
48
|
+
- Updated dependencies [92004d1906]
|
|
49
|
+
- Updated dependencies [b8bbe036c7]
|
|
50
|
+
- Updated dependencies [40ed5874c6]
|
|
51
|
+
- Updated dependencies [60d5378632]
|
|
52
|
+
- Updated dependencies [d5a31df781]
|
|
53
|
+
- Updated dependencies [dda38c9c3e]
|
|
54
|
+
- Updated dependencies [8b8e1bb571]
|
|
55
|
+
- Updated dependencies [3bbea92b2a]
|
|
56
|
+
- Updated dependencies [9144c21]
|
|
57
|
+
- Updated dependencies [b710adb843]
|
|
58
|
+
- Updated dependencies [18aaf42249]
|
|
59
|
+
- Updated dependencies [34702d5]
|
|
60
|
+
- Updated dependencies [fcace5b5b9]
|
|
61
|
+
- Updated dependencies [ea7cf06]
|
|
62
|
+
- Updated dependencies [bbe4c4a]
|
|
63
|
+
- Updated dependencies [e4558a0]
|
|
64
|
+
- Updated dependencies [abf3421a75]
|
|
65
|
+
- Updated dependencies [543be9558e]
|
|
66
|
+
- Updated dependencies [14b712da84]
|
|
67
|
+
- @modern-js/runtime@2.0.0-beta.4
|
|
68
|
+
- @modern-js/utils@2.0.0-beta.4
|
|
69
|
+
|
|
3
70
|
## 2.0.0-beta.3
|
|
4
71
|
|
|
5
72
|
### Major Changes
|
|
@@ -1,61 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
11
36
|
};
|
|
12
|
-
|
|
37
|
+
import path from "path";
|
|
38
|
+
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from "@modern-js/utils";
|
|
39
|
+
import { logger } from "../util";
|
|
40
|
+
import {
|
|
41
|
+
getRuntimeConfig,
|
|
42
|
+
makeProvider,
|
|
43
|
+
makeRenderFunction,
|
|
44
|
+
setRuntimeConfig,
|
|
45
|
+
generateAsyncEntry
|
|
46
|
+
} from "./utils";
|
|
47
|
+
import "./types";
|
|
48
|
+
const externals = { "react-dom": "react-dom", react: "react" };
|
|
49
|
+
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
13
50
|
if (microFrontend === true) {
|
|
14
51
|
return {
|
|
15
52
|
enableHtmlEntry: true,
|
|
16
53
|
externalBasicLibrary: false,
|
|
17
|
-
moduleApp:
|
|
54
|
+
moduleApp: ""
|
|
18
55
|
};
|
|
19
56
|
}
|
|
20
|
-
return
|
|
57
|
+
return __spreadValues({
|
|
21
58
|
enableHtmlEntry: true,
|
|
22
59
|
externalBasicLibrary: false
|
|
23
60
|
}, microFrontend);
|
|
24
61
|
}
|
|
25
|
-
|
|
26
|
-
pluginName
|
|
27
|
-
runtimePluginName
|
|
28
|
-
mfPackagePath
|
|
62
|
+
var cli_default = ({
|
|
63
|
+
pluginName = "@modern-js/plugin-garfish",
|
|
64
|
+
runtimePluginName = "@modern-js/runtime/plugins",
|
|
65
|
+
mfPackagePath = path.resolve(__dirname, "../../../../")
|
|
29
66
|
} = {}) => ({
|
|
30
|
-
name:
|
|
31
|
-
setup: ({
|
|
32
|
-
useAppContext,
|
|
33
|
-
useResolvedConfigContext,
|
|
34
|
-
useConfigContext
|
|
35
|
-
}) => {
|
|
67
|
+
name: "@modern-js/plugin-garfish",
|
|
68
|
+
setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
|
|
36
69
|
let pluginsExportsUtils;
|
|
37
70
|
let runtimeExportsUtils;
|
|
38
71
|
return {
|
|
39
72
|
validateSchema() {
|
|
40
|
-
return PLUGIN_SCHEMAS[
|
|
73
|
+
return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
|
|
41
74
|
},
|
|
42
|
-
resolvedConfig:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} =
|
|
46
|
-
const {
|
|
47
|
-
masterApp,
|
|
48
|
-
router
|
|
49
|
-
} = getRuntimeConfig(resolved);
|
|
75
|
+
resolvedConfig: (config) => __async(void 0, null, function* () {
|
|
76
|
+
var _a;
|
|
77
|
+
const { resolved } = config;
|
|
78
|
+
const { masterApp, router } = getRuntimeConfig(resolved);
|
|
50
79
|
const nConfig = {
|
|
51
|
-
resolved:
|
|
80
|
+
resolved: __spreadValues({}, resolved)
|
|
52
81
|
};
|
|
53
82
|
if (masterApp) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
setRuntimeConfig(
|
|
84
|
+
nConfig.resolved,
|
|
85
|
+
"masterApp",
|
|
86
|
+
Object.assign(
|
|
87
|
+
typeof masterApp === "object" ? __spreadValues({}, masterApp) : {},
|
|
88
|
+
{
|
|
89
|
+
basename: ((_a = router == null ? void 0 : router.historyOptions) == null ? void 0 : _a.basename) || (router == null ? void 0 : router.basename) || "/"
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
);
|
|
59
93
|
}
|
|
60
94
|
logger(`resolvedConfig`, {
|
|
61
95
|
output: nConfig.resolved.output,
|
|
@@ -64,25 +98,25 @@ export default (({
|
|
|
64
98
|
server: nConfig.resolved.server
|
|
65
99
|
});
|
|
66
100
|
return nConfig;
|
|
67
|
-
},
|
|
101
|
+
}),
|
|
68
102
|
config() {
|
|
69
|
-
var
|
|
70
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
103
|
+
var _a, _b, _c;
|
|
71
104
|
const useConfig = useConfigContext();
|
|
72
|
-
logger(
|
|
73
|
-
|
|
74
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
105
|
+
logger("useConfig", useConfig);
|
|
75
106
|
const config = useAppContext();
|
|
76
|
-
pluginsExportsUtils = createRuntimeExportsUtils(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
107
|
+
pluginsExportsUtils = createRuntimeExportsUtils(
|
|
108
|
+
config.internalDirectory,
|
|
109
|
+
"plugins"
|
|
110
|
+
);
|
|
111
|
+
runtimeExportsUtils = createRuntimeExportsUtils(
|
|
112
|
+
config.internalDirectory,
|
|
113
|
+
"index"
|
|
114
|
+
);
|
|
115
|
+
let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
|
|
116
|
+
if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
|
|
117
|
+
const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
|
|
118
|
+
(_c = useConfig.deploy) == null ? void 0 : _c.microFrontend
|
|
119
|
+
);
|
|
86
120
|
if (!enableHtmlEntry) {
|
|
87
121
|
disableCssExtract = true;
|
|
88
122
|
}
|
|
@@ -93,61 +127,54 @@ export default (({
|
|
|
93
127
|
},
|
|
94
128
|
source: {
|
|
95
129
|
alias: {
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
131
|
+
"@modern-js/runtime/garfish": mfPackagePath
|
|
98
132
|
}
|
|
99
133
|
},
|
|
100
134
|
tools: {
|
|
101
135
|
devServer: {
|
|
102
136
|
headers: {
|
|
103
|
-
|
|
137
|
+
"Access-Control-Allow-Origin": "*"
|
|
104
138
|
}
|
|
105
139
|
},
|
|
106
140
|
webpackChain: (chain, {
|
|
107
141
|
webpack,
|
|
108
|
-
env
|
|
142
|
+
env = process.env.NODE_ENV || "development",
|
|
109
143
|
CHAIN_ID
|
|
110
144
|
}) => {
|
|
111
|
-
var
|
|
112
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
145
|
+
var _a2, _b2, _c2, _d;
|
|
113
146
|
const resolveOptions = useResolvedConfigContext();
|
|
114
|
-
if (resolveOptions
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
147
|
+
if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
|
|
148
|
+
chain.output.libraryTarget("umd");
|
|
149
|
+
if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
|
|
150
|
+
chain.output.publicPath(
|
|
151
|
+
`//localhost:${resolveOptions.server.port}/`
|
|
152
|
+
);
|
|
119
153
|
}
|
|
120
|
-
|
|
121
|
-
// add comments avoid sourcemap abnormal
|
|
122
154
|
if (webpack.BannerPlugin) {
|
|
123
|
-
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
|
|
124
|
-
banner: 'Micro front-end'
|
|
125
|
-
}]);
|
|
155
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
|
|
126
156
|
}
|
|
127
|
-
const {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
|
|
131
|
-
// external
|
|
157
|
+
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
|
|
158
|
+
(_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
|
|
159
|
+
);
|
|
132
160
|
if (externalBasicLibrary) {
|
|
133
161
|
chain.externals(externals);
|
|
134
162
|
}
|
|
135
|
-
// use html mode
|
|
136
163
|
if (!enableHtmlEntry) {
|
|
137
|
-
chain.output.filename(
|
|
164
|
+
chain.output.filename("index.js");
|
|
138
165
|
chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
|
|
139
166
|
chain.optimization.runtimeChunk(false);
|
|
140
167
|
chain.optimization.splitChunks({
|
|
141
|
-
chunks:
|
|
168
|
+
chunks: "async"
|
|
142
169
|
});
|
|
143
170
|
}
|
|
144
171
|
}
|
|
145
172
|
const resolveWebpackConfig = chain.toConfig();
|
|
146
|
-
logger(
|
|
173
|
+
logger("webpackConfig", {
|
|
147
174
|
output: resolveWebpackConfig.output,
|
|
148
175
|
externals: resolveWebpackConfig.externals,
|
|
149
|
-
env
|
|
150
|
-
alias: (
|
|
176
|
+
env,
|
|
177
|
+
alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
|
|
151
178
|
plugins: resolveWebpackConfig.plugins
|
|
152
179
|
});
|
|
153
180
|
}
|
|
@@ -155,104 +182,86 @@ export default (({
|
|
|
155
182
|
};
|
|
156
183
|
},
|
|
157
184
|
addRuntimeExports() {
|
|
158
|
-
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${
|
|
159
|
-
logger(
|
|
185
|
+
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
|
|
186
|
+
logger("exportStatement", addExportStatement);
|
|
160
187
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
161
|
-
runtimeExportsUtils.addExport(
|
|
188
|
+
runtimeExportsUtils.addExport(
|
|
189
|
+
`export * from '${mfPackagePath}/runtime'`
|
|
190
|
+
);
|
|
162
191
|
},
|
|
163
|
-
modifyEntryImports({
|
|
164
|
-
entrypoint,
|
|
165
|
-
imports
|
|
166
|
-
}) {
|
|
167
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
192
|
+
modifyEntryImports({ entrypoint, imports }) {
|
|
168
193
|
const config = useResolvedConfigContext();
|
|
169
|
-
const {
|
|
170
|
-
masterApp
|
|
171
|
-
} = getRuntimeConfig(config);
|
|
194
|
+
const { masterApp } = getRuntimeConfig(config);
|
|
172
195
|
if (masterApp) {
|
|
173
196
|
imports.push({
|
|
174
|
-
value:
|
|
175
|
-
specifiers: [
|
|
176
|
-
|
|
177
|
-
|
|
197
|
+
value: runtimePluginName,
|
|
198
|
+
specifiers: [
|
|
199
|
+
{
|
|
200
|
+
imported: "garfish"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
178
203
|
});
|
|
179
204
|
imports.push({
|
|
180
|
-
value:
|
|
181
|
-
specifiers: [
|
|
182
|
-
|
|
183
|
-
|
|
205
|
+
value: runtimePluginName,
|
|
206
|
+
specifiers: [
|
|
207
|
+
{
|
|
208
|
+
imported: "masterApp"
|
|
209
|
+
}
|
|
210
|
+
]
|
|
184
211
|
});
|
|
185
212
|
}
|
|
186
213
|
imports.push({
|
|
187
|
-
value:
|
|
188
|
-
specifiers: [
|
|
189
|
-
|
|
190
|
-
|
|
214
|
+
value: runtimePluginName,
|
|
215
|
+
specifiers: [
|
|
216
|
+
{
|
|
217
|
+
imported: "hoistNonReactStatics"
|
|
218
|
+
}
|
|
219
|
+
]
|
|
191
220
|
});
|
|
192
221
|
imports.push({
|
|
193
|
-
value:
|
|
194
|
-
specifiers: [
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
value: "react-dom",
|
|
223
|
+
specifiers: [
|
|
224
|
+
{
|
|
225
|
+
imported: "unmountComponentAtNode"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
imported: "createPortal"
|
|
229
|
+
}
|
|
230
|
+
]
|
|
199
231
|
});
|
|
200
|
-
return {
|
|
201
|
-
imports,
|
|
202
|
-
entrypoint
|
|
203
|
-
};
|
|
232
|
+
return { imports, entrypoint };
|
|
204
233
|
},
|
|
205
|
-
modifyEntryRuntimePlugins({
|
|
206
|
-
entrypoint,
|
|
207
|
-
plugins
|
|
208
|
-
}) {
|
|
209
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
234
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
210
235
|
const config = useResolvedConfigContext();
|
|
211
|
-
const {
|
|
212
|
-
masterApp
|
|
213
|
-
} = getRuntimeConfig(config);
|
|
236
|
+
const { masterApp } = getRuntimeConfig(config);
|
|
214
237
|
if (masterApp) {
|
|
215
|
-
logger(
|
|
238
|
+
logger("garfishPlugin options", masterApp);
|
|
216
239
|
plugins.push({
|
|
217
|
-
name:
|
|
218
|
-
args:
|
|
240
|
+
name: "garfish",
|
|
241
|
+
args: "masterApp",
|
|
219
242
|
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
220
243
|
});
|
|
221
244
|
}
|
|
222
|
-
return {
|
|
223
|
-
entrypoint,
|
|
224
|
-
plugins
|
|
225
|
-
};
|
|
245
|
+
return { entrypoint, plugins };
|
|
226
246
|
},
|
|
227
|
-
modifyEntryRenderFunction({
|
|
228
|
-
|
|
229
|
-
code
|
|
230
|
-
}) {
|
|
231
|
-
var _config$deploy;
|
|
232
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
247
|
+
modifyEntryRenderFunction({ entrypoint, code }) {
|
|
248
|
+
var _a;
|
|
233
249
|
const config = useResolvedConfigContext();
|
|
234
|
-
if (!(config
|
|
235
|
-
return {
|
|
236
|
-
entrypoint,
|
|
237
|
-
code
|
|
238
|
-
};
|
|
250
|
+
if (!((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend)) {
|
|
251
|
+
return { entrypoint, code };
|
|
239
252
|
}
|
|
240
253
|
const nCode = makeRenderFunction(code);
|
|
241
|
-
logger(
|
|
254
|
+
logger("makeRenderFunction", nCode);
|
|
242
255
|
return {
|
|
243
256
|
entrypoint,
|
|
244
257
|
code: nCode
|
|
245
258
|
};
|
|
246
259
|
},
|
|
247
|
-
modifyAsyncEntry({
|
|
248
|
-
|
|
249
|
-
code
|
|
250
|
-
}) {
|
|
251
|
-
var _config$deploy2, _config$source;
|
|
252
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
260
|
+
modifyAsyncEntry({ entrypoint, code }) {
|
|
261
|
+
var _a, _b;
|
|
253
262
|
const config = useResolvedConfigContext();
|
|
254
263
|
let finalCode = code;
|
|
255
|
-
if (config
|
|
264
|
+
if (((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) && ((_b = config == null ? void 0 : config.source) == null ? void 0 : _b.enableAsyncEntry)) {
|
|
256
265
|
finalCode = generateAsyncEntry(code);
|
|
257
266
|
return {
|
|
258
267
|
entrypoint,
|
|
@@ -264,16 +273,12 @@ export default (({
|
|
|
264
273
|
code: finalCode
|
|
265
274
|
};
|
|
266
275
|
},
|
|
267
|
-
modifyEntryExport({
|
|
268
|
-
|
|
269
|
-
exportStatement
|
|
270
|
-
}) {
|
|
271
|
-
var _config$deploy3;
|
|
272
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
276
|
+
modifyEntryExport({ entrypoint, exportStatement }) {
|
|
277
|
+
var _a;
|
|
273
278
|
const config = useResolvedConfigContext();
|
|
274
|
-
if (config
|
|
279
|
+
if ((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) {
|
|
275
280
|
const exportStatementCode = makeProvider();
|
|
276
|
-
logger(
|
|
281
|
+
logger("exportStatement", exportStatementCode);
|
|
277
282
|
return {
|
|
278
283
|
entrypoint,
|
|
279
284
|
exportStatement: exportStatementCode
|
|
@@ -286,4 +291,9 @@ export default (({
|
|
|
286
291
|
}
|
|
287
292
|
};
|
|
288
293
|
}
|
|
289
|
-
})
|
|
294
|
+
});
|
|
295
|
+
export {
|
|
296
|
+
cli_default as default,
|
|
297
|
+
externals,
|
|
298
|
+
getDefaultMicroFrontedConfig
|
|
299
|
+
};
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const makeProvider = () => `
|
|
2
2
|
export const provider = function ({basename, dom}) {
|
|
3
3
|
return {
|
|
4
4
|
render({basename, dom, props, appName}) {
|
|
@@ -79,40 +79,41 @@ function generateAppWrapperAndRootDom ({ App, props, dom }) {
|
|
|
79
79
|
return { AppWrapper, mountNode }
|
|
80
80
|
}
|
|
81
81
|
`;
|
|
82
|
-
|
|
82
|
+
const makeRenderFunction = (code) => {
|
|
83
83
|
const inGarfishToRender = `
|
|
84
84
|
const { basename, props, dom, appName } = typeof arguments[0] === 'object' && arguments[0] || {};
|
|
85
85
|
if (!canContinueRender({ dom, appName })) return null;
|
|
86
86
|
let { AppWrapper, mountNode } = generateAppWrapperAndRootDom({App, props, dom});
|
|
87
87
|
`;
|
|
88
|
-
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace(
|
|
88
|
+
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
|
|
89
|
+
`bootstrap(AppWrapper, mountNode, root`,
|
|
90
|
+
"bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
|
|
91
|
+
);
|
|
89
92
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (config !== null && config !== void 0 && (_config$runtime = config.runtime) !== null && _config$runtime !== void 0 && _config$runtime.features) {
|
|
95
|
-
var _config$runtime2;
|
|
96
|
-
return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
|
|
93
|
+
function getRuntimeConfig(config) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if ((_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.features) {
|
|
96
|
+
return (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.features;
|
|
97
97
|
}
|
|
98
|
-
return (config
|
|
98
|
+
return (config == null ? void 0 : config.runtime) || {};
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
var _config$runtime3, _config$runtime4;
|
|
104
|
-
if (config !== null && config !== void 0 && (_config$runtime3 = config.runtime) !== null && _config$runtime3 !== void 0 && _config$runtime3.features && config !== null && config !== void 0 && (_config$runtime4 = config.runtime) !== null && _config$runtime4 !== void 0 && _config$runtime4.features[key]) {
|
|
100
|
+
function setRuntimeConfig(config, key, value) {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
if (((_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.features) && ((_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.features[key])) {
|
|
105
103
|
config.runtime.features[key] = value;
|
|
106
|
-
return
|
|
104
|
+
return void 0;
|
|
107
105
|
}
|
|
108
|
-
if (config
|
|
106
|
+
if ((config == null ? void 0 : config.runtime) && (config == null ? void 0 : config.runtime[key])) {
|
|
109
107
|
config.runtime[key] = value;
|
|
110
|
-
return
|
|
108
|
+
return void 0;
|
|
111
109
|
}
|
|
112
|
-
return
|
|
110
|
+
return void 0;
|
|
113
111
|
}
|
|
114
|
-
|
|
115
|
-
const transformCode = code.replace(
|
|
112
|
+
const generateAsyncEntry = (code) => {
|
|
113
|
+
const transformCode = code.replace(
|
|
114
|
+
`import('./bootstrap.js');`,
|
|
115
|
+
`if (!window.__GARFISH__) { import('./bootstrap.js'); }`
|
|
116
|
+
);
|
|
116
117
|
return `
|
|
117
118
|
export const provider = async (...args) => {
|
|
118
119
|
const exports = await import('./bootstrap');
|
|
@@ -120,4 +121,11 @@ export const generateAsyncEntry = code => {
|
|
|
120
121
|
};
|
|
121
122
|
${transformCode}
|
|
122
123
|
`;
|
|
123
|
-
};
|
|
124
|
+
};
|
|
125
|
+
export {
|
|
126
|
+
generateAsyncEntry,
|
|
127
|
+
getRuntimeConfig,
|
|
128
|
+
makeProvider,
|
|
129
|
+
makeRenderFunction,
|
|
130
|
+
setRuntimeConfig
|
|
131
|
+
};
|
|
File without changes
|
package/dist/js/modern/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { default as default2 } from "./plugin";
|
|
2
|
+
import { useModuleApps, useModuleApp } from "./useModuleApps";
|
|
3
|
+
import { default as default3, default as default4 } from "garfish";
|
|
4
|
+
import { default as default5 } from "hoist-non-react-statics";
|
|
5
|
+
export {
|
|
6
|
+
default3 as Garfish,
|
|
7
|
+
default2 as default,
|
|
8
|
+
default4 as garfish,
|
|
9
|
+
default5 as hoistNonReactStatics,
|
|
10
|
+
useModuleApp,
|
|
11
|
+
useModuleApps
|
|
12
|
+
};
|