@modern-js/plugin-garfish 2.0.0-beta.3 → 2.0.0-beta.4
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 +164 -157
- 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 +177 -142
- package/dist/js/modern/runtime/utils/setExternal.js +11 -11
- package/dist/js/modern/type.d.js +0 -0
- package/dist/js/modern/util.js +11 -9
- package/dist/js/node/cli/index.js +184 -168
- package/dist/js/node/cli/utils.js +45 -30
- package/dist/js/node/global.d.js +0 -0
- package/dist/js/node/index.js +29 -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 +35 -44
- package/dist/js/node/runtime/loadable.js +95 -61
- package/dist/js/node/runtime/plugin.js +147 -95
- package/dist/js/node/runtime/useModuleApps.js +64 -34
- package/dist/js/node/runtime/utils/Context.js +30 -10
- package/dist/js/node/runtime/utils/MApp.js +107 -84
- package/dist/js/node/runtime/utils/apps.js +204 -146
- package/dist/js/node/runtime/utils/setExternal.js +35 -18
- package/dist/js/node/type.d.js +0 -0
- package/dist/js/node/util.js +34 -19
- package/dist/js/treeshaking/cli/index.js +402 -284
- 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 +536 -230
- package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
- package/dist/js/treeshaking/type.d.js +1 -0
- package/dist/js/treeshaking/util.js +7 -9
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/runtime/plugin.d.ts +2 -0
- package/dist/types/runtime/utils/setExternal.d.ts +1 -0
- package/package.json +10 -10
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,94 @@
|
|
|
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
|
+
const externals = { "react-dom": "react-dom", react: "react" };
|
|
48
|
+
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
13
49
|
if (microFrontend === true) {
|
|
14
50
|
return {
|
|
15
51
|
enableHtmlEntry: true,
|
|
16
52
|
externalBasicLibrary: false,
|
|
17
|
-
moduleApp:
|
|
53
|
+
moduleApp: ""
|
|
18
54
|
};
|
|
19
55
|
}
|
|
20
|
-
return
|
|
56
|
+
return __spreadValues({
|
|
21
57
|
enableHtmlEntry: true,
|
|
22
58
|
externalBasicLibrary: false
|
|
23
59
|
}, microFrontend);
|
|
24
60
|
}
|
|
25
|
-
|
|
26
|
-
pluginName
|
|
27
|
-
runtimePluginName
|
|
28
|
-
mfPackagePath
|
|
61
|
+
var cli_default = ({
|
|
62
|
+
pluginName = "@modern-js/plugin-garfish",
|
|
63
|
+
runtimePluginName = "@modern-js/runtime/plugins",
|
|
64
|
+
mfPackagePath = path.resolve(__dirname, "../../../../")
|
|
29
65
|
} = {}) => ({
|
|
30
|
-
name:
|
|
31
|
-
setup: ({
|
|
32
|
-
useAppContext,
|
|
33
|
-
useResolvedConfigContext,
|
|
34
|
-
useConfigContext
|
|
35
|
-
}) => {
|
|
66
|
+
name: "@modern-js/plugin-garfish",
|
|
67
|
+
setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
|
|
36
68
|
let pluginsExportsUtils;
|
|
37
69
|
let runtimeExportsUtils;
|
|
38
70
|
return {
|
|
39
71
|
validateSchema() {
|
|
40
|
-
return PLUGIN_SCHEMAS[
|
|
72
|
+
return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
|
|
41
73
|
},
|
|
42
|
-
resolvedConfig:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} =
|
|
46
|
-
const {
|
|
47
|
-
masterApp,
|
|
48
|
-
router
|
|
49
|
-
} = getRuntimeConfig(resolved);
|
|
74
|
+
resolvedConfig: (config) => __async(void 0, null, function* () {
|
|
75
|
+
var _a;
|
|
76
|
+
const { resolved } = config;
|
|
77
|
+
const { masterApp, router } = getRuntimeConfig(resolved);
|
|
50
78
|
const nConfig = {
|
|
51
|
-
resolved:
|
|
79
|
+
resolved: __spreadValues({}, resolved)
|
|
52
80
|
};
|
|
53
81
|
if (masterApp) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
setRuntimeConfig(
|
|
83
|
+
nConfig.resolved,
|
|
84
|
+
"masterApp",
|
|
85
|
+
Object.assign(
|
|
86
|
+
typeof masterApp === "object" ? __spreadValues({}, masterApp) : {},
|
|
87
|
+
{
|
|
88
|
+
basename: ((_a = router == null ? void 0 : router.historyOptions) == null ? void 0 : _a.basename) || (router == null ? void 0 : router.basename) || "/"
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
);
|
|
59
92
|
}
|
|
60
93
|
logger(`resolvedConfig`, {
|
|
61
94
|
output: nConfig.resolved.output,
|
|
@@ -64,25 +97,25 @@ export default (({
|
|
|
64
97
|
server: nConfig.resolved.server
|
|
65
98
|
});
|
|
66
99
|
return nConfig;
|
|
67
|
-
},
|
|
100
|
+
}),
|
|
68
101
|
config() {
|
|
69
|
-
var
|
|
70
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
102
|
+
var _a, _b, _c;
|
|
71
103
|
const useConfig = useConfigContext();
|
|
72
|
-
logger(
|
|
73
|
-
|
|
74
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
104
|
+
logger("useConfig", useConfig);
|
|
75
105
|
const config = useAppContext();
|
|
76
|
-
pluginsExportsUtils = createRuntimeExportsUtils(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
pluginsExportsUtils = createRuntimeExportsUtils(
|
|
107
|
+
config.internalDirectory,
|
|
108
|
+
"plugins"
|
|
109
|
+
);
|
|
110
|
+
runtimeExportsUtils = createRuntimeExportsUtils(
|
|
111
|
+
config.internalDirectory,
|
|
112
|
+
"index"
|
|
113
|
+
);
|
|
114
|
+
let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
|
|
115
|
+
if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
|
|
116
|
+
const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
|
|
117
|
+
(_c = useConfig.deploy) == null ? void 0 : _c.microFrontend
|
|
118
|
+
);
|
|
86
119
|
if (!enableHtmlEntry) {
|
|
87
120
|
disableCssExtract = true;
|
|
88
121
|
}
|
|
@@ -93,61 +126,54 @@ export default (({
|
|
|
93
126
|
},
|
|
94
127
|
source: {
|
|
95
128
|
alias: {
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
130
|
+
"@modern-js/runtime/garfish": mfPackagePath
|
|
98
131
|
}
|
|
99
132
|
},
|
|
100
133
|
tools: {
|
|
101
134
|
devServer: {
|
|
102
135
|
headers: {
|
|
103
|
-
|
|
136
|
+
"Access-Control-Allow-Origin": "*"
|
|
104
137
|
}
|
|
105
138
|
},
|
|
106
139
|
webpackChain: (chain, {
|
|
107
140
|
webpack,
|
|
108
|
-
env
|
|
141
|
+
env = process.env.NODE_ENV || "development",
|
|
109
142
|
CHAIN_ID
|
|
110
143
|
}) => {
|
|
111
|
-
var
|
|
112
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
144
|
+
var _a2, _b2, _c2, _d;
|
|
113
145
|
const resolveOptions = useResolvedConfigContext();
|
|
114
|
-
if (resolveOptions
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
146
|
+
if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
|
|
147
|
+
chain.output.libraryTarget("umd");
|
|
148
|
+
if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
|
|
149
|
+
chain.output.publicPath(
|
|
150
|
+
`//localhost:${resolveOptions.server.port}/`
|
|
151
|
+
);
|
|
119
152
|
}
|
|
120
|
-
|
|
121
|
-
// add comments avoid sourcemap abnormal
|
|
122
153
|
if (webpack.BannerPlugin) {
|
|
123
|
-
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
|
|
124
|
-
banner: 'Micro front-end'
|
|
125
|
-
}]);
|
|
154
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
|
|
126
155
|
}
|
|
127
|
-
const {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
|
|
131
|
-
// external
|
|
156
|
+
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
|
|
157
|
+
(_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
|
|
158
|
+
);
|
|
132
159
|
if (externalBasicLibrary) {
|
|
133
160
|
chain.externals(externals);
|
|
134
161
|
}
|
|
135
|
-
// use html mode
|
|
136
162
|
if (!enableHtmlEntry) {
|
|
137
|
-
chain.output.filename(
|
|
163
|
+
chain.output.filename("index.js");
|
|
138
164
|
chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
|
|
139
165
|
chain.optimization.runtimeChunk(false);
|
|
140
166
|
chain.optimization.splitChunks({
|
|
141
|
-
chunks:
|
|
167
|
+
chunks: "async"
|
|
142
168
|
});
|
|
143
169
|
}
|
|
144
170
|
}
|
|
145
171
|
const resolveWebpackConfig = chain.toConfig();
|
|
146
|
-
logger(
|
|
172
|
+
logger("webpackConfig", {
|
|
147
173
|
output: resolveWebpackConfig.output,
|
|
148
174
|
externals: resolveWebpackConfig.externals,
|
|
149
|
-
env
|
|
150
|
-
alias: (
|
|
175
|
+
env,
|
|
176
|
+
alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
|
|
151
177
|
plugins: resolveWebpackConfig.plugins
|
|
152
178
|
});
|
|
153
179
|
}
|
|
@@ -155,104 +181,84 @@ export default (({
|
|
|
155
181
|
};
|
|
156
182
|
},
|
|
157
183
|
addRuntimeExports() {
|
|
158
|
-
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${
|
|
159
|
-
logger(
|
|
184
|
+
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}'`;
|
|
185
|
+
logger("exportStatement", addExportStatement);
|
|
160
186
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
161
|
-
runtimeExportsUtils.addExport(`export * from '${
|
|
187
|
+
runtimeExportsUtils.addExport(`export * from '${mfPackagePath}'`);
|
|
162
188
|
},
|
|
163
|
-
modifyEntryImports({
|
|
164
|
-
entrypoint,
|
|
165
|
-
imports
|
|
166
|
-
}) {
|
|
167
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
189
|
+
modifyEntryImports({ entrypoint, imports }) {
|
|
168
190
|
const config = useResolvedConfigContext();
|
|
169
|
-
const {
|
|
170
|
-
masterApp
|
|
171
|
-
} = getRuntimeConfig(config);
|
|
191
|
+
const { masterApp } = getRuntimeConfig(config);
|
|
172
192
|
if (masterApp) {
|
|
173
193
|
imports.push({
|
|
174
|
-
value:
|
|
175
|
-
specifiers: [
|
|
176
|
-
|
|
177
|
-
|
|
194
|
+
value: runtimePluginName,
|
|
195
|
+
specifiers: [
|
|
196
|
+
{
|
|
197
|
+
imported: "garfish"
|
|
198
|
+
}
|
|
199
|
+
]
|
|
178
200
|
});
|
|
179
201
|
imports.push({
|
|
180
|
-
value:
|
|
181
|
-
specifiers: [
|
|
182
|
-
|
|
183
|
-
|
|
202
|
+
value: runtimePluginName,
|
|
203
|
+
specifiers: [
|
|
204
|
+
{
|
|
205
|
+
imported: "masterApp"
|
|
206
|
+
}
|
|
207
|
+
]
|
|
184
208
|
});
|
|
185
209
|
}
|
|
186
210
|
imports.push({
|
|
187
|
-
value:
|
|
188
|
-
specifiers: [
|
|
189
|
-
|
|
190
|
-
|
|
211
|
+
value: runtimePluginName,
|
|
212
|
+
specifiers: [
|
|
213
|
+
{
|
|
214
|
+
imported: "hoistNonReactStatics"
|
|
215
|
+
}
|
|
216
|
+
]
|
|
191
217
|
});
|
|
192
218
|
imports.push({
|
|
193
|
-
value:
|
|
194
|
-
specifiers: [
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
219
|
+
value: "react-dom",
|
|
220
|
+
specifiers: [
|
|
221
|
+
{
|
|
222
|
+
imported: "unmountComponentAtNode"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
imported: "createPortal"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
199
228
|
});
|
|
200
|
-
return {
|
|
201
|
-
imports,
|
|
202
|
-
entrypoint
|
|
203
|
-
};
|
|
229
|
+
return { imports, entrypoint };
|
|
204
230
|
},
|
|
205
|
-
modifyEntryRuntimePlugins({
|
|
206
|
-
entrypoint,
|
|
207
|
-
plugins
|
|
208
|
-
}) {
|
|
209
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
231
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
210
232
|
const config = useResolvedConfigContext();
|
|
211
|
-
const {
|
|
212
|
-
masterApp
|
|
213
|
-
} = getRuntimeConfig(config);
|
|
233
|
+
const { masterApp } = getRuntimeConfig(config);
|
|
214
234
|
if (masterApp) {
|
|
215
|
-
logger(
|
|
235
|
+
logger("garfishPlugin options", masterApp);
|
|
216
236
|
plugins.push({
|
|
217
|
-
name:
|
|
218
|
-
args:
|
|
237
|
+
name: "garfish",
|
|
238
|
+
args: "masterApp",
|
|
219
239
|
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
220
240
|
});
|
|
221
241
|
}
|
|
222
|
-
return {
|
|
223
|
-
entrypoint,
|
|
224
|
-
plugins
|
|
225
|
-
};
|
|
242
|
+
return { entrypoint, plugins };
|
|
226
243
|
},
|
|
227
|
-
modifyEntryRenderFunction({
|
|
228
|
-
|
|
229
|
-
code
|
|
230
|
-
}) {
|
|
231
|
-
var _config$deploy;
|
|
232
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
244
|
+
modifyEntryRenderFunction({ entrypoint, code }) {
|
|
245
|
+
var _a;
|
|
233
246
|
const config = useResolvedConfigContext();
|
|
234
|
-
if (!(config
|
|
235
|
-
return {
|
|
236
|
-
entrypoint,
|
|
237
|
-
code
|
|
238
|
-
};
|
|
247
|
+
if (!((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend)) {
|
|
248
|
+
return { entrypoint, code };
|
|
239
249
|
}
|
|
240
250
|
const nCode = makeRenderFunction(code);
|
|
241
|
-
logger(
|
|
251
|
+
logger("makeRenderFunction", nCode);
|
|
242
252
|
return {
|
|
243
253
|
entrypoint,
|
|
244
254
|
code: nCode
|
|
245
255
|
};
|
|
246
256
|
},
|
|
247
|
-
modifyAsyncEntry({
|
|
248
|
-
|
|
249
|
-
code
|
|
250
|
-
}) {
|
|
251
|
-
var _config$deploy2, _config$source;
|
|
252
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
257
|
+
modifyAsyncEntry({ entrypoint, code }) {
|
|
258
|
+
var _a, _b;
|
|
253
259
|
const config = useResolvedConfigContext();
|
|
254
260
|
let finalCode = code;
|
|
255
|
-
if (config
|
|
261
|
+
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
262
|
finalCode = generateAsyncEntry(code);
|
|
257
263
|
return {
|
|
258
264
|
entrypoint,
|
|
@@ -264,16 +270,12 @@ export default (({
|
|
|
264
270
|
code: finalCode
|
|
265
271
|
};
|
|
266
272
|
},
|
|
267
|
-
modifyEntryExport({
|
|
268
|
-
|
|
269
|
-
exportStatement
|
|
270
|
-
}) {
|
|
271
|
-
var _config$deploy3;
|
|
272
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
273
|
+
modifyEntryExport({ entrypoint, exportStatement }) {
|
|
274
|
+
var _a;
|
|
273
275
|
const config = useResolvedConfigContext();
|
|
274
|
-
if (config
|
|
276
|
+
if ((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) {
|
|
275
277
|
const exportStatementCode = makeProvider();
|
|
276
|
-
logger(
|
|
278
|
+
logger("exportStatement", exportStatementCode);
|
|
277
279
|
return {
|
|
278
280
|
entrypoint,
|
|
279
281
|
exportStatement: exportStatementCode
|
|
@@ -286,4 +288,9 @@ export default (({
|
|
|
286
288
|
}
|
|
287
289
|
};
|
|
288
290
|
}
|
|
289
|
-
})
|
|
291
|
+
});
|
|
292
|
+
export {
|
|
293
|
+
cli_default as default,
|
|
294
|
+
externals,
|
|
295
|
+
getDefaultMicroFrontedConfig
|
|
296
|
+
};
|
|
@@ -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
|
+
};
|