@modern-js/plugin-garfish 1.21.5 → 1.22.1
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 +18 -0
- package/dist/js/modern/cli/index.js +27 -3
- package/dist/js/modern/cli/utils.js +11 -1
- package/dist/js/node/cli/index.js +26 -2
- package/dist/js/node/cli/utils.js +15 -1
- package/dist/js/treeshaking/cli/index.js +27 -5
- package/dist/js/treeshaking/cli/utils.js +5 -1
- package/dist/types/cli/utils.d.ts +2 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
+
## 1.22.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @modern-js/runtime@1.22.1
|
|
8
|
+
- @modern-js/utils@1.22.1
|
|
9
|
+
|
|
10
|
+
## 1.21.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 57f7399: feat: support async export provider for module federation
|
|
15
|
+
支持模块联邦场景异步导出 provider
|
|
16
|
+
- Updated dependencies [bb7788d]
|
|
17
|
+
- Updated dependencies [e951ac1]
|
|
18
|
+
- @modern-js/runtime@1.21.6
|
|
19
|
+
- @modern-js/utils@1.21.6
|
|
20
|
+
|
|
3
21
|
## 1.21.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
9
9
|
import { logger } from "../util";
|
|
10
|
-
import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig } from "./utils";
|
|
10
|
+
import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig, generateAsyncEntry } from "./utils";
|
|
11
11
|
export const externals = {
|
|
12
12
|
'react-dom': 'react-dom',
|
|
13
13
|
react: 'react'
|
|
@@ -274,16 +274,40 @@ export default (({
|
|
|
274
274
|
};
|
|
275
275
|
},
|
|
276
276
|
|
|
277
|
+
modifyAsyncEntry({
|
|
278
|
+
entrypoint,
|
|
279
|
+
code
|
|
280
|
+
}) {
|
|
281
|
+
var _config$deploy2, _config$source;
|
|
282
|
+
|
|
283
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
284
|
+
const config = useResolvedConfigContext();
|
|
285
|
+
let finalCode = code;
|
|
286
|
+
|
|
287
|
+
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend && config !== null && config !== void 0 && (_config$source = config.source) !== null && _config$source !== void 0 && _config$source.enableAsyncEntry) {
|
|
288
|
+
finalCode = generateAsyncEntry(code);
|
|
289
|
+
return {
|
|
290
|
+
entrypoint,
|
|
291
|
+
code: `${finalCode}`
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
entrypoint,
|
|
297
|
+
code: finalCode
|
|
298
|
+
};
|
|
299
|
+
},
|
|
300
|
+
|
|
277
301
|
modifyEntryExport({
|
|
278
302
|
entrypoint,
|
|
279
303
|
exportStatement
|
|
280
304
|
}) {
|
|
281
|
-
var _config$
|
|
305
|
+
var _config$deploy3;
|
|
282
306
|
|
|
283
307
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
284
308
|
const config = useResolvedConfigContext();
|
|
285
309
|
|
|
286
|
-
if (config !== null && config !== void 0 && (_config$
|
|
310
|
+
if (config !== null && config !== void 0 && (_config$deploy3 = config.deploy) !== null && _config$deploy3 !== void 0 && _config$deploy3.microFrontend) {
|
|
287
311
|
const exportStatementCode = makeProvider();
|
|
288
312
|
logger('exportStatement', exportStatementCode);
|
|
289
313
|
return {
|
|
@@ -114,4 +114,14 @@ export function setRuntimeConfig(config, key, value) {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
return undefined;
|
|
117
|
-
}
|
|
117
|
+
}
|
|
118
|
+
export const generateAsyncEntry = code => {
|
|
119
|
+
const transformCode = code.replace(`import('./bootstrap.js');`, `if (!window.__GARFISH__) { import('./bootstrap.js'); }`);
|
|
120
|
+
return `
|
|
121
|
+
export const provider = async (...args) => {
|
|
122
|
+
const exports = await import('./bootstrap');
|
|
123
|
+
return exports.provider.apply(null, args);
|
|
124
|
+
};
|
|
125
|
+
${transformCode}
|
|
126
|
+
`;
|
|
127
|
+
};
|
|
@@ -291,16 +291,40 @@ var _default = ({
|
|
|
291
291
|
};
|
|
292
292
|
},
|
|
293
293
|
|
|
294
|
+
modifyAsyncEntry({
|
|
295
|
+
entrypoint,
|
|
296
|
+
code
|
|
297
|
+
}) {
|
|
298
|
+
var _config$deploy2, _config$source;
|
|
299
|
+
|
|
300
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
301
|
+
const config = useResolvedConfigContext();
|
|
302
|
+
let finalCode = code;
|
|
303
|
+
|
|
304
|
+
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend && config !== null && config !== void 0 && (_config$source = config.source) !== null && _config$source !== void 0 && _config$source.enableAsyncEntry) {
|
|
305
|
+
finalCode = (0, _utils2.generateAsyncEntry)(code);
|
|
306
|
+
return {
|
|
307
|
+
entrypoint,
|
|
308
|
+
code: `${finalCode}`
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
entrypoint,
|
|
314
|
+
code: finalCode
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
|
|
294
318
|
modifyEntryExport({
|
|
295
319
|
entrypoint,
|
|
296
320
|
exportStatement
|
|
297
321
|
}) {
|
|
298
|
-
var _config$
|
|
322
|
+
var _config$deploy3;
|
|
299
323
|
|
|
300
324
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
301
325
|
const config = useResolvedConfigContext();
|
|
302
326
|
|
|
303
|
-
if (config !== null && config !== void 0 && (_config$
|
|
327
|
+
if (config !== null && config !== void 0 && (_config$deploy3 = config.deploy) !== null && _config$deploy3 !== void 0 && _config$deploy3.microFrontend) {
|
|
304
328
|
const exportStatementCode = (0, _utils2.makeProvider)();
|
|
305
329
|
(0, _util.logger)('exportStatement', exportStatementCode);
|
|
306
330
|
return {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.generateAsyncEntry = void 0;
|
|
6
7
|
exports.getRuntimeConfig = getRuntimeConfig;
|
|
7
8
|
exports.makeRenderFunction = exports.makeProvider = void 0;
|
|
8
9
|
exports.setRuntimeConfig = setRuntimeConfig;
|
|
@@ -130,4 +131,17 @@ function setRuntimeConfig(config, key, value) {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
return undefined;
|
|
133
|
-
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const generateAsyncEntry = code => {
|
|
137
|
+
const transformCode = code.replace(`import('./bootstrap.js');`, `if (!window.__GARFISH__) { import('./bootstrap.js'); }`);
|
|
138
|
+
return `
|
|
139
|
+
export const provider = async (...args) => {
|
|
140
|
+
const exports = await import('./bootstrap');
|
|
141
|
+
return exports.provider.apply(null, args);
|
|
142
|
+
};
|
|
143
|
+
${transformCode}
|
|
144
|
+
`;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
exports.generateAsyncEntry = generateAsyncEntry;
|
|
@@ -5,7 +5,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
7
7
|
import { logger } from "../util";
|
|
8
|
-
import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig } from "./utils";
|
|
8
|
+
import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig, generateAsyncEntry } from "./utils";
|
|
9
9
|
export var externals = {
|
|
10
10
|
'react-dom': 'react-dom',
|
|
11
11
|
react: 'react'
|
|
@@ -279,15 +279,37 @@ export default (function () {
|
|
|
279
279
|
code: nCode
|
|
280
280
|
};
|
|
281
281
|
},
|
|
282
|
-
|
|
283
|
-
var _config$deploy2;
|
|
282
|
+
modifyAsyncEntry: function modifyAsyncEntry(_ref7) {
|
|
283
|
+
var _config$deploy2, _config$source;
|
|
284
284
|
|
|
285
285
|
var entrypoint = _ref7.entrypoint,
|
|
286
|
-
|
|
286
|
+
code = _ref7.code;
|
|
287
287
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
288
288
|
var config = useResolvedConfigContext();
|
|
289
|
+
var finalCode = code;
|
|
289
290
|
|
|
290
|
-
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
|
|
291
|
+
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend && config !== null && config !== void 0 && (_config$source = config.source) !== null && _config$source !== void 0 && _config$source.enableAsyncEntry) {
|
|
292
|
+
finalCode = generateAsyncEntry(code);
|
|
293
|
+
return {
|
|
294
|
+
entrypoint: entrypoint,
|
|
295
|
+
code: "".concat(finalCode)
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
entrypoint: entrypoint,
|
|
301
|
+
code: finalCode
|
|
302
|
+
};
|
|
303
|
+
},
|
|
304
|
+
modifyEntryExport: function modifyEntryExport(_ref8) {
|
|
305
|
+
var _config$deploy3;
|
|
306
|
+
|
|
307
|
+
var entrypoint = _ref8.entrypoint,
|
|
308
|
+
exportStatement = _ref8.exportStatement;
|
|
309
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
310
|
+
var config = useResolvedConfigContext();
|
|
311
|
+
|
|
312
|
+
if (config !== null && config !== void 0 && (_config$deploy3 = config.deploy) !== null && _config$deploy3 !== void 0 && _config$deploy3.microFrontend) {
|
|
291
313
|
var exportStatementCode = makeProvider();
|
|
292
314
|
logger('exportStatement', exportStatementCode);
|
|
293
315
|
return {
|
|
@@ -32,4 +32,8 @@ export function setRuntimeConfig(config, key, value) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return undefined;
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
|
+
export var generateAsyncEntry = function generateAsyncEntry(code) {
|
|
37
|
+
var transformCode = code.replace("import('./bootstrap.js');", "if (!window.__GARFISH__) { import('./bootstrap.js'); }");
|
|
38
|
+
return "\n export const provider = async (...args) => {\n const exports = await import('./bootstrap');\n return exports.provider.apply(null, args);\n };\n ".concat(transformCode, "\n ");
|
|
39
|
+
};
|
|
@@ -2,4 +2,5 @@ import type { NormalizedConfig } from '@modern-js/core';
|
|
|
2
2
|
export declare const makeProvider: () => string;
|
|
3
3
|
export declare const makeRenderFunction: (code: string) => string;
|
|
4
4
|
export declare function getRuntimeConfig(config: Partial<NormalizedConfig>): any;
|
|
5
|
-
export declare function setRuntimeConfig(config: Partial<NormalizedConfig>, key: string, value: any): undefined;
|
|
5
|
+
export declare function setRuntimeConfig(config: Partial<NormalizedConfig>, key: string, value: any): undefined;
|
|
6
|
+
export declare const generateAsyncEntry: (code: string) => string;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.22.1",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/runtime/index.d.ts",
|
|
17
17
|
"typesVersions": {
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"garfish": "^1.8.1",
|
|
57
57
|
"hoist-non-react-statics": "^3.3.2",
|
|
58
58
|
"react-loadable": "^5.5.0",
|
|
59
|
-
"@modern-js/utils": "1.
|
|
59
|
+
"@modern-js/utils": "1.22.1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@modern-js/runtime": "^1.
|
|
62
|
+
"@modern-js/runtime": "^1.22.1"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"@modern-js/runtime": {
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"react-router-dom": "^6.2.1",
|
|
83
83
|
"typescript": "^4",
|
|
84
84
|
"webpack-chain": "^6.5.1",
|
|
85
|
-
"@modern-js/core": "1.
|
|
86
|
-
"@modern-js/runtime": "1.
|
|
87
|
-
"@modern-js/types": "1.
|
|
88
|
-
"@scripts/build": "1.
|
|
89
|
-
"@scripts/jest-config": "1.
|
|
85
|
+
"@modern-js/core": "1.22.1",
|
|
86
|
+
"@modern-js/runtime": "1.22.1",
|
|
87
|
+
"@modern-js/types": "1.22.1",
|
|
88
|
+
"@scripts/build": "1.22.1",
|
|
89
|
+
"@scripts/jest-config": "1.22.1"
|
|
90
90
|
},
|
|
91
91
|
"sideEffects": false,
|
|
92
92
|
"modernConfig": {},
|