@module-federation/modern-js 0.0.0-next-20240520070201 → 0.0.0-next-20240520072517

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.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var inject_node_fetch_exports = {};
30
+ __export(inject_node_fetch_exports, {
31
+ default: () => inject_node_fetch_default
32
+ });
33
+ module.exports = __toCommonJS(inject_node_fetch_exports);
34
+ var import_node_fetch = __toESM(require("node-fetch"));
35
+ const injectNodeFetchPlugin = () => ({
36
+ name: "inject-node-fetch-plugin",
37
+ beforeInit(args) {
38
+ if (!globalThis.fetch) {
39
+ globalThis.fetch = import_node_fetch.default;
40
+ }
41
+ return args;
42
+ }
43
+ });
44
+ var inject_node_fetch_default = injectNodeFetchPlugin;
@@ -51,14 +51,21 @@ const patchMFConfig = (mfConfig, isServer) => {
51
51
  const runtimePlugins = [
52
52
  ...mfConfig.runtimePlugins || []
53
53
  ];
54
- const runtimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
55
- if (!runtimePlugins.includes(runtimePluginPath)) {
56
- runtimePlugins.push(import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"));
54
+ const sharedStrategyRuntimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
55
+ if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
56
+ runtimePlugins.push(sharedStrategyRuntimePluginPath);
57
57
  }
58
58
  if (isServer) {
59
- const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
60
- if (!runtimePlugins.includes(nodeHmrPluginPath)) {
61
- runtimePlugins.push(nodeHmrPluginPath);
59
+ const isDev = process.env.NODE_ENV === "development";
60
+ if (isDev) {
61
+ const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
62
+ if (!runtimePlugins.includes(nodeHmrPluginPath)) {
63
+ runtimePlugins.push(nodeHmrPluginPath);
64
+ }
65
+ }
66
+ const injectNodeFetchRuntimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
67
+ if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
68
+ runtimePlugins.push(injectNodeFetchRuntimePluginPath);
62
69
  }
63
70
  }
64
71
  if (typeof mfConfig.async === "undefined") {
@@ -0,0 +1,16 @@
1
+ import nodeFetch from "node-fetch";
2
+ var injectNodeFetchPlugin = function() {
3
+ return {
4
+ name: "inject-node-fetch-plugin",
5
+ beforeInit: function beforeInit(args) {
6
+ if (!globalThis.fetch) {
7
+ globalThis.fetch = nodeFetch;
8
+ }
9
+ return args;
10
+ }
11
+ };
12
+ };
13
+ var inject_node_fetch_default = injectNodeFetchPlugin;
14
+ export {
15
+ inject_node_fetch_default as default
16
+ };
@@ -45,14 +45,21 @@ var getMFConfig = function() {
45
45
  }();
46
46
  var patchMFConfig = function(mfConfig, isServer) {
47
47
  var runtimePlugins = _to_consumable_array(mfConfig.runtimePlugins || []);
48
- var runtimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
49
- if (!runtimePlugins.includes(runtimePluginPath)) {
50
- runtimePlugins.push(path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"));
48
+ var sharedStrategyRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
49
+ if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
50
+ runtimePlugins.push(sharedStrategyRuntimePluginPath);
51
51
  }
52
52
  if (isServer) {
53
- var nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
54
- if (!runtimePlugins.includes(nodeHmrPluginPath)) {
55
- runtimePlugins.push(nodeHmrPluginPath);
53
+ var isDev = process.env.NODE_ENV === "development";
54
+ if (isDev) {
55
+ var nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
56
+ if (!runtimePlugins.includes(nodeHmrPluginPath)) {
57
+ runtimePlugins.push(nodeHmrPluginPath);
58
+ }
59
+ }
60
+ var injectNodeFetchRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
61
+ if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
62
+ runtimePlugins.push(injectNodeFetchRuntimePluginPath);
56
63
  }
57
64
  }
58
65
  if (typeof mfConfig.async === "undefined") {
@@ -0,0 +1,14 @@
1
+ import nodeFetch from "node-fetch";
2
+ const injectNodeFetchPlugin = () => ({
3
+ name: "inject-node-fetch-plugin",
4
+ beforeInit(args) {
5
+ if (!globalThis.fetch) {
6
+ globalThis.fetch = nodeFetch;
7
+ }
8
+ return args;
9
+ }
10
+ });
11
+ var inject_node_fetch_default = injectNodeFetchPlugin;
12
+ export {
13
+ inject_node_fetch_default as default
14
+ };
@@ -15,14 +15,21 @@ const patchMFConfig = (mfConfig, isServer) => {
15
15
  const runtimePlugins = [
16
16
  ...mfConfig.runtimePlugins || []
17
17
  ];
18
- const runtimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
19
- if (!runtimePlugins.includes(runtimePluginPath)) {
20
- runtimePlugins.push(path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"));
18
+ const sharedStrategyRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
19
+ if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
20
+ runtimePlugins.push(sharedStrategyRuntimePluginPath);
21
21
  }
22
22
  if (isServer) {
23
- const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
24
- if (!runtimePlugins.includes(nodeHmrPluginPath)) {
25
- runtimePlugins.push(nodeHmrPluginPath);
23
+ const isDev = process.env.NODE_ENV === "development";
24
+ if (isDev) {
25
+ const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
26
+ if (!runtimePlugins.includes(nodeHmrPluginPath)) {
27
+ runtimePlugins.push(nodeHmrPluginPath);
28
+ }
29
+ }
30
+ const injectNodeFetchRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
31
+ if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
32
+ runtimePlugins.push(injectNodeFetchRuntimePluginPath);
26
33
  }
27
34
  }
28
35
  if (typeof mfConfig.async === "undefined") {
@@ -0,0 +1,3 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ declare const injectNodeFetchPlugin: () => FederationRuntimePlugin;
3
+ export default injectNodeFetchPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240520070201",
3
+ "version": "0.0.0-next-20240520072517",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -45,9 +45,10 @@
45
45
  "@swc/helpers": "0.5.3",
46
46
  "@modern-js/utils": "^2.49.2",
47
47
  "@modern-js/node-bundle-require": "^2.49.2",
48
- "@module-federation/sdk": "0.0.0-next-20240520070201",
49
- "@module-federation/enhanced": "0.0.0-next-20240520070201",
50
- "@module-federation/node": "0.0.0-next-20240520070201"
48
+ "node-fetch": "~3.3.0",
49
+ "@module-federation/sdk": "0.0.0-next-20240520072517",
50
+ "@module-federation/enhanced": "0.0.0-next-20240520072517",
51
+ "@module-federation/node": "0.0.0-next-20240520072517"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@modern-js/app-tools": "^2.49.2",
@@ -55,7 +56,7 @@
55
56
  "@modern-js/runtime": "^2.49.2",
56
57
  "@modern-js/module-tools": "^2.35.0",
57
58
  "@modern-js/tsconfig": "^2.35.0",
58
- "@module-federation/manifest": "0.0.0-next-20240520070201"
59
+ "@module-federation/manifest": "0.0.0-next-20240520072517"
59
60
  },
60
61
  "scripts": {
61
62
  "build": "modern build"