@module-federation/data-prefetch 0.0.0-next-20241009072306 → 0.0.0-next-20241009075733
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 +4 -3
- package/dist/cli.cjs.js +5 -4
- package/dist/cli.esm.js +5 -4
- package/dist/package.json +0 -12
- package/package.json +3 -15
- package/rollup.config.js +0 -1
- package/src/cli/index.ts +6 -3
- package/dist/shared.cjs.d.ts +0 -2
- package/dist/shared.cjs.js +0 -16
- package/dist/shared.esm.d.ts +0 -2
- package/dist/shared.esm.js +0 -14
- package/dist/src/shared/index.d.ts +0 -3
- package/src/shared/index.ts +0 -18
- package/tsup.config.ts +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# @module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20241009075733
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- 5364c07: fix(data-prefetch): apply DataPrefetchPlugin on demand
|
|
8
|
+
- 026c308: fix(data-prefetch): set sharedStrategy in build options instead of using runtime plugin
|
|
8
9
|
- Updated dependencies [b704f30]
|
|
9
10
|
- Updated dependencies [5364c07]
|
|
10
|
-
- @module-federation/runtime@0.0.0-next-
|
|
11
|
-
- @module-federation/sdk@0.0.0-next-
|
|
11
|
+
- @module-federation/runtime@0.0.0-next-20241009075733
|
|
12
|
+
- @module-federation/sdk@0.0.0-next-20241009075733
|
|
12
13
|
|
|
13
14
|
## 0.6.9
|
|
14
15
|
|
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/package.json
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
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/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-20241009075733",
|
|
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.0.0-next-
|
|
92
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
81
|
+
"@module-federation/runtime": "0.0.0-next-20241009075733",
|
|
82
|
+
"@module-federation/sdk": "0.0.0-next-20241009075733"
|
|
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/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/dist/shared.cjs.d.ts
DELETED
package/dist/shared.cjs.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var constant = require('./constant.cjs.js');
|
|
4
|
-
|
|
5
|
-
const sharedStrategy = ()=>({
|
|
6
|
-
name: 'shared-strategy',
|
|
7
|
-
beforeInit (args) {
|
|
8
|
-
if (args.options.shareStrategy == constant.SHARED_STRATEGY) {
|
|
9
|
-
args.options.shareStrategy = 'loaded-first';
|
|
10
|
-
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
|
|
11
|
-
}
|
|
12
|
-
return args;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
module.exports = sharedStrategy;
|
package/dist/shared.esm.d.ts
DELETED
package/dist/shared.esm.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { S as SHARED_STRATEGY } from './constant.esm.js';
|
|
2
|
-
|
|
3
|
-
const sharedStrategy = ()=>({
|
|
4
|
-
name: 'shared-strategy',
|
|
5
|
-
beforeInit (args) {
|
|
6
|
-
if (args.options.shareStrategy == SHARED_STRATEGY) {
|
|
7
|
-
args.options.shareStrategy = 'loaded-first';
|
|
8
|
-
console.warn(`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`);
|
|
9
|
-
}
|
|
10
|
-
return args;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export { sharedStrategy as default };
|
package/src/shared/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { FederationRuntimePlugin } from '@module-federation/runtime';
|
|
2
|
-
import { SHARED_STRATEGY } from '../constant';
|
|
3
|
-
|
|
4
|
-
const sharedStrategy: () => FederationRuntimePlugin = () => ({
|
|
5
|
-
name: 'shared-strategy',
|
|
6
|
-
beforeInit(args) {
|
|
7
|
-
const { userOptions } = args;
|
|
8
|
-
if (args.options.shareStrategy! == SHARED_STRATEGY) {
|
|
9
|
-
args.options.shareStrategy = 'loaded-first';
|
|
10
|
-
console.warn(
|
|
11
|
-
`[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch`,
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
return args;
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
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
|
-
};
|