@umijs/plugins 4.6.66 → 4.6.67
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/qiankun/slave.js +61 -2
- package/package.json +4 -4
package/dist/qiankun/slave.js
CHANGED
|
@@ -92,6 +92,59 @@ function isSlaveEnable(opts) {
|
|
|
92
92
|
}
|
|
93
93
|
return !!process.env.INITIAL_QIANKUN_SLAVE_OPTIONS;
|
|
94
94
|
}
|
|
95
|
+
function isUtoopackEnable(api) {
|
|
96
|
+
return Boolean(
|
|
97
|
+
api.appData.bundler === "utoopack" || api.userConfig.utoopack || api.config.utoopack || process.env.FORCE_UTOOPACK
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function getUtoopackQiankunLifecycleProxyScript(appName) {
|
|
101
|
+
return `(function() {
|
|
102
|
+
var appName = ${JSON.stringify(appName)};
|
|
103
|
+
var lifecycleNames = ['bootstrap', 'mount', 'unmount', 'update'];
|
|
104
|
+
var global = window;
|
|
105
|
+
var existed = global[appName];
|
|
106
|
+
if (existed && typeof existed.bootstrap === 'function' && typeof existed.mount === 'function' && typeof existed.unmount === 'function') {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var resolveReady;
|
|
110
|
+
var ready = new Promise(function(resolve) {
|
|
111
|
+
resolveReady = resolve;
|
|
112
|
+
});
|
|
113
|
+
var proxy = {};
|
|
114
|
+
lifecycleNames.forEach(function(name) {
|
|
115
|
+
proxy[name] = function() {
|
|
116
|
+
var context = this;
|
|
117
|
+
var args = arguments;
|
|
118
|
+
return ready.then(function(lifecycles) {
|
|
119
|
+
var lifecycle = lifecycles && lifecycles[name];
|
|
120
|
+
if (typeof lifecycle !== 'function') {
|
|
121
|
+
if (name === 'update') {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
throw new Error('[plugins/qiankun]: lifecycle ' + name + ' is not available for ' + appName + '.');
|
|
125
|
+
}
|
|
126
|
+
return lifecycle.apply(context, args);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(global, appName, {
|
|
131
|
+
configurable: true,
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function() {
|
|
134
|
+
return proxy;
|
|
135
|
+
},
|
|
136
|
+
set: function(lifecycles) {
|
|
137
|
+
Object.defineProperty(global, appName, {
|
|
138
|
+
configurable: true,
|
|
139
|
+
enumerable: true,
|
|
140
|
+
writable: true,
|
|
141
|
+
value: lifecycles
|
|
142
|
+
});
|
|
143
|
+
resolveReady(lifecycles);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
})();`;
|
|
147
|
+
}
|
|
95
148
|
var slave_default = (api) => {
|
|
96
149
|
api.describe({
|
|
97
150
|
key: "qiankun-slave",
|
|
@@ -172,7 +225,7 @@ export interface IRuntimeConfig {
|
|
|
172
225
|
];
|
|
173
226
|
});
|
|
174
227
|
api.chainWebpack((config, { ssr }) => {
|
|
175
|
-
if (ssr || api
|
|
228
|
+
if (ssr || isUtoopackEnable(api)) {
|
|
176
229
|
return;
|
|
177
230
|
}
|
|
178
231
|
(0, import_assert.default)(api.pkg.name, "You should have name in package.json.");
|
|
@@ -185,10 +238,16 @@ export interface IRuntimeConfig {
|
|
|
185
238
|
return config;
|
|
186
239
|
});
|
|
187
240
|
api.modifyHTML(($) => {
|
|
241
|
+
var _a, _b;
|
|
242
|
+
const appName = ((_b = (_a = api.config.qiankun) == null ? void 0 : _a.slave) == null ? void 0 : _b.appName) || api.pkg.name;
|
|
243
|
+
const lifecycleProxyScript = isUtoopackEnable(api) && appName ? `<script>${getUtoopackQiankunLifecycleProxyScript(appName)}</script>` : "";
|
|
188
244
|
$("script").each((_, el) => {
|
|
189
245
|
const scriptEl = $(el);
|
|
190
246
|
const umiEntry = /\/?umi(\.\w+)?\.js$/g;
|
|
191
247
|
if (umiEntry.test(scriptEl.attr("src") ?? "")) {
|
|
248
|
+
if (lifecycleProxyScript) {
|
|
249
|
+
scriptEl.before(lifecycleProxyScript);
|
|
250
|
+
}
|
|
192
251
|
scriptEl.attr("entry", "");
|
|
193
252
|
}
|
|
194
253
|
});
|
|
@@ -214,7 +273,7 @@ export const mount = isServer ? qiankun_noop : qiankun_genMount('${api.config.mo
|
|
|
214
273
|
export const unmount = isServer ? qiankun_noop : qiankun_genUnmount('${api.config.mountElementId}');
|
|
215
274
|
export const update = isServer ? qiankun_noop : qiankun_genUpdate();
|
|
216
275
|
|
|
217
|
-
if (!isServer && ${
|
|
276
|
+
if (!isServer && ${isUtoopackEnable(api)}) {
|
|
218
277
|
window['${appName}'] = {
|
|
219
278
|
bootstrap,
|
|
220
279
|
mount,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.67",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"intl": "1.2.5",
|
|
40
40
|
"lodash": "^4.18.1",
|
|
41
41
|
"moment": "^2.29.4",
|
|
42
|
-
"qiankun": "
|
|
42
|
+
"qiankun": "2.10.17-beta.0",
|
|
43
43
|
"react-intl": "3.12.1",
|
|
44
44
|
"react-redux": "^8.0.5",
|
|
45
45
|
"redux": "^4.2.1",
|
|
46
46
|
"styled-components": "6.1.1",
|
|
47
47
|
"tslib": "^2",
|
|
48
48
|
"warning": "^4.0.3",
|
|
49
|
-
"@umijs/bundler-utils": "4.6.
|
|
49
|
+
"@umijs/bundler-utils": "4.6.67",
|
|
50
50
|
"@umijs/valtio": "1.0.4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"antd": "^4.24.1",
|
|
54
|
-
"umi": "4.6.
|
|
54
|
+
"umi": "4.6.67"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|