@module-federation/data-prefetch 2.3.1 → 2.3.2
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/README.md +2 -2
- package/dist/cli/index.cjs +12 -12
- package/dist/cli/index.js +11 -11
- package/dist/common/node-utils.cjs +4 -4
- package/dist/common/node-utils.js +3 -3
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Deprecated
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package has been deprecated, please use [data solution](https://module-federation.io/guide/basic/data-fetch.html)
|
package/dist/cli/index.cjs
CHANGED
|
@@ -60,9 +60,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
60
60
|
;// CONCATENATED MODULE: external "path"
|
|
61
61
|
const external_path_namespaceObject = require("path");
|
|
62
62
|
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
|
|
63
|
-
;// CONCATENATED MODULE: external "fs
|
|
64
|
-
const
|
|
65
|
-
var
|
|
63
|
+
;// CONCATENATED MODULE: external "fs"
|
|
64
|
+
const external_fs_namespaceObject = require("fs");
|
|
65
|
+
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
|
|
66
66
|
;// CONCATENATED MODULE: external "@module-federation/sdk"
|
|
67
67
|
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
68
68
|
;// CONCATENATED MODULE: external "@module-federation/sdk/normalize-webpack-path"
|
|
@@ -109,7 +109,7 @@ class PrefetchPlugin {
|
|
|
109
109
|
}
|
|
110
110
|
const runtimePluginFile = process.env.IS_ESM_BUILD === 'true' ? '../plugin.js' : '../plugin.cjs';
|
|
111
111
|
const runtimePath = external_path_default().resolve(__dirname, runtimePluginFile);
|
|
112
|
-
if (!
|
|
112
|
+
if (!external_fs_default().existsSync(runtimePath)) {
|
|
113
113
|
throw new Error(`[Module Federation Data Prefetch]: Unable to resolve runtime plugin file at ${runtimePath}.`);
|
|
114
114
|
}
|
|
115
115
|
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) === null || _this_options_runtimePlugins === void 0 ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
|
|
@@ -121,8 +121,8 @@ class PrefetchPlugin {
|
|
|
121
121
|
}
|
|
122
122
|
const encodedName = (0,sdk_namespaceObject.encodeName)(name);
|
|
123
123
|
const asyncEntryPath = external_path_default().resolve(compiler.options.context, `node_modules/${constant_cjs_namespaceObject.TEMP_DIR}/${encodedName}/bootstrap.js`);
|
|
124
|
-
if (
|
|
125
|
-
|
|
124
|
+
if (external_fs_default().existsSync(asyncEntryPath)) {
|
|
125
|
+
external_fs_default().unlinkSync(asyncEntryPath);
|
|
126
126
|
}
|
|
127
127
|
// @ts-ignore
|
|
128
128
|
if (!this.options.dataPrefetch) {
|
|
@@ -154,13 +154,13 @@ class PrefetchPlugin {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
const tempDirRealPath = external_path_default().resolve(compiler.options.context, 'node_modules', constant_cjs_namespaceObject.TEMP_DIR);
|
|
157
|
-
if (!
|
|
158
|
-
|
|
157
|
+
if (!external_fs_default().existsSync(tempDirRealPath)) {
|
|
158
|
+
external_fs_default().mkdirSync(tempDirRealPath);
|
|
159
159
|
}
|
|
160
|
-
if (!
|
|
161
|
-
|
|
160
|
+
if (!external_fs_default().existsSync(`${tempDirRealPath}/${encodedName}`)) {
|
|
161
|
+
external_fs_default().mkdirSync(`${tempDirRealPath}/${encodedName}`);
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
external_fs_default().writeFileSync(asyncEntryPath, this._reWriteExports);
|
|
164
164
|
new compiler.webpack.DefinePlugin({
|
|
165
165
|
FederationDataPrefetch: JSON.stringify(asyncEntryPath)
|
|
166
166
|
}).apply(compiler);
|
|
@@ -173,7 +173,7 @@ class PrefetchPlugin {
|
|
|
173
173
|
const prefetchEntry = external_path_default().resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);
|
|
174
174
|
const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
175
175
|
return Template.asString([
|
|
176
|
-
|
|
176
|
+
external_fs_default().existsSync(prefetchEntry) ? Template.indent([
|
|
177
177
|
'function injectPrefetch() {',
|
|
178
178
|
Template.indent([
|
|
179
179
|
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import
|
|
2
|
+
import fs from "fs";
|
|
3
3
|
import { MFPrefetchCommon, bindLoggerToCompiler, createInfrastructureLogger, createLogger, encodeName } from "@module-federation/sdk";
|
|
4
4
|
import { normalizeWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
|
|
5
5
|
import { TEMP_DIR } from "../common/constant.js";
|
|
@@ -9,7 +9,7 @@ import { SHARED_STRATEGY } from "../constant.js";
|
|
|
9
9
|
|
|
10
10
|
;// CONCATENATED MODULE: external "path"
|
|
11
11
|
|
|
12
|
-
;// CONCATENATED MODULE: external "fs
|
|
12
|
+
;// CONCATENATED MODULE: external "fs"
|
|
13
13
|
|
|
14
14
|
;// CONCATENATED MODULE: external "@module-federation/sdk"
|
|
15
15
|
|
|
@@ -57,7 +57,7 @@ class PrefetchPlugin {
|
|
|
57
57
|
}
|
|
58
58
|
const runtimePluginFile = process.env.IS_ESM_BUILD === 'true' ? '../plugin.js' : '../plugin.cjs';
|
|
59
59
|
const runtimePath = path.resolve(__dirname, runtimePluginFile);
|
|
60
|
-
if (!
|
|
60
|
+
if (!fs.existsSync(runtimePath)) {
|
|
61
61
|
throw new Error(`[Module Federation Data Prefetch]: Unable to resolve runtime plugin file at ${runtimePath}.`);
|
|
62
62
|
}
|
|
63
63
|
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) === null || _this_options_runtimePlugins === void 0 ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
|
|
@@ -69,8 +69,8 @@ class PrefetchPlugin {
|
|
|
69
69
|
}
|
|
70
70
|
const encodedName = encodeName(name);
|
|
71
71
|
const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);
|
|
72
|
-
if (
|
|
73
|
-
|
|
72
|
+
if (fs.existsSync(asyncEntryPath)) {
|
|
73
|
+
fs.unlinkSync(asyncEntryPath);
|
|
74
74
|
}
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
if (!this.options.dataPrefetch) {
|
|
@@ -102,13 +102,13 @@ class PrefetchPlugin {
|
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
const tempDirRealPath = path.resolve(compiler.options.context, 'node_modules', TEMP_DIR);
|
|
105
|
-
if (!
|
|
106
|
-
|
|
105
|
+
if (!fs.existsSync(tempDirRealPath)) {
|
|
106
|
+
fs.mkdirSync(tempDirRealPath);
|
|
107
107
|
}
|
|
108
|
-
if (!
|
|
109
|
-
|
|
108
|
+
if (!fs.existsSync(`${tempDirRealPath}/${encodedName}`)) {
|
|
109
|
+
fs.mkdirSync(`${tempDirRealPath}/${encodedName}`);
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
fs.writeFileSync(asyncEntryPath, this._reWriteExports);
|
|
112
112
|
new compiler.webpack.DefinePlugin({
|
|
113
113
|
FederationDataPrefetch: JSON.stringify(asyncEntryPath)
|
|
114
114
|
}).apply(compiler);
|
|
@@ -121,7 +121,7 @@ class PrefetchPlugin {
|
|
|
121
121
|
const prefetchEntry = path.resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);
|
|
122
122
|
const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
123
123
|
return Template.asString([
|
|
124
|
-
|
|
124
|
+
fs.existsSync(prefetchEntry) ? Template.indent([
|
|
125
125
|
'function injectPrefetch() {',
|
|
126
126
|
Template.indent([
|
|
127
127
|
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
@@ -60,9 +60,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
60
60
|
;// CONCATENATED MODULE: external "path"
|
|
61
61
|
const external_path_namespaceObject = require("path");
|
|
62
62
|
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
|
|
63
|
-
;// CONCATENATED MODULE: external "fs
|
|
64
|
-
const
|
|
65
|
-
var
|
|
63
|
+
;// CONCATENATED MODULE: external "fs"
|
|
64
|
+
const external_fs_namespaceObject = require("fs");
|
|
65
|
+
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
|
|
66
66
|
;// CONCATENATED MODULE: ./src/common/node-utils.ts
|
|
67
67
|
|
|
68
68
|
|
|
@@ -71,7 +71,7 @@ const fileExistsWithCaseSync = (filepath)=>{
|
|
|
71
71
|
if (filepath === '/' || filepath === '.') {
|
|
72
72
|
return true;
|
|
73
73
|
}
|
|
74
|
-
const filenames =
|
|
74
|
+
const filenames = external_fs_default().readdirSync(dir);
|
|
75
75
|
if (filenames.indexOf(external_path_default().basename(filepath)) === -1) {
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import
|
|
2
|
+
import fs from "fs";
|
|
3
3
|
|
|
4
4
|
;// CONCATENATED MODULE: external "path"
|
|
5
5
|
|
|
6
|
-
;// CONCATENATED MODULE: external "fs
|
|
6
|
+
;// CONCATENATED MODULE: external "fs"
|
|
7
7
|
|
|
8
8
|
;// CONCATENATED MODULE: ./src/common/node-utils.ts
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ const fileExistsWithCaseSync = (filepath)=>{
|
|
|
13
13
|
if (filepath === '/' || filepath === '.') {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
|
-
const filenames =
|
|
16
|
+
const filenames = fs.readdirSync(dir);
|
|
17
17
|
if (filenames.indexOf(path.basename(filepath)) === -1) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
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": "2.3.
|
|
4
|
+
"version": "2.3.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "nieyan <nyqykk@foxmail.com>",
|
|
7
7
|
"homepage": "https://github.com/module-federation/core",
|
|
@@ -107,7 +107,6 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@testing-library/react-hooks": "^8.0.1",
|
|
110
|
-
"@types/fs-extra": "9.0.13",
|
|
111
110
|
"@types/jest": "^29.5.11",
|
|
112
111
|
"@types/node": "^20.19.5",
|
|
113
112
|
"@types/react": "~18.0.38",
|
|
@@ -122,9 +121,8 @@
|
|
|
122
121
|
"@module-federation/webpack-type": "0.0.1"
|
|
123
122
|
},
|
|
124
123
|
"dependencies": {
|
|
125
|
-
"
|
|
126
|
-
"@module-federation/
|
|
127
|
-
"@module-federation/sdk": "2.3.1"
|
|
124
|
+
"@module-federation/runtime": "2.3.2",
|
|
125
|
+
"@module-federation/sdk": "2.3.2"
|
|
128
126
|
},
|
|
129
127
|
"scripts": {
|
|
130
128
|
"test": "jest",
|