@module-federation/modern-js 0.0.0-next-20240814073142 → 0.0.0-next-20240814082511

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.
@@ -18,14 +18,17 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var constant_exports = {};
20
20
  __export(constant_exports, {
21
+ META_NAME: () => META_NAME,
21
22
  MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME: () => MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME,
22
23
  isDev: () => isDev
23
24
  });
24
25
  module.exports = __toCommonJS(constant_exports);
25
26
  const isDev = process.env.NODE_ENV === "development";
26
27
  const MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
28
+ const META_NAME = "modern-js";
27
29
  // Annotate the CommonJS export names for ESM import in node:
28
30
  0 && (module.exports = {
31
+ META_NAME,
29
32
  MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME,
30
33
  isDev
31
34
  });
@@ -101,8 +101,8 @@ function addExpose(options) {
101
101
  }
102
102
  }
103
103
  function addShared(options) {
104
- const { pkgName, mfConfig } = options;
105
- const alias = `@${pkgName}/runtime/router`;
104
+ const { metaName, mfConfig } = options;
105
+ const alias = `@${metaName}/runtime/router`;
106
106
  if (!mfConfig.shared) {
107
107
  mfConfig.shared = {
108
108
  [alias]: {
@@ -123,6 +123,21 @@ function _pathMfConfig(options) {
123
123
  addShared(options);
124
124
  addExpose(options);
125
125
  }
126
+ function transformRuntimeOptions(buildOptions) {
127
+ const remotes = buildOptions.remotes || {};
128
+ const runtimeRemotes = Object.entries(remotes).map((remote) => {
129
+ const [_alias, nameAndEntry] = remote;
130
+ const [name, entry] = nameAndEntry.split("@");
131
+ return {
132
+ name,
133
+ entry
134
+ };
135
+ });
136
+ return {
137
+ name: buildOptions.name,
138
+ remotes: runtimeRemotes
139
+ };
140
+ }
126
141
  const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) => ({
127
142
  name: "@modern-js/plugin-module-federation-data-loader",
128
143
  pre: [
@@ -137,7 +152,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
137
152
  if (!enable) {
138
153
  return;
139
154
  }
140
- const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, pkgName = "modern-js", serverPlugin = "@module-federation/modern-js/data-loader-server" } = userConfig;
155
+ const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, metaName = import_constant3.META_NAME, serverPlugin = "@module-federation/modern-js/data-loader-server", runtimeOptions } = userConfig;
141
156
  if (!baseName) {
142
157
  throw new Error(`${import_constant.PLUGIN_IDENTIFIER} 'baseName' is required if you enable 'dataLoader'!`);
143
158
  }
@@ -145,7 +160,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
145
160
  const appContext = useAppContext();
146
161
  const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
147
162
  const name = (_internalOptions_csrConfig = internalOptions.csrConfig) === null || _internalOptions_csrConfig === void 0 ? void 0 : _internalOptions_csrConfig.name;
148
- const routesFilePath = import_path.default.resolve(appContext.internalDirectory, `./main/${import_constant3.MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME}`);
163
+ const routesFilePath = import_path.default.resolve(appContext.internalDirectory.replace(import_constant3.META_NAME, metaName || import_constant3.META_NAME), `./main/${import_constant3.MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME}`);
149
164
  return {
150
165
  _internalRuntimePlugins: ({ entrypoint, plugins }) => {
151
166
  plugins.push({
@@ -161,7 +176,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
161
176
  _internalServerPlugins({ plugins }) {
162
177
  plugins.push({
163
178
  name: serverPlugin,
164
- options: internalOptions
179
+ options: runtimeOptions || transformRuntimeOptions(internalOptions.csrConfig)
165
180
  });
166
181
  return {
167
182
  plugins
@@ -179,7 +194,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
179
194
  patchMFConfigFn({
180
195
  mfConfig: isServer ? internalOptions.ssrConfig : internalOptions.csrConfig,
181
196
  baseName,
182
- pkgName,
197
+ metaName,
183
198
  isServer,
184
199
  routesFilePath
185
200
  });
@@ -23,25 +23,16 @@ __export(dataLoaderPlugin_exports, {
23
23
  module.exports = __toCommonJS(dataLoaderPlugin_exports);
24
24
  var import_runtime = require("@module-federation/enhanced/runtime");
25
25
  var import_constant = require("../../runtime/constant");
26
- var dataLoaderPlugin_default = (options) => ({
26
+ var dataLoaderPlugin_default = (mfRuntimeOptions) => ({
27
27
  name: "MFDataLoaderServerPlugin",
28
28
  pre: [
29
29
  "@modern-js/plugin-inject-resource"
30
30
  ],
31
31
  setup(api) {
32
- const mfConfig = options.csrConfig;
33
- const remotes = mfConfig.remotes;
34
- if (!remotes || !Object.keys(remotes).length) {
32
+ const { remotes, name } = mfRuntimeOptions;
33
+ if (!remotes.length) {
35
34
  return {};
36
35
  }
37
- const runtimeRemotes = Object.entries(remotes).map((item) => {
38
- const [_alias, nameAndEntry] = item;
39
- const [name, entry] = nameAndEntry.split("@");
40
- return {
41
- name,
42
- entry
43
- };
44
- });
45
36
  let isHandled = false;
46
37
  return {
47
38
  prepare() {
@@ -57,10 +48,10 @@ var dataLoaderPlugin_default = (options) => ({
57
48
  await next();
58
49
  } else {
59
50
  const instance = (0, import_runtime.getInstance)() || (0, import_runtime.init)({
60
- name: mfConfig.name,
61
- remotes: runtimeRemotes
51
+ name,
52
+ remotes
62
53
  });
63
- const slimRoutes = await Promise.all(runtimeRemotes.map(async (remote) => {
54
+ const slimRoutes = await Promise.all(remotes.map(async (remote) => {
64
55
  const { routes, baseName } = await instance.loadRemote(`${remote.name}/${import_constant.MF_SLIM_ROUTES}`);
65
56
  return {
66
57
  routes,
@@ -1,6 +1,8 @@
1
1
  var isDev = process.env.NODE_ENV === "development";
2
2
  var MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
3
+ var META_NAME = "modern-js";
3
4
  export {
5
+ META_NAME,
4
6
  MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME,
5
7
  isDev
6
8
  };
@@ -1,5 +1,6 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
3
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
3
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
5
  import path from "path";
5
6
  import { fs } from "@modern-js/utils";
@@ -7,7 +8,7 @@ import { transformName2Prefix } from "../runtime/utils";
7
8
  import { PLUGIN_IDENTIFIER } from "../constant";
8
9
  import { MF_FULL_ROUTES, MF_SLIM_ROUTES, MF_ROUTES_META } from "../runtime/constant";
9
10
  import { generateRoutes, generateSlimRoutes } from "./ast";
10
- import { MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME } from "./constant";
11
+ import { MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME, META_NAME } from "./constant";
11
12
  function generateExtraExposeFiles(options) {
12
13
  var routesFilePath = options.routesFilePath, mfConfig = options.mfConfig, isServer = options.isServer, baseName = options.baseName;
13
14
  var outputDir = path.resolve(process.cwd(), "node_modules/.federation");
@@ -65,8 +66,8 @@ function addExpose(options) {
65
66
  }
66
67
  }
67
68
  function addShared(options) {
68
- var pkgName = options.pkgName, mfConfig = options.mfConfig;
69
- var alias = "@".concat(pkgName, "/runtime/router");
69
+ var metaName = options.metaName, mfConfig = options.mfConfig;
70
+ var alias = "@".concat(metaName, "/runtime/router");
70
71
  if (!mfConfig.shared) {
71
72
  mfConfig.shared = _define_property({}, alias, {
72
73
  singleton: true
@@ -85,6 +86,21 @@ function _pathMfConfig(options) {
85
86
  addShared(options);
86
87
  addExpose(options);
87
88
  }
89
+ function transformRuntimeOptions(buildOptions) {
90
+ var remotes = buildOptions.remotes || {};
91
+ var runtimeRemotes = Object.entries(remotes).map(function(remote) {
92
+ var _remote = _sliced_to_array(remote, 2), _alias = _remote[0], nameAndEntry = _remote[1];
93
+ var _nameAndEntry_split = _sliced_to_array(nameAndEntry.split("@"), 2), name = _nameAndEntry_split[0], entry = _nameAndEntry_split[1];
94
+ return {
95
+ name,
96
+ entry
97
+ };
98
+ });
99
+ return {
100
+ name: buildOptions.name,
101
+ remotes: runtimeRemotes
102
+ };
103
+ }
88
104
  var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userConfig) {
89
105
  return {
90
106
  name: "@modern-js/plugin-module-federation-data-loader",
@@ -97,7 +113,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
97
113
  ],
98
114
  setup: function() {
99
115
  var _ref = _async_to_generator(function(param) {
100
- var useConfigContext, useAppContext, _modernjsConfig_server, _internalOptions_csrConfig, baseName, _userConfig_partialSSRRemotes, partialSSRRemotes, fetchSSRByRouteIds, patchMFConfig, _userConfig_pkgName, pkgName, _userConfig_serverPlugin, serverPlugin, modernjsConfig, appContext, enableSSR, name, routesFilePath;
116
+ var useConfigContext, useAppContext, _modernjsConfig_server, _internalOptions_csrConfig, baseName, _userConfig_partialSSRRemotes, partialSSRRemotes, fetchSSRByRouteIds, patchMFConfig, _userConfig_metaName, metaName, _userConfig_serverPlugin, serverPlugin, runtimeOptions, modernjsConfig, appContext, enableSSR, name, routesFilePath;
101
117
  return _ts_generator(this, function(_state) {
102
118
  useConfigContext = param.useConfigContext, useAppContext = param.useAppContext;
103
119
  if (!enable) {
@@ -105,7 +121,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
105
121
  2
106
122
  ];
107
123
  }
108
- baseName = userConfig.baseName, _userConfig_partialSSRRemotes = userConfig.partialSSRRemotes, partialSSRRemotes = _userConfig_partialSSRRemotes === void 0 ? [] : _userConfig_partialSSRRemotes, fetchSSRByRouteIds = userConfig.fetchSSRByRouteIds, patchMFConfig = userConfig.patchMFConfig, _userConfig_pkgName = userConfig.pkgName, pkgName = _userConfig_pkgName === void 0 ? "modern-js" : _userConfig_pkgName, _userConfig_serverPlugin = userConfig.serverPlugin, serverPlugin = _userConfig_serverPlugin === void 0 ? "@module-federation/modern-js/data-loader-server" : _userConfig_serverPlugin;
124
+ baseName = userConfig.baseName, _userConfig_partialSSRRemotes = userConfig.partialSSRRemotes, partialSSRRemotes = _userConfig_partialSSRRemotes === void 0 ? [] : _userConfig_partialSSRRemotes, fetchSSRByRouteIds = userConfig.fetchSSRByRouteIds, patchMFConfig = userConfig.patchMFConfig, _userConfig_metaName = userConfig.metaName, metaName = _userConfig_metaName === void 0 ? META_NAME : _userConfig_metaName, _userConfig_serverPlugin = userConfig.serverPlugin, serverPlugin = _userConfig_serverPlugin === void 0 ? "@module-federation/modern-js/data-loader-server" : _userConfig_serverPlugin, runtimeOptions = userConfig.runtimeOptions;
109
125
  if (!baseName) {
110
126
  throw new Error("".concat(PLUGIN_IDENTIFIER, " 'baseName' is required if you enable 'dataLoader'!"));
111
127
  }
@@ -113,7 +129,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
113
129
  appContext = useAppContext();
114
130
  enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
115
131
  name = (_internalOptions_csrConfig = internalOptions.csrConfig) === null || _internalOptions_csrConfig === void 0 ? void 0 : _internalOptions_csrConfig.name;
116
- routesFilePath = path.resolve(appContext.internalDirectory, "./main/".concat(MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME));
132
+ routesFilePath = path.resolve(appContext.internalDirectory.replace(META_NAME, metaName || META_NAME), "./main/".concat(MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME));
117
133
  return [
118
134
  2,
119
135
  {
@@ -133,7 +149,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
133
149
  var plugins = param2.plugins;
134
150
  plugins.push({
135
151
  name: serverPlugin,
136
- options: internalOptions
152
+ options: runtimeOptions || transformRuntimeOptions(internalOptions.csrConfig)
137
153
  });
138
154
  return {
139
155
  plugins
@@ -156,7 +172,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
156
172
  patchMFConfigFn({
157
173
  mfConfig: isServer ? internalOptions.ssrConfig : internalOptions.csrConfig,
158
174
  baseName,
159
- pkgName,
175
+ metaName,
160
176
  isServer,
161
177
  routesFilePath
162
178
  });
@@ -1,29 +1,19 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
3
2
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
4
  import { getInstance, init } from "@module-federation/enhanced/runtime";
6
5
  import { MF_SLIM_ROUTES } from "../../runtime/constant";
7
- function dataLoaderPlugin_default(options) {
6
+ function dataLoaderPlugin_default(mfRuntimeOptions) {
8
7
  return {
9
8
  name: "MFDataLoaderServerPlugin",
10
9
  pre: [
11
10
  "@modern-js/plugin-inject-resource"
12
11
  ],
13
12
  setup: function setup(api) {
14
- var mfConfig = options.csrConfig;
15
- var remotes = mfConfig.remotes;
16
- if (!remotes || !Object.keys(remotes).length) {
13
+ var remotes = mfRuntimeOptions.remotes, name = mfRuntimeOptions.name;
14
+ if (!remotes.length) {
17
15
  return {};
18
16
  }
19
- var runtimeRemotes = Object.entries(remotes).map(function(item) {
20
- var _item = _sliced_to_array(item, 2), _alias = _item[0], nameAndEntry = _item[1];
21
- var _nameAndEntry_split = _sliced_to_array(nameAndEntry.split("@"), 2), name = _nameAndEntry_split[0], entry = _nameAndEntry_split[1];
22
- return {
23
- name,
24
- entry
25
- };
26
- });
27
17
  var isHandled = false;
28
18
  return {
29
19
  prepare: function prepare() {
@@ -57,12 +47,12 @@ function dataLoaderPlugin_default(options) {
57
47
  ];
58
48
  case 2:
59
49
  instance = getInstance() || init({
60
- name: mfConfig.name,
61
- remotes: runtimeRemotes
50
+ name,
51
+ remotes
62
52
  });
63
53
  return [
64
54
  4,
65
- Promise.all(runtimeRemotes.map(function() {
55
+ Promise.all(remotes.map(function() {
66
56
  var _ref2 = _async_to_generator(function(remote) {
67
57
  var _ref3, routes, baseName;
68
58
  return _ts_generator(this, function(_state2) {
@@ -1,6 +1,8 @@
1
1
  const isDev = process.env.NODE_ENV === "development";
2
2
  const MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
3
+ const META_NAME = "modern-js";
3
4
  export {
5
+ META_NAME,
4
6
  MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME,
5
7
  isDev
6
8
  };
@@ -4,7 +4,7 @@ import { transformName2Prefix } from "../runtime/utils";
4
4
  import { PLUGIN_IDENTIFIER } from "../constant";
5
5
  import { MF_FULL_ROUTES, MF_SLIM_ROUTES, MF_ROUTES_META } from "../runtime/constant";
6
6
  import { generateRoutes, generateSlimRoutes } from "./ast";
7
- import { MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME } from "./constant";
7
+ import { MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME, META_NAME } from "./constant";
8
8
  function generateExtraExposeFiles(options) {
9
9
  const { routesFilePath, mfConfig, isServer, baseName } = options;
10
10
  const outputDir = path.resolve(process.cwd(), "node_modules/.federation");
@@ -65,8 +65,8 @@ function addExpose(options) {
65
65
  }
66
66
  }
67
67
  function addShared(options) {
68
- const { pkgName, mfConfig } = options;
69
- const alias = `@${pkgName}/runtime/router`;
68
+ const { metaName, mfConfig } = options;
69
+ const alias = `@${metaName}/runtime/router`;
70
70
  if (!mfConfig.shared) {
71
71
  mfConfig.shared = {
72
72
  [alias]: {
@@ -87,6 +87,21 @@ function _pathMfConfig(options) {
87
87
  addShared(options);
88
88
  addExpose(options);
89
89
  }
90
+ function transformRuntimeOptions(buildOptions) {
91
+ const remotes = buildOptions.remotes || {};
92
+ const runtimeRemotes = Object.entries(remotes).map((remote) => {
93
+ const [_alias, nameAndEntry] = remote;
94
+ const [name, entry] = nameAndEntry.split("@");
95
+ return {
96
+ name,
97
+ entry
98
+ };
99
+ });
100
+ return {
101
+ name: buildOptions.name,
102
+ remotes: runtimeRemotes
103
+ };
104
+ }
90
105
  const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) => ({
91
106
  name: "@modern-js/plugin-module-federation-data-loader",
92
107
  pre: [
@@ -101,7 +116,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
101
116
  if (!enable) {
102
117
  return;
103
118
  }
104
- const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, pkgName = "modern-js", serverPlugin = "@module-federation/modern-js/data-loader-server" } = userConfig;
119
+ const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, metaName = META_NAME, serverPlugin = "@module-federation/modern-js/data-loader-server", runtimeOptions } = userConfig;
105
120
  if (!baseName) {
106
121
  throw new Error(`${PLUGIN_IDENTIFIER} 'baseName' is required if you enable 'dataLoader'!`);
107
122
  }
@@ -109,7 +124,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
109
124
  const appContext = useAppContext();
110
125
  const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
111
126
  const name = (_internalOptions_csrConfig = internalOptions.csrConfig) === null || _internalOptions_csrConfig === void 0 ? void 0 : _internalOptions_csrConfig.name;
112
- const routesFilePath = path.resolve(appContext.internalDirectory, `./main/${MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME}`);
127
+ const routesFilePath = path.resolve(appContext.internalDirectory.replace(META_NAME, metaName || META_NAME), `./main/${MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME}`);
113
128
  return {
114
129
  _internalRuntimePlugins: ({ entrypoint, plugins }) => {
115
130
  plugins.push({
@@ -125,7 +140,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
125
140
  _internalServerPlugins({ plugins }) {
126
141
  plugins.push({
127
142
  name: serverPlugin,
128
- options: internalOptions
143
+ options: runtimeOptions || transformRuntimeOptions(internalOptions.csrConfig)
129
144
  });
130
145
  return {
131
146
  plugins
@@ -143,7 +158,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
143
158
  patchMFConfigFn({
144
159
  mfConfig: isServer ? internalOptions.ssrConfig : internalOptions.csrConfig,
145
160
  baseName,
146
- pkgName,
161
+ metaName,
147
162
  isServer,
148
163
  routesFilePath
149
164
  });
@@ -1,24 +1,15 @@
1
1
  import { getInstance, init } from "@module-federation/enhanced/runtime";
2
2
  import { MF_SLIM_ROUTES } from "../../runtime/constant";
3
- var dataLoaderPlugin_default = (options) => ({
3
+ var dataLoaderPlugin_default = (mfRuntimeOptions) => ({
4
4
  name: "MFDataLoaderServerPlugin",
5
5
  pre: [
6
6
  "@modern-js/plugin-inject-resource"
7
7
  ],
8
8
  setup(api) {
9
- const mfConfig = options.csrConfig;
10
- const remotes = mfConfig.remotes;
11
- if (!remotes || !Object.keys(remotes).length) {
9
+ const { remotes, name } = mfRuntimeOptions;
10
+ if (!remotes.length) {
12
11
  return {};
13
12
  }
14
- const runtimeRemotes = Object.entries(remotes).map((item) => {
15
- const [_alias, nameAndEntry] = item;
16
- const [name, entry] = nameAndEntry.split("@");
17
- return {
18
- name,
19
- entry
20
- };
21
- });
22
13
  let isHandled = false;
23
14
  return {
24
15
  prepare() {
@@ -34,10 +25,10 @@ var dataLoaderPlugin_default = (options) => ({
34
25
  await next();
35
26
  } else {
36
27
  const instance = getInstance() || init({
37
- name: mfConfig.name,
38
- remotes: runtimeRemotes
28
+ name,
29
+ remotes
39
30
  });
40
- const slimRoutes = await Promise.all(runtimeRemotes.map(async (remote) => {
31
+ const slimRoutes = await Promise.all(remotes.map(async (remote) => {
41
32
  const { routes, baseName } = await instance.loadRemote(`${remote.name}/${MF_SLIM_ROUTES}`);
42
33
  return {
43
34
  routes,
@@ -1,2 +1,3 @@
1
1
  export declare const isDev: boolean;
2
2
  export declare const MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
3
+ export declare const META_NAME = "modern-js";
@@ -1,4 +1,5 @@
1
1
  import type { ServerPlugin } from '@modern-js/server-core';
2
- import { InternalModernPluginOptions } from '../../types';
3
- declare const _default: (options: InternalModernPluginOptions) => ServerPlugin;
2
+ import { init } from '@module-federation/enhanced/runtime';
3
+ type MFRuntimeOptions = Parameters<typeof init>[0];
4
+ declare const _default: (mfRuntimeOptions: MFRuntimeOptions) => ServerPlugin;
4
5
  export default _default;
@@ -1,6 +1,7 @@
1
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
2
2
  import type { ModuleFederationPlugin as WebpackModuleFederationPlugin } from '@module-federation/enhanced';
3
3
  import type { ModuleFederationPlugin as RspackModuleFederationPlugin } from '@module-federation/enhanced/rspack';
4
+ import type { init } from '@module-federation/enhanced/runtime';
4
5
  export interface PluginOptions {
5
6
  config?: moduleFederationPlugin.ModuleFederationPluginOptions;
6
7
  configPath?: string;
@@ -20,13 +21,14 @@ export type BundlerPlugin = WebpackModuleFederationPlugin | RspackModuleFederati
20
21
  export type DataLoaderOptions = {
21
22
  baseName: string;
22
23
  partialSSRRemotes?: string[];
23
- pkgName?: string;
24
+ metaName?: string;
24
25
  serverPlugin?: string;
26
+ runtimeOptions?: Parameters<typeof init>[0];
25
27
  fetchSSRByRouteIds?: (partialSSRRemotes: string[], mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) => Promise<string[] | undefined>;
26
28
  patchMFConfig?: (options: {
27
29
  mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
28
30
  baseName: string;
29
- pkgName: string;
31
+ metaName: string;
30
32
  isServer: boolean;
31
33
  routesFilePath: string;
32
34
  }) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240814073142",
3
+ "version": "0.0.0-next-20240814082511",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -84,9 +84,9 @@
84
84
  "@babel/parser": "7.25.3",
85
85
  "@babel/traverse": "7.25.3",
86
86
  "@babel/types": "7.25.2",
87
- "@module-federation/sdk": "0.0.0-next-20240814073142",
88
- "@module-federation/enhanced": "0.0.0-next-20240814073142",
89
- "@module-federation/node": "0.0.0-next-20240814073142"
87
+ "@module-federation/sdk": "0.0.0-next-20240814082511",
88
+ "@module-federation/enhanced": "0.0.0-next-20240814082511",
89
+ "@module-federation/node": "0.0.0-next-20240814082511"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/babel__traverse": "7.20.6",
@@ -98,7 +98,7 @@
98
98
  "@modern-js/runtime": "0.0.0-next-20240814063139",
99
99
  "@modern-js/module-tools": "0.0.0-next-20240814063139",
100
100
  "@modern-js/tsconfig": "0.0.0-next-20240814063139",
101
- "@module-federation/manifest": "0.0.0-next-20240814073142"
101
+ "@module-federation/manifest": "0.0.0-next-20240814082511"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": ">=17",