@module-federation/data-prefetch 0.0.0-next-20241009072306 → 0.0.0-next-20241009081924
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 +3 -5
- package/dist/index.cjs.js +0 -1
- package/dist/index.esm.js +0 -1
- package/dist/plugin.cjs.js +4 -4
- package/dist/plugin.esm.js +4 -4
- package/dist/shared.cjs.js +12 -4
- package/dist/shared.esm.js +12 -4
- package/package.json +3 -3
- package/src/plugin.ts +4 -4
- package/src/shared/index.ts +11 -3
- package/dist/constant.cjs.js +0 -5
- package/dist/constant.esm.js +0 -3
- package/dist/src/constant.d.ts +0 -1
- package/src/constant.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
# @module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20241009081924
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- 5364c07: fix(data-prefetch): apply DataPrefetchPlugin on demand
|
|
8
7
|
- Updated dependencies [b704f30]
|
|
9
|
-
-
|
|
10
|
-
- @module-federation/
|
|
11
|
-
- @module-federation/sdk@0.0.0-next-20241009072306
|
|
8
|
+
- @module-federation/runtime@0.0.0-next-20241009081924
|
|
9
|
+
- @module-federation/sdk@0.0.0-next-20241009081924
|
|
12
10
|
|
|
13
11
|
## 0.6.9
|
|
14
12
|
|
package/dist/index.cjs.js
CHANGED
package/dist/index.esm.js
CHANGED
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');
|
|
10
9
|
require('@module-federation/runtime');
|
|
11
10
|
|
|
12
11
|
const loadingArray = [];
|
|
13
|
-
|
|
12
|
+
const strategy = 'loaded-first';
|
|
13
|
+
let sharedFlag = 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 !== 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 !== 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';
|
|
6
5
|
import '@module-federation/runtime';
|
|
7
6
|
|
|
8
7
|
const loadingArray = [];
|
|
9
|
-
|
|
8
|
+
const strategy = 'loaded-first';
|
|
9
|
+
let sharedFlag = 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 !== 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 !== 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);
|
package/dist/shared.cjs.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var constant = require('./constant.cjs.js');
|
|
4
|
-
|
|
5
3
|
const sharedStrategy = ()=>({
|
|
6
4
|
name: 'shared-strategy',
|
|
7
5
|
beforeInit (args) {
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
});
|
|
10
18
|
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
|
|
11
19
|
}
|
|
12
20
|
return args;
|
package/dist/shared.esm.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { S as SHARED_STRATEGY } from './constant.esm.js';
|
|
2
|
-
|
|
3
1
|
const sharedStrategy = ()=>({
|
|
4
2
|
name: 'shared-strategy',
|
|
5
3
|
beforeInit (args) {
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
});
|
|
8
16
|
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
|
|
9
17
|
}
|
|
10
18
|
return args;
|
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.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20241009081924",
|
|
5
5
|
"author": "nieyan <nyqykk@foxmail.com>",
|
|
6
6
|
"homepage": "https://github.com/module-federation/core",
|
|
7
7
|
"license": "MIT",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"fs-extra": "9.1.0",
|
|
91
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
92
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
91
|
+
"@module-federation/runtime": "0.0.0-next-20241009081924",
|
|
92
|
+
"@module-federation/sdk": "0.0.0-next-20241009081924"
|
|
93
93
|
},
|
|
94
94
|
"scripts": {
|
|
95
95
|
"dev": "cross-env WATCH=true tsup",
|
package/src/plugin.ts
CHANGED
|
@@ -4,7 +4,6 @@ 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';
|
|
8
7
|
|
|
9
8
|
interface Loading {
|
|
10
9
|
id: string;
|
|
@@ -16,7 +15,8 @@ interface Loading {
|
|
|
16
15
|
>;
|
|
17
16
|
}
|
|
18
17
|
const loadingArray: Array<Loading> = [];
|
|
19
|
-
|
|
18
|
+
const strategy = 'loaded-first';
|
|
19
|
+
let sharedFlag = 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 !== 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 !== 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/src/shared/index.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { FederationRuntimePlugin } from '@module-federation/runtime';
|
|
2
|
-
import { SHARED_STRATEGY } from '../constant';
|
|
3
2
|
|
|
4
3
|
const sharedStrategy: () => FederationRuntimePlugin = () => ({
|
|
5
4
|
name: 'shared-strategy',
|
|
6
5
|
beforeInit(args) {
|
|
7
6
|
const { userOptions } = args;
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
});
|
|
10
18
|
console.warn(
|
|
11
19
|
`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`,
|
|
12
20
|
);
|
package/dist/constant.cjs.js
DELETED
package/dist/constant.esm.js
DELETED
package/dist/src/constant.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SHARED_STRATEGY = "loaded-first";
|
package/src/constant.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SHARED_STRATEGY = 'loaded-first';
|