@module-federation/data-prefetch 0.6.9 → 0.6.11
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 +20 -0
- package/dist/cli.cjs.js +5 -4
- package/dist/cli.esm.js +5 -4
- package/dist/constant.cjs.js +5 -0
- package/dist/constant.esm.js +3 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/package.json +1 -13
- package/dist/plugin.cjs.js +4 -4
- package/dist/plugin.esm.js +4 -4
- package/dist/src/constant.d.ts +1 -0
- package/package.json +3 -15
- package/project.json +1 -1
- package/rollup.config.js +0 -1
- package/src/cli/index.ts +6 -3
- package/src/constant.ts +1 -0
- package/src/plugin.ts +4 -4
- package/dist/shared.cjs.d.ts +0 -2
- package/dist/shared.cjs.js +0 -24
- package/dist/shared.esm.d.ts +0 -2
- package/dist/shared.esm.js +0 -22
- package/dist/src/shared/index.d.ts +0 -3
- package/src/shared/index.ts +0 -26
- package/tsup.config.ts +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
+
## 0.6.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ea6d417]
|
|
8
|
+
- Updated dependencies [d5a3072]
|
|
9
|
+
- @module-federation/runtime@0.6.11
|
|
10
|
+
- @module-federation/sdk@0.6.11
|
|
11
|
+
|
|
12
|
+
## 0.6.10
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 22a3b83: fix(data-prefetch): apply DataPrefetchPlugin on demand
|
|
17
|
+
- 22a3b83: fix(data-prefetch): set sharedStrategy in build options instead of using runtime plugin
|
|
18
|
+
- Updated dependencies [b704f30]
|
|
19
|
+
- Updated dependencies [22a3b83]
|
|
20
|
+
- @module-federation/runtime@0.6.10
|
|
21
|
+
- @module-federation/sdk@0.6.10
|
|
22
|
+
|
|
3
23
|
## 0.6.9
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cli.cjs.js
CHANGED
|
@@ -5,6 +5,7 @@ var fs = require('fs-extra');
|
|
|
5
5
|
var sdk = require('@module-federation/sdk');
|
|
6
6
|
var normalizeWebpackPath = require('@module-federation/sdk/normalize-webpack-path');
|
|
7
7
|
var runtimeUtils = require('./runtime-utils.cjs.js');
|
|
8
|
+
var constant = require('./constant.cjs.js');
|
|
8
9
|
require('@module-federation/runtime');
|
|
9
10
|
|
|
10
11
|
const TEMP_DIR = '.mf';
|
|
@@ -40,7 +41,7 @@ function getFederationGlobalScope(runtimeGlobals) {
|
|
|
40
41
|
class PrefetchPlugin {
|
|
41
42
|
// eslint-disable-next-line max-lines-per-function
|
|
42
43
|
apply(compiler) {
|
|
43
|
-
var _this_options_runtimePlugins
|
|
44
|
+
var _this_options_runtimePlugins;
|
|
44
45
|
const { name, exposes } = this.options;
|
|
45
46
|
if (!exposes) {
|
|
46
47
|
return;
|
|
@@ -53,12 +54,12 @@ class PrefetchPlugin {
|
|
|
53
54
|
this.options.runtimePlugins = [];
|
|
54
55
|
}
|
|
55
56
|
const runtimePath = path.resolve(__dirname, './plugin.esm.js');
|
|
56
|
-
const sharedPath = path.resolve(__dirname, './shared.esm.js');
|
|
57
57
|
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
|
|
58
58
|
this.options.runtimePlugins.push(runtimePath);
|
|
59
59
|
}
|
|
60
|
-
if (
|
|
61
|
-
this.options.
|
|
60
|
+
if (this.options.shareStrategy !== constant.SHARED_STRATEGY) {
|
|
61
|
+
this.options.shareStrategy = constant.SHARED_STRATEGY;
|
|
62
|
+
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${constant.SHARED_STRATEGY}', this is a necessary condition for data prefetch`);
|
|
62
63
|
}
|
|
63
64
|
const encodedName = sdk.encodeName(name);
|
|
64
65
|
const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);
|
package/dist/cli.esm.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'fs-extra';
|
|
|
3
3
|
import { encodeName, MFPrefetchCommon } from '@module-federation/sdk';
|
|
4
4
|
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
|
|
5
5
|
import { b as getPrefetchId } from './runtime-utils.esm.js';
|
|
6
|
+
import { S as SHARED_STRATEGY } from './constant.esm.js';
|
|
6
7
|
import '@module-federation/runtime';
|
|
7
8
|
|
|
8
9
|
const TEMP_DIR = '.mf';
|
|
@@ -38,7 +39,7 @@ function getFederationGlobalScope(runtimeGlobals) {
|
|
|
38
39
|
class PrefetchPlugin {
|
|
39
40
|
// eslint-disable-next-line max-lines-per-function
|
|
40
41
|
apply(compiler) {
|
|
41
|
-
var _this_options_runtimePlugins
|
|
42
|
+
var _this_options_runtimePlugins;
|
|
42
43
|
const { name, exposes } = this.options;
|
|
43
44
|
if (!exposes) {
|
|
44
45
|
return;
|
|
@@ -51,12 +52,12 @@ class PrefetchPlugin {
|
|
|
51
52
|
this.options.runtimePlugins = [];
|
|
52
53
|
}
|
|
53
54
|
const runtimePath = path.resolve(__dirname, './plugin.esm.js');
|
|
54
|
-
const sharedPath = path.resolve(__dirname, './shared.esm.js');
|
|
55
55
|
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
|
|
56
56
|
this.options.runtimePlugins.push(runtimePath);
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
59
|
-
this.options.
|
|
58
|
+
if (this.options.shareStrategy !== SHARED_STRATEGY) {
|
|
59
|
+
this.options.shareStrategy = SHARED_STRATEGY;
|
|
60
|
+
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`);
|
|
60
61
|
}
|
|
61
62
|
const encodedName = encodeName(name);
|
|
62
63
|
const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);
|
package/dist/index.cjs.js
CHANGED
package/dist/index.esm.js
CHANGED
package/dist/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/data-prefetch",
|
|
3
3
|
"description": "Module Federation Data Prefetch",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.11",
|
|
5
5
|
"author": "nieyan <nyqykk@foxmail.com>",
|
|
6
6
|
"homepage": "https://github.com/module-federation/core",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"dev": "cross-env WATCH=true tsup",
|
|
10
|
-
"build": "rm -rf dist && tsup",
|
|
11
9
|
"test": "jest"
|
|
12
10
|
},
|
|
13
11
|
"publishConfig": {
|
|
@@ -38,11 +36,6 @@
|
|
|
38
36
|
"import": "./dist/universal.esm.js",
|
|
39
37
|
"require": "./dist/universal.cjs.js",
|
|
40
38
|
"types": "./dist/universal.cjs.d.ts"
|
|
41
|
-
},
|
|
42
|
-
"./shared": {
|
|
43
|
-
"import": "./dist/shared.esm.js",
|
|
44
|
-
"require": "./dist/shared.cjs.js",
|
|
45
|
-
"types": "./dist/shared/.cjs.d.ts"
|
|
46
39
|
}
|
|
47
40
|
},
|
|
48
41
|
"typesVersions": {
|
|
@@ -59,9 +52,6 @@
|
|
|
59
52
|
"universal": [
|
|
60
53
|
"./dist/universal.cjs.d.ts"
|
|
61
54
|
],
|
|
62
|
-
"shared": [
|
|
63
|
-
"./dist/shared.cjs.d.ts"
|
|
64
|
-
],
|
|
65
55
|
"babel-plugin": [
|
|
66
56
|
"./dist/babel.cjs.d.ts"
|
|
67
57
|
]
|
|
@@ -79,7 +69,6 @@
|
|
|
79
69
|
"@types/jest": "^29.5.11",
|
|
80
70
|
"@types/node": "^17.0.45",
|
|
81
71
|
"@types/react": "~18.0.38",
|
|
82
|
-
"esbuild-plugin-replace": "^1.4.0",
|
|
83
72
|
"jest": "^29.7.0",
|
|
84
73
|
"jest-environment-jsdom": "^29.7.0",
|
|
85
74
|
"minimist": "^1.2.8",
|
|
@@ -88,7 +77,6 @@
|
|
|
88
77
|
"react-router": "^6.21.3",
|
|
89
78
|
"react-test-renderer": "^18.2.0",
|
|
90
79
|
"ts-jest": "29.0.1",
|
|
91
|
-
"tsup": "6.2.0",
|
|
92
80
|
"webpack": "5.75.0"
|
|
93
81
|
},
|
|
94
82
|
"dependencies": {
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -6,11 +6,11 @@ var sdk = require('@module-federation/sdk');
|
|
|
6
6
|
var runtimeUtils = require('./runtime-utils.cjs.js');
|
|
7
7
|
var prefetch = require('./prefetch.cjs.js');
|
|
8
8
|
var index = require('./index.cjs2.js');
|
|
9
|
+
var constant = require('./constant.cjs.js');
|
|
9
10
|
require('@module-federation/runtime');
|
|
10
11
|
|
|
11
12
|
const loadingArray = [];
|
|
12
|
-
|
|
13
|
-
let sharedFlag = strategy;
|
|
13
|
+
let sharedFlag = constant.SHARED_STRATEGY;
|
|
14
14
|
// eslint-disable-next-line max-lines-per-function
|
|
15
15
|
const prefetchPlugin = ()=>({
|
|
16
16
|
name: 'data-prefetch-runtime-plugin',
|
|
@@ -28,7 +28,7 @@ const prefetchPlugin = ()=>({
|
|
|
28
28
|
if (!signal) {
|
|
29
29
|
return options;
|
|
30
30
|
}
|
|
31
|
-
if (sharedFlag !==
|
|
31
|
+
if (sharedFlag !== constant.SHARED_STRATEGY) {
|
|
32
32
|
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`);
|
|
33
33
|
}
|
|
34
34
|
const instance = prefetch.MFDataPrefetch.getInstance(name) || new prefetch.MFDataPrefetch(prefetchOptions);
|
|
@@ -88,7 +88,7 @@ const prefetchPlugin = ()=>({
|
|
|
88
88
|
if (!inited) {
|
|
89
89
|
return options;
|
|
90
90
|
}
|
|
91
|
-
if (sharedFlag !==
|
|
91
|
+
if (sharedFlag !== constant.SHARED_STRATEGY) {
|
|
92
92
|
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`);
|
|
93
93
|
}
|
|
94
94
|
const instance = prefetch.MFDataPrefetch.getInstance(name) || new prefetch.MFDataPrefetch(prefetchOptions);
|
package/dist/plugin.esm.js
CHANGED
|
@@ -2,11 +2,11 @@ import { getResourceUrl } from '@module-federation/sdk';
|
|
|
2
2
|
import { a as getSignalFromManifest } from './runtime-utils.esm.js';
|
|
3
3
|
import { M as MFDataPrefetch } from './prefetch.esm.js';
|
|
4
4
|
import { l as logger } from './index.esm2.js';
|
|
5
|
+
import { S as SHARED_STRATEGY } from './constant.esm.js';
|
|
5
6
|
import '@module-federation/runtime';
|
|
6
7
|
|
|
7
8
|
const loadingArray = [];
|
|
8
|
-
|
|
9
|
-
let sharedFlag = strategy;
|
|
9
|
+
let sharedFlag = SHARED_STRATEGY;
|
|
10
10
|
// eslint-disable-next-line max-lines-per-function
|
|
11
11
|
const prefetchPlugin = ()=>({
|
|
12
12
|
name: 'data-prefetch-runtime-plugin',
|
|
@@ -24,7 +24,7 @@ const prefetchPlugin = ()=>({
|
|
|
24
24
|
if (!signal) {
|
|
25
25
|
return options;
|
|
26
26
|
}
|
|
27
|
-
if (sharedFlag !==
|
|
27
|
+
if (sharedFlag !== SHARED_STRATEGY) {
|
|
28
28
|
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`);
|
|
29
29
|
}
|
|
30
30
|
const instance = MFDataPrefetch.getInstance(name) || new MFDataPrefetch(prefetchOptions);
|
|
@@ -84,7 +84,7 @@ const prefetchPlugin = ()=>({
|
|
|
84
84
|
if (!inited) {
|
|
85
85
|
return options;
|
|
86
86
|
}
|
|
87
|
-
if (sharedFlag !==
|
|
87
|
+
if (sharedFlag !== SHARED_STRATEGY) {
|
|
88
88
|
throw new Error(`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`);
|
|
89
89
|
}
|
|
90
90
|
const instance = MFDataPrefetch.getInstance(name) || new MFDataPrefetch(prefetchOptions);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHARED_STRATEGY = "loaded-first";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/data-prefetch",
|
|
3
3
|
"description": "Module Federation Data Prefetch",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.11",
|
|
5
5
|
"author": "nieyan <nyqykk@foxmail.com>",
|
|
6
6
|
"homepage": "https://github.com/module-federation/core",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,11 +33,6 @@
|
|
|
33
33
|
"import": "./dist/universal.esm.js",
|
|
34
34
|
"require": "./dist/universal.cjs.js",
|
|
35
35
|
"types": "./dist/universal.cjs.d.ts"
|
|
36
|
-
},
|
|
37
|
-
"./shared": {
|
|
38
|
-
"import": "./dist/shared.esm.js",
|
|
39
|
-
"require": "./dist/shared.cjs.js",
|
|
40
|
-
"types": "./dist/shared/.cjs.d.ts"
|
|
41
36
|
}
|
|
42
37
|
},
|
|
43
38
|
"typesVersions": {
|
|
@@ -54,9 +49,6 @@
|
|
|
54
49
|
"universal": [
|
|
55
50
|
"./dist/universal.cjs.d.ts"
|
|
56
51
|
],
|
|
57
|
-
"shared": [
|
|
58
|
-
"./dist/shared.cjs.d.ts"
|
|
59
|
-
],
|
|
60
52
|
"babel-plugin": [
|
|
61
53
|
"./dist/babel.cjs.d.ts"
|
|
62
54
|
]
|
|
@@ -74,7 +66,6 @@
|
|
|
74
66
|
"@types/jest": "^29.5.11",
|
|
75
67
|
"@types/node": "^17.0.45",
|
|
76
68
|
"@types/react": "~18.0.38",
|
|
77
|
-
"esbuild-plugin-replace": "^1.4.0",
|
|
78
69
|
"jest": "^29.7.0",
|
|
79
70
|
"jest-environment-jsdom": "^29.7.0",
|
|
80
71
|
"minimist": "^1.2.8",
|
|
@@ -83,17 +74,14 @@
|
|
|
83
74
|
"react-router": "^6.21.3",
|
|
84
75
|
"react-test-renderer": "^18.2.0",
|
|
85
76
|
"ts-jest": "29.0.1",
|
|
86
|
-
"tsup": "6.2.0",
|
|
87
77
|
"webpack": "5.75.0"
|
|
88
78
|
},
|
|
89
79
|
"dependencies": {
|
|
90
80
|
"fs-extra": "9.1.0",
|
|
91
|
-
"@module-federation/runtime": "0.6.
|
|
92
|
-
"@module-federation/sdk": "0.6.
|
|
81
|
+
"@module-federation/runtime": "0.6.11",
|
|
82
|
+
"@module-federation/sdk": "0.6.11"
|
|
93
83
|
},
|
|
94
84
|
"scripts": {
|
|
95
|
-
"dev": "cross-env WATCH=true tsup",
|
|
96
|
-
"build": "rm -rf dist && tsup",
|
|
97
85
|
"test": "jest"
|
|
98
86
|
}
|
|
99
87
|
}
|
package/project.json
CHANGED
package/rollup.config.js
CHANGED
|
@@ -18,7 +18,6 @@ module.exports = (rollupConfig, _projectOptions) => {
|
|
|
18
18
|
babel: 'packages/data-prefetch/src/cli/babel.ts',
|
|
19
19
|
universal: 'packages/data-prefetch/src/universal/index.ts',
|
|
20
20
|
plugin: 'packages/data-prefetch/src/plugin.ts',
|
|
21
|
-
shared: 'packages/data-prefetch/src/shared/index.ts',
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
if (Array.isArray(rollupConfig.output)) {
|
package/src/cli/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { Compiler, WebpackPluginInstance } from 'webpack';
|
|
|
12
12
|
import { TEMP_DIR } from '../common/constant';
|
|
13
13
|
import { fileExistsWithCaseSync, fixPrefetchPath } from '../common/node-utils';
|
|
14
14
|
import { getPrefetchId } from '../common/runtime-utils';
|
|
15
|
+
import { SHARED_STRATEGY } from '../constant';
|
|
15
16
|
|
|
16
17
|
const { RuntimeGlobals, Template } = require(
|
|
17
18
|
normalizeWebpackPath('webpack'),
|
|
@@ -48,12 +49,14 @@ export class PrefetchPlugin implements WebpackPluginInstance {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const runtimePath = path.resolve(__dirname, './plugin.esm.js');
|
|
51
|
-
const sharedPath = path.resolve(__dirname, './shared.esm.js');
|
|
52
52
|
if (!this.options.runtimePlugins?.includes(runtimePath)) {
|
|
53
53
|
this.options.runtimePlugins!.push(runtimePath);
|
|
54
54
|
}
|
|
55
|
-
if (
|
|
56
|
-
this.options.
|
|
55
|
+
if (this.options.shareStrategy !== SHARED_STRATEGY) {
|
|
56
|
+
this.options.shareStrategy = SHARED_STRATEGY;
|
|
57
|
+
console.warn(
|
|
58
|
+
`[Module Federation Data Prefetch]: Your shared strategy is set to '${SHARED_STRATEGY}', this is a necessary condition for data prefetch`,
|
|
59
|
+
);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
const encodedName = encodeName(name as string);
|
package/src/constant.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SHARED_STRATEGY = 'loaded-first';
|
package/src/plugin.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ModuleInfo, getResourceUrl } from '@module-federation/sdk';
|
|
|
4
4
|
import { getSignalFromManifest } from './common/runtime-utils';
|
|
5
5
|
import { MFDataPrefetch } from './prefetch';
|
|
6
6
|
import logger from './logger';
|
|
7
|
+
import { SHARED_STRATEGY } from './constant';
|
|
7
8
|
|
|
8
9
|
interface Loading {
|
|
9
10
|
id: string;
|
|
@@ -15,8 +16,7 @@ interface Loading {
|
|
|
15
16
|
>;
|
|
16
17
|
}
|
|
17
18
|
const loadingArray: Array<Loading> = [];
|
|
18
|
-
|
|
19
|
-
let sharedFlag = strategy;
|
|
19
|
+
let sharedFlag = SHARED_STRATEGY;
|
|
20
20
|
// eslint-disable-next-line max-lines-per-function
|
|
21
21
|
export const prefetchPlugin = (): FederationRuntimePlugin => ({
|
|
22
22
|
name: 'data-prefetch-runtime-plugin',
|
|
@@ -35,7 +35,7 @@ export const prefetchPlugin = (): FederationRuntimePlugin => ({
|
|
|
35
35
|
if (!signal) {
|
|
36
36
|
return options;
|
|
37
37
|
}
|
|
38
|
-
if (sharedFlag !==
|
|
38
|
+
if (sharedFlag !== SHARED_STRATEGY) {
|
|
39
39
|
throw new Error(
|
|
40
40
|
`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`,
|
|
41
41
|
);
|
|
@@ -109,7 +109,7 @@ export const prefetchPlugin = (): FederationRuntimePlugin => ({
|
|
|
109
109
|
return options;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
if (sharedFlag !==
|
|
112
|
+
if (sharedFlag !== SHARED_STRATEGY) {
|
|
113
113
|
throw new Error(
|
|
114
114
|
`[Module Federation Data Prefetch]: If you want to use data prefetch, the shared strategy must be 'loaded-first'`,
|
|
115
115
|
);
|
package/dist/shared.cjs.d.ts
DELETED
package/dist/shared.cjs.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const sharedStrategy = ()=>({
|
|
4
|
-
name: 'shared-strategy',
|
|
5
|
-
beforeInit (args) {
|
|
6
|
-
const { userOptions } = args;
|
|
7
|
-
const shared = userOptions.shared;
|
|
8
|
-
if (shared) {
|
|
9
|
-
Object.keys(shared).forEach((sharedKey)=>{
|
|
10
|
-
const sharedConfigs = shared[sharedKey];
|
|
11
|
-
const arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
|
|
12
|
-
sharedConfigs
|
|
13
|
-
];
|
|
14
|
-
arraySharedConfigs.forEach((s)=>{
|
|
15
|
-
s.strategy = 'loaded-first';
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
|
|
19
|
-
}
|
|
20
|
-
return args;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
module.exports = sharedStrategy;
|
package/dist/shared.esm.d.ts
DELETED
package/dist/shared.esm.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const sharedStrategy = ()=>({
|
|
2
|
-
name: 'shared-strategy',
|
|
3
|
-
beforeInit (args) {
|
|
4
|
-
const { userOptions } = args;
|
|
5
|
-
const shared = userOptions.shared;
|
|
6
|
-
if (shared) {
|
|
7
|
-
Object.keys(shared).forEach((sharedKey)=>{
|
|
8
|
-
const sharedConfigs = shared[sharedKey];
|
|
9
|
-
const arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
|
|
10
|
-
sharedConfigs
|
|
11
|
-
];
|
|
12
|
-
arraySharedConfigs.forEach((s)=>{
|
|
13
|
-
s.strategy = 'loaded-first';
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
|
|
17
|
-
}
|
|
18
|
-
return args;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export { sharedStrategy as default };
|
package/src/shared/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { FederationRuntimePlugin } from '@module-federation/runtime';
|
|
2
|
-
|
|
3
|
-
const sharedStrategy: () => FederationRuntimePlugin = () => ({
|
|
4
|
-
name: 'shared-strategy',
|
|
5
|
-
beforeInit(args) {
|
|
6
|
-
const { userOptions } = args;
|
|
7
|
-
const shared = userOptions.shared;
|
|
8
|
-
if (shared) {
|
|
9
|
-
Object.keys(shared).forEach((sharedKey) => {
|
|
10
|
-
const sharedConfigs = shared[sharedKey];
|
|
11
|
-
const arraySharedConfigs = Array.isArray(sharedConfigs)
|
|
12
|
-
? sharedConfigs
|
|
13
|
-
: [sharedConfigs];
|
|
14
|
-
arraySharedConfigs.forEach((s) => {
|
|
15
|
-
s.strategy = 'loaded-first';
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
console.warn(
|
|
19
|
-
`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`,
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
return args;
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export default sharedStrategy;
|
package/tsup.config.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { replace } from 'esbuild-plugin-replace';
|
|
2
|
-
import minimist from 'minimist';
|
|
3
|
-
import type { Options } from 'tsup';
|
|
4
|
-
|
|
5
|
-
import pkg from './package.json';
|
|
6
|
-
|
|
7
|
-
const args = minimist(process.argv.slice(2));
|
|
8
|
-
const watch = process.env.WATCH;
|
|
9
|
-
const sourceMap = args.sourcemap || args.s;
|
|
10
|
-
|
|
11
|
-
export const tsup: Options = {
|
|
12
|
-
entry: [
|
|
13
|
-
'src/index.ts',
|
|
14
|
-
'src/react/index.ts',
|
|
15
|
-
'src/cli/index.ts',
|
|
16
|
-
'src/cli/babel.ts',
|
|
17
|
-
'src/universal/index.ts',
|
|
18
|
-
'src/plugin.ts',
|
|
19
|
-
'src/shared/index.ts',
|
|
20
|
-
],
|
|
21
|
-
sourcemap: sourceMap,
|
|
22
|
-
clean: true,
|
|
23
|
-
dts: true,
|
|
24
|
-
watch: watch ? 'src/' : false,
|
|
25
|
-
format: ['esm', 'cjs'],
|
|
26
|
-
legacyOutput: true,
|
|
27
|
-
esbuildPlugins: [
|
|
28
|
-
replace({
|
|
29
|
-
__VERSION__: `'${pkg.version}'`,
|
|
30
|
-
__DEV__:
|
|
31
|
-
'(typeof process !== "undefined" && process.env && process.env.NODE_ENV ? (process.env.NODE_ENV !== "production") : false)',
|
|
32
|
-
__TEST__: 'false',
|
|
33
|
-
}),
|
|
34
|
-
],
|
|
35
|
-
};
|