@module-federation/modern-js 2.3.1 → 2.3.3

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.
@@ -40,8 +40,8 @@ __webpack_require__.d(__webpack_exports__, {
40
40
  });
41
41
  const external_path_namespaceObject = require("path");
42
42
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
43
- const external_fs_extra_namespaceObject = require("fs-extra");
44
- var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
43
+ const external_fs_namespaceObject = require("fs");
44
+ var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
45
45
  const enhanced_namespaceObject = require("@module-federation/enhanced");
46
46
  const rspack_namespaceObject = require("@module-federation/enhanced/rspack");
47
47
  const universe_entry_chunk_tracker_plugin_namespaceObject = require("@module-federation/node/universe-entry-chunk-tracker-plugin");
@@ -246,11 +246,11 @@ const moduleFederationSSRPlugin = (pluginOptions)=>({
246
246
  var _req_url, _req_url1;
247
247
  if ((null == (_req_url = req.url) ? void 0 : _req_url.includes('.json')) && !(null == (_req_url1 = req.url) ? void 0 : _req_url1.includes('hot-update'))) {
248
248
  const filepath = external_path_default().join(process.cwd(), `dist${req.url}`);
249
- external_fs_extra_default().statSync(filepath);
249
+ external_fs_default().statSync(filepath);
250
250
  res.setHeader('Access-Control-Allow-Origin', '*');
251
251
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
252
252
  res.setHeader('Access-Control-Allow-Headers', '*');
253
- external_fs_extra_default().createReadStream(filepath).pipe(res);
253
+ external_fs_default().createReadStream(filepath).pipe(res);
254
254
  } else next();
255
255
  } catch (err) {
256
256
  external_logger_js_default().debug(err);
@@ -1,14 +1,5 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
3
  (()=>{
13
4
  __webpack_require__.d = (exports1, definition)=>{
14
5
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
@@ -36,21 +27,28 @@ __webpack_require__.d(__webpack_exports__, {
36
27
  FileCache: ()=>FileCache,
37
28
  fileCache: ()=>fileCache
38
29
  });
39
- const external_fs_extra_namespaceObject = require("fs-extra");
40
- var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
30
+ const promises_namespaceObject = require("fs/promises");
41
31
  const external_lru_cache_namespaceObject = require("lru-cache");
32
+ const pathExists = async (filepath)=>{
33
+ try {
34
+ await (0, promises_namespaceObject.access)(filepath);
35
+ return true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ };
42
40
  class FileCache {
43
41
  async getFile(filepath) {
44
- if (!await external_fs_extra_default().pathExists(filepath)) return null;
42
+ if (!await pathExists(filepath)) return null;
45
43
  try {
46
- const stat = await external_fs_extra_default().lstat(filepath);
44
+ const stat = await (0, promises_namespaceObject.lstat)(filepath);
47
45
  const currentModified = stat.mtimeMs;
48
46
  const cachedEntry = this.cache.get(filepath);
49
47
  if (cachedEntry && currentModified <= cachedEntry.lastModified) return {
50
48
  content: cachedEntry.content,
51
49
  lastModified: cachedEntry.lastModified
52
50
  };
53
- const content = await external_fs_extra_default().readFile(filepath, 'utf-8');
51
+ const content = await (0, promises_namespaceObject.readFile)(filepath, 'utf-8');
54
52
  const newEntry = {
55
53
  content,
56
54
  lastModified: currentModified
@@ -36,11 +36,18 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  createStaticMiddleware: ()=>createStaticMiddleware,
37
37
  createCorsMiddleware: ()=>createCorsMiddleware
38
38
  });
39
- const external_fs_extra_namespaceObject = require("fs-extra");
40
- var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
39
+ const promises_namespaceObject = require("fs/promises");
41
40
  const external_path_namespaceObject = require("path");
42
41
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
43
42
  const external_fileCache_js_namespaceObject = require("./fileCache.js");
43
+ const pathExists = async (filepath)=>{
44
+ try {
45
+ await (0, promises_namespaceObject.access)(filepath);
46
+ return true;
47
+ } catch {
48
+ return false;
49
+ }
50
+ };
44
51
  const bundlesAssetPrefix = '/bundles';
45
52
  const removeHost = (url)=>{
46
53
  try {
@@ -62,7 +69,7 @@ const createStaticMiddleware = (options)=>{
62
69
  if (!pathname.startsWith(prefixWithBundle)) return next();
63
70
  const pathnameWithoutPrefix = pathname.replace(prefixWithBundle, '');
64
71
  const filepath = external_path_default().join(pwd, bundlesAssetPrefix, pathnameWithoutPrefix);
65
- if (!await external_fs_extra_default().pathExists(filepath)) return next();
72
+ if (!await pathExists(filepath)) return next();
66
73
  const fileResult = await external_fileCache_js_namespaceObject.fileCache.getFile(filepath);
67
74
  if (!fileResult) return next();
68
75
  c.header('Content-Type', "application/javascript");
@@ -3,7 +3,7 @@ import { _ as _instanceof__ } from "@swc/helpers/_/_instanceof";
3
3
  import { _ as _type_of__ } from "@swc/helpers/_/_type_of";
4
4
  import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
5
5
  import path from "path";
6
- import fs_extra from "fs-extra";
6
+ import fs from "fs";
7
7
  import { ModuleFederationPlugin, TreeShakingSharedPlugin as enhanced_TreeShakingSharedPlugin } from "@module-federation/enhanced";
8
8
  import { ModuleFederationPlugin as rspack_ModuleFederationPlugin, TreeShakingSharedPlugin as rspack_TreeShakingSharedPlugin } from "@module-federation/enhanced/rspack";
9
9
  import universe_entry_chunk_tracker_plugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
@@ -221,11 +221,11 @@ var ssrPlugin_moduleFederationSSRPlugin = function(pluginOptions) {
221
221
  var _req_url, _req_url1;
222
222
  if ((null == (_req_url = req.url) ? void 0 : _req_url.includes('.json')) && !(null == (_req_url1 = req.url) ? void 0 : _req_url1.includes('hot-update'))) {
223
223
  var filepath = path.join(process.cwd(), "dist".concat(req.url));
224
- fs_extra.statSync(filepath);
224
+ fs.statSync(filepath);
225
225
  res.setHeader('Access-Control-Allow-Origin', '*');
226
226
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
227
227
  res.setHeader('Access-Control-Allow-Headers', '*');
228
- fs_extra.createReadStream(filepath).pipe(res);
228
+ fs.createReadStream(filepath).pipe(res);
229
229
  } else next();
230
230
  } catch (err) {
231
231
  logger.debug(err);
@@ -1,8 +1,43 @@
1
1
  import { _ } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _class_call_check__ } from "@swc/helpers/_/_class_call_check";
3
3
  import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
4
- import fs_extra from "fs-extra";
4
+ import { access, lstat, readFile } from "fs/promises";
5
5
  import { LRUCache } from "lru-cache";
6
+ var fileCache_pathExists = function(filepath) {
7
+ return _(function() {
8
+ return _ts_generator__(this, function(_state) {
9
+ switch(_state.label){
10
+ case 0:
11
+ _state.trys.push([
12
+ 0,
13
+ 2,
14
+ ,
15
+ 3
16
+ ]);
17
+ return [
18
+ 4,
19
+ access(filepath)
20
+ ];
21
+ case 1:
22
+ _state.sent();
23
+ return [
24
+ 2,
25
+ true
26
+ ];
27
+ case 2:
28
+ _state.sent();
29
+ return [
30
+ 2,
31
+ false
32
+ ];
33
+ case 3:
34
+ return [
35
+ 2
36
+ ];
37
+ }
38
+ });
39
+ })();
40
+ };
6
41
  var fileCache_FileCache = /*#__PURE__*/ function() {
7
42
  "use strict";
8
43
  function FileCache() {
@@ -20,7 +55,7 @@ var fileCache_FileCache = /*#__PURE__*/ function() {
20
55
  case 0:
21
56
  return [
22
57
  4,
23
- fs_extra.pathExists(filepath)
58
+ fileCache_pathExists(filepath)
24
59
  ];
25
60
  case 1:
26
61
  if (!_state.sent()) return [
@@ -37,7 +72,7 @@ var fileCache_FileCache = /*#__PURE__*/ function() {
37
72
  ]);
38
73
  return [
39
74
  4,
40
- fs_extra.lstat(filepath)
75
+ lstat(filepath)
41
76
  ];
42
77
  case 3:
43
78
  stat = _state.sent();
@@ -52,7 +87,7 @@ var fileCache_FileCache = /*#__PURE__*/ function() {
52
87
  ];
53
88
  return [
54
89
  4,
55
- fs_extra.readFile(filepath, 'utf-8')
90
+ readFile(filepath, 'utf-8')
56
91
  ];
57
92
  case 4:
58
93
  content = _state.sent();
@@ -1,8 +1,43 @@
1
1
  import { _ } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
3
- import fs_extra from "fs-extra";
3
+ import { access } from "fs/promises";
4
4
  import path from "path";
5
5
  import { fileCache } from "./fileCache.mjs";
6
+ var staticMiddleware_pathExists = function(filepath) {
7
+ return _(function() {
8
+ return _ts_generator__(this, function(_state) {
9
+ switch(_state.label){
10
+ case 0:
11
+ _state.trys.push([
12
+ 0,
13
+ 2,
14
+ ,
15
+ 3
16
+ ]);
17
+ return [
18
+ 4,
19
+ access(filepath)
20
+ ];
21
+ case 1:
22
+ _state.sent();
23
+ return [
24
+ 2,
25
+ true
26
+ ];
27
+ case 2:
28
+ _state.sent();
29
+ return [
30
+ 2,
31
+ false
32
+ ];
33
+ case 3:
34
+ return [
35
+ 2
36
+ ];
37
+ }
38
+ });
39
+ })();
40
+ };
6
41
  var bundlesAssetPrefix = '/bundles';
7
42
  var staticMiddleware_removeHost = function(url) {
8
43
  try {
@@ -37,7 +72,7 @@ var staticMiddleware_createStaticMiddleware = function(options) {
37
72
  filepath = path.join(pwd, bundlesAssetPrefix, pathnameWithoutPrefix);
38
73
  return [
39
74
  4,
40
- fs_extra.pathExists(filepath)
75
+ staticMiddleware_pathExists(filepath)
41
76
  ];
42
77
  case 1:
43
78
  if (!_state.sent()) return [
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import fs_extra from "fs-extra";
2
+ import fs from "fs";
3
3
  import { ModuleFederationPlugin, TreeShakingSharedPlugin as enhanced_TreeShakingSharedPlugin } from "@module-federation/enhanced";
4
4
  import { ModuleFederationPlugin as rspack_ModuleFederationPlugin, TreeShakingSharedPlugin as rspack_TreeShakingSharedPlugin } from "@module-federation/enhanced/rspack";
5
5
  import universe_entry_chunk_tracker_plugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
@@ -202,11 +202,11 @@ const moduleFederationSSRPlugin = (pluginOptions)=>({
202
202
  var _req_url, _req_url1;
203
203
  if ((null == (_req_url = req.url) ? void 0 : _req_url.includes('.json')) && !(null == (_req_url1 = req.url) ? void 0 : _req_url1.includes('hot-update'))) {
204
204
  const filepath = path.join(process.cwd(), `dist${req.url}`);
205
- fs_extra.statSync(filepath);
205
+ fs.statSync(filepath);
206
206
  res.setHeader('Access-Control-Allow-Origin', '*');
207
207
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
208
208
  res.setHeader('Access-Control-Allow-Headers', '*');
209
- fs_extra.createReadStream(filepath).pipe(res);
209
+ fs.createReadStream(filepath).pipe(res);
210
210
  } else next();
211
211
  } catch (err) {
212
212
  logger.debug(err);
@@ -1,17 +1,25 @@
1
- import fs_extra from "fs-extra";
1
+ import { access, lstat, readFile } from "fs/promises";
2
2
  import { LRUCache } from "lru-cache";
3
+ const pathExists = async (filepath)=>{
4
+ try {
5
+ await access(filepath);
6
+ return true;
7
+ } catch {
8
+ return false;
9
+ }
10
+ };
3
11
  class FileCache {
4
12
  async getFile(filepath) {
5
- if (!await fs_extra.pathExists(filepath)) return null;
13
+ if (!await pathExists(filepath)) return null;
6
14
  try {
7
- const stat = await fs_extra.lstat(filepath);
15
+ const stat = await lstat(filepath);
8
16
  const currentModified = stat.mtimeMs;
9
17
  const cachedEntry = this.cache.get(filepath);
10
18
  if (cachedEntry && currentModified <= cachedEntry.lastModified) return {
11
19
  content: cachedEntry.content,
12
20
  lastModified: cachedEntry.lastModified
13
21
  };
14
- const content = await fs_extra.readFile(filepath, 'utf-8');
22
+ const content = await readFile(filepath, 'utf-8');
15
23
  const newEntry = {
16
24
  content,
17
25
  lastModified: currentModified
@@ -1,6 +1,14 @@
1
- import fs_extra from "fs-extra";
1
+ import { access } from "fs/promises";
2
2
  import path from "path";
3
3
  import { fileCache } from "./fileCache.mjs";
4
+ const pathExists = async (filepath)=>{
5
+ try {
6
+ await access(filepath);
7
+ return true;
8
+ } catch {
9
+ return false;
10
+ }
11
+ };
4
12
  const bundlesAssetPrefix = '/bundles';
5
13
  const removeHost = (url)=>{
6
14
  try {
@@ -22,7 +30,7 @@ const createStaticMiddleware = (options)=>{
22
30
  if (!pathname.startsWith(prefixWithBundle)) return next();
23
31
  const pathnameWithoutPrefix = pathname.replace(prefixWithBundle, '');
24
32
  const filepath = path.join(pwd, bundlesAssetPrefix, pathnameWithoutPrefix);
25
- if (!await fs_extra.pathExists(filepath)) return next();
33
+ if (!await pathExists(filepath)) return next();
26
34
  const fileResult = await fileCache.getFile(filepath);
27
35
  if (!fileResult) return next();
28
36
  c.header('Content-Type', "application/javascript");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -126,19 +126,18 @@
126
126
  "license": "MIT",
127
127
  "dependencies": {
128
128
  "@modern-js/utils": "2.70.5",
129
- "fs-extra": "11.3.0",
130
129
  "lru-cache": "10.4.3",
131
- "@swc/helpers": "^0.5.17",
132
- "node-fetch": "~3.3.0",
130
+ "@swc/helpers": "0.5.17",
131
+ "node-fetch": "3.3.0",
133
132
  "jiti": "2.4.2",
134
133
  "react-error-boundary": "4.1.2",
135
- "@module-federation/rsbuild-plugin": "2.3.1",
136
- "@module-federation/enhanced": "2.3.1",
137
- "@module-federation/runtime": "2.3.1",
138
- "@module-federation/node": "2.7.39",
139
- "@module-federation/cli": "2.3.1",
140
- "@module-federation/bridge-react": "2.3.1",
141
- "@module-federation/sdk": "2.3.1"
134
+ "@module-federation/rsbuild-plugin": "2.3.3",
135
+ "@module-federation/enhanced": "2.3.3",
136
+ "@module-federation/runtime": "2.3.3",
137
+ "@module-federation/bridge-react": "2.3.3",
138
+ "@module-federation/sdk": "2.3.3",
139
+ "@module-federation/cli": "2.3.3",
140
+ "@module-federation/node": "2.7.41"
142
141
  },
143
142
  "devDependencies": {
144
143
  "@rsbuild/plugin-react": "1.4.5",
@@ -152,7 +151,7 @@
152
151
  "@types/react": "^18.3.11",
153
152
  "@types/react-dom": "^18.3.0",
154
153
  "vitest": "1.6.0",
155
- "@module-federation/manifest": "2.3.1"
154
+ "@module-federation/manifest": "2.3.3"
156
155
  },
157
156
  "peerDependencies": {
158
157
  "react": ">=17",