@module-federation/modern-js 0.0.0-next-20240725061440 → 0.0.0-next-20240726075341

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.
@@ -43,7 +43,7 @@ function setEnv(enableSSR) {
43
43
  }
44
44
  }
45
45
  function modifyBundlerConfig(options) {
46
- const { mfConfig, config, isServer, modernjsConfig, bundlerType, remoteIpStrategy = "ipv4" } = options;
46
+ const { mfConfig, config, isServer, modernjsConfig, remoteIpStrategy = "ipv4" } = options;
47
47
  (0, import_utils.patchMFConfig)(mfConfig, isServer, remoteIpStrategy);
48
48
  (0, import_utils.patchBundlerConfig)({
49
49
  bundlerConfig: config,
@@ -66,9 +66,17 @@ const moduleFederationConfigPlugin = (userConfig) => ({
66
66
  userConfig.csrConfig = csrConfig;
67
67
  return {
68
68
  config: async () => {
69
- var _modernjsConfig_dev;
69
+ var _modernjsConfig_server, _modernjsConfig_dev;
70
70
  const bundlerType = useAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
71
71
  const ipv4 = (0, import_utils.getIPV4)();
72
+ const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
73
+ if (userConfig.remoteIpStrategy === void 0) {
74
+ if (!enableSSR) {
75
+ userConfig.remoteIpStrategy = "inherit";
76
+ } else {
77
+ userConfig.remoteIpStrategy = "ipv4";
78
+ }
79
+ }
72
80
  return {
73
81
  tools: {
74
82
  rspack(config, { isServer }) {
@@ -23,7 +23,7 @@ __export(resolve_entry_ipv4_exports, {
23
23
  module.exports = __toCommonJS(resolve_entry_ipv4_exports);
24
24
  var import_constant = require("../../constant");
25
25
  const ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
26
- const remoteIpStrategy = typeof REMOTE_IP_STRATEGY !== "undefined" ? REMOTE_IP_STRATEGY : "127.0.0.1";
26
+ const remoteIpStrategy = typeof REMOTE_IP_STRATEGY !== "undefined" ? REMOTE_IP_STRATEGY : "inherit";
27
27
  function replaceObjectLocalhost(key, obj) {
28
28
  if (remoteIpStrategy !== "ipv4") {
29
29
  return;
@@ -9,7 +9,7 @@ function setEnv(enableSSR) {
9
9
  }
10
10
  }
11
11
  function modifyBundlerConfig(options) {
12
- var mfConfig = options.mfConfig, config = options.config, isServer = options.isServer, modernjsConfig = options.modernjsConfig, bundlerType = options.bundlerType, _options_remoteIpStrategy = options.remoteIpStrategy, remoteIpStrategy = _options_remoteIpStrategy === void 0 ? "ipv4" : _options_remoteIpStrategy;
12
+ var mfConfig = options.mfConfig, config = options.config, isServer = options.isServer, modernjsConfig = options.modernjsConfig, _options_remoteIpStrategy = options.remoteIpStrategy, remoteIpStrategy = _options_remoteIpStrategy === void 0 ? "ipv4" : _options_remoteIpStrategy;
13
13
  patchMFConfig(mfConfig, isServer, remoteIpStrategy);
14
14
  patchBundlerConfig({
15
15
  bundlerConfig: config,
@@ -46,10 +46,18 @@ var moduleFederationConfigPlugin = function(userConfig) {
46
46
  2,
47
47
  {
48
48
  config: /* @__PURE__ */ _async_to_generator(function() {
49
- var _modernjsConfig_dev, bundlerType, ipv4;
49
+ var _modernjsConfig_server, _modernjsConfig_dev, bundlerType, ipv4, enableSSR;
50
50
  return _ts_generator(this, function(_state2) {
51
51
  bundlerType = useAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
52
52
  ipv4 = getIPV4();
53
+ enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
54
+ if (userConfig.remoteIpStrategy === void 0) {
55
+ if (!enableSSR) {
56
+ userConfig.remoteIpStrategy = "inherit";
57
+ } else {
58
+ userConfig.remoteIpStrategy = "ipv4";
59
+ }
60
+ }
53
61
  return [
54
62
  2,
55
63
  {
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { LOCALHOST } from "../../constant";
4
4
  var ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
5
- var remoteIpStrategy = typeof REMOTE_IP_STRATEGY !== "undefined" ? REMOTE_IP_STRATEGY : "127.0.0.1";
5
+ var remoteIpStrategy = typeof REMOTE_IP_STRATEGY !== "undefined" ? REMOTE_IP_STRATEGY : "inherit";
6
6
  function replaceObjectLocalhost(key, obj) {
7
7
  if (remoteIpStrategy !== "ipv4") {
8
8
  return;
@@ -7,7 +7,7 @@ function setEnv(enableSSR) {
7
7
  }
8
8
  }
9
9
  function modifyBundlerConfig(options) {
10
- const { mfConfig, config, isServer, modernjsConfig, bundlerType, remoteIpStrategy = "ipv4" } = options;
10
+ const { mfConfig, config, isServer, modernjsConfig, remoteIpStrategy = "ipv4" } = options;
11
11
  patchMFConfig(mfConfig, isServer, remoteIpStrategy);
12
12
  patchBundlerConfig({
13
13
  bundlerConfig: config,
@@ -30,9 +30,17 @@ const moduleFederationConfigPlugin = (userConfig) => ({
30
30
  userConfig.csrConfig = csrConfig;
31
31
  return {
32
32
  config: async () => {
33
- var _modernjsConfig_dev;
33
+ var _modernjsConfig_server, _modernjsConfig_dev;
34
34
  const bundlerType = useAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
35
35
  const ipv4 = getIPV4();
36
+ const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
37
+ if (userConfig.remoteIpStrategy === void 0) {
38
+ if (!enableSSR) {
39
+ userConfig.remoteIpStrategy = "inherit";
40
+ } else {
41
+ userConfig.remoteIpStrategy = "ipv4";
42
+ }
43
+ }
36
44
  return {
37
45
  tools: {
38
46
  rspack(config, { isServer }) {
@@ -1,6 +1,6 @@
1
1
  import { LOCALHOST } from "../../constant";
2
2
  const ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
3
- const remoteIpStrategy = typeof REMOTE_IP_STRATEGY !== "undefined" ? REMOTE_IP_STRATEGY : "127.0.0.1";
3
+ const remoteIpStrategy = typeof REMOTE_IP_STRATEGY !== "undefined" ? REMOTE_IP_STRATEGY : "inherit";
4
4
  function replaceObjectLocalhost(key, obj) {
5
5
  if (remoteIpStrategy !== "ipv4") {
6
6
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240725061440",
3
+ "version": "0.0.0-next-20240726075341",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -61,9 +61,9 @@
61
61
  "node-fetch": "~3.3.0",
62
62
  "react-error-boundary": "4.0.13",
63
63
  "hoist-non-react-statics": "3.3.2",
64
- "@module-federation/sdk": "0.0.0-next-20240725061440",
65
- "@module-federation/enhanced": "0.0.0-next-20240725061440",
66
- "@module-federation/node": "0.0.0-next-20240725061440"
64
+ "@module-federation/sdk": "0.0.0-next-20240726075341",
65
+ "@module-federation/enhanced": "0.0.0-next-20240726075341",
66
+ "@module-federation/node": "0.0.0-next-20240726075341"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/hoist-non-react-statics": "3.3.2",
@@ -72,7 +72,7 @@
72
72
  "@modern-js/runtime": "2.56.2",
73
73
  "@modern-js/module-tools": "2.56.2",
74
74
  "@modern-js/tsconfig": "2.56.2",
75
- "@module-federation/manifest": "0.0.0-next-20240725061440"
75
+ "@module-federation/manifest": "0.0.0-next-20240726075341"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "react": ">=17",
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var RspackNodePlugin_exports = {};
20
- __export(RspackNodePlugin_exports, {
21
- default: () => RspackNodePlugin
22
- });
23
- module.exports = __toCommonJS(RspackNodePlugin_exports);
24
- class RspackNodePlugin {
25
- apply(compiler) {
26
- const { webpack } = compiler;
27
- compiler.options.output.chunkFormat = "commonjs";
28
- if (compiler.options.output.enabledLibraryTypes === void 0) {
29
- compiler.options.output.enabledLibraryTypes = [
30
- "commonjs-module"
31
- ];
32
- } else {
33
- compiler.options.output.enabledLibraryTypes.push("commonjs-module");
34
- }
35
- compiler.options.output.chunkLoading = "async-node";
36
- compiler.options.output.enabledChunkLoadingTypes = [];
37
- compiler.options.output.environment = {
38
- ...compiler.options.output.environment,
39
- dynamicImport: true
40
- };
41
- new webpack.node.NodeEnvironmentPlugin.apply(compiler);
42
- new webpack.node.NodeTargetPlugin().apply(compiler);
43
- }
44
- constructor() {
45
- }
46
- }
@@ -1,32 +0,0 @@
1
- import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- var RspackNodePlugin = /* @__PURE__ */ function() {
5
- "use strict";
6
- function RspackNodePlugin2() {
7
- _class_call_check(this, RspackNodePlugin2);
8
- }
9
- var _proto = RspackNodePlugin2.prototype;
10
- _proto.apply = function apply(compiler) {
11
- var webpack = compiler.webpack;
12
- compiler.options.output.chunkFormat = "commonjs";
13
- if (compiler.options.output.enabledLibraryTypes === void 0) {
14
- compiler.options.output.enabledLibraryTypes = [
15
- "commonjs-module"
16
- ];
17
- } else {
18
- compiler.options.output.enabledLibraryTypes.push("commonjs-module");
19
- }
20
- compiler.options.output.chunkLoading = "async-node";
21
- compiler.options.output.enabledChunkLoadingTypes = [];
22
- compiler.options.output.environment = _object_spread_props(_object_spread({}, compiler.options.output.environment), {
23
- dynamicImport: true
24
- });
25
- new webpack.node.NodeEnvironmentPlugin.apply(compiler);
26
- new webpack.node.NodeTargetPlugin().apply(compiler);
27
- };
28
- return RspackNodePlugin2;
29
- }();
30
- export {
31
- RspackNodePlugin as default
32
- };
@@ -1,26 +0,0 @@
1
- class RspackNodePlugin {
2
- apply(compiler) {
3
- const { webpack } = compiler;
4
- compiler.options.output.chunkFormat = "commonjs";
5
- if (compiler.options.output.enabledLibraryTypes === void 0) {
6
- compiler.options.output.enabledLibraryTypes = [
7
- "commonjs-module"
8
- ];
9
- } else {
10
- compiler.options.output.enabledLibraryTypes.push("commonjs-module");
11
- }
12
- compiler.options.output.chunkLoading = "async-node";
13
- compiler.options.output.enabledChunkLoadingTypes = [];
14
- compiler.options.output.environment = {
15
- ...compiler.options.output.environment,
16
- dynamicImport: true
17
- };
18
- new webpack.node.NodeEnvironmentPlugin.apply(compiler);
19
- new webpack.node.NodeTargetPlugin().apply(compiler);
20
- }
21
- constructor() {
22
- }
23
- }
24
- export {
25
- RspackNodePlugin as default
26
- };
@@ -1,5 +0,0 @@
1
- import type { Rspack } from '@modern-js/app-tools';
2
- export default class RspackNodePlugin implements Rspack.RspackPluginInstance {
3
- constructor();
4
- apply(compiler: Rspack.Compiler): void;
5
- }