@module-federation/modern-js 0.0.0-next-20240814082511 → 0.0.0-next-20240814085621
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.
|
@@ -123,7 +123,7 @@ function _pathMfConfig(options) {
|
|
|
123
123
|
addShared(options);
|
|
124
124
|
addExpose(options);
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function _transformRuntimeOptions(buildOptions) {
|
|
127
127
|
const remotes = buildOptions.remotes || {};
|
|
128
128
|
const runtimeRemotes = Object.entries(remotes).map((remote) => {
|
|
129
129
|
const [_alias, nameAndEntry] = remote;
|
|
@@ -152,7 +152,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
152
152
|
if (!enable) {
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
-
const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, metaName = import_constant3.META_NAME, serverPlugin = "@module-federation/modern-js/data-loader-server",
|
|
155
|
+
const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, metaName = import_constant3.META_NAME, serverPlugin = "@module-federation/modern-js/data-loader-server", transformRuntimeOptions } = userConfig;
|
|
156
156
|
if (!baseName) {
|
|
157
157
|
throw new Error(`${import_constant.PLUGIN_IDENTIFIER} 'baseName' is required if you enable 'dataLoader'!`);
|
|
158
158
|
}
|
|
@@ -161,6 +161,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
161
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);
|
|
162
162
|
const name = (_internalOptions_csrConfig = internalOptions.csrConfig) === null || _internalOptions_csrConfig === void 0 ? void 0 : _internalOptions_csrConfig.name;
|
|
163
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}`);
|
|
164
|
+
const transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
164
165
|
return {
|
|
165
166
|
_internalRuntimePlugins: ({ entrypoint, plugins }) => {
|
|
166
167
|
plugins.push({
|
|
@@ -176,7 +177,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
176
177
|
_internalServerPlugins({ plugins }) {
|
|
177
178
|
plugins.push({
|
|
178
179
|
name: serverPlugin,
|
|
179
|
-
options:
|
|
180
|
+
options: transformRuntimeFn(internalOptions.csrConfig)
|
|
180
181
|
});
|
|
181
182
|
return {
|
|
182
183
|
plugins
|
|
@@ -86,7 +86,7 @@ function _pathMfConfig(options) {
|
|
|
86
86
|
addShared(options);
|
|
87
87
|
addExpose(options);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function _transformRuntimeOptions(buildOptions) {
|
|
90
90
|
var remotes = buildOptions.remotes || {};
|
|
91
91
|
var runtimeRemotes = Object.entries(remotes).map(function(remote) {
|
|
92
92
|
var _remote = _sliced_to_array(remote, 2), _alias = _remote[0], nameAndEntry = _remote[1];
|
|
@@ -113,7 +113,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
113
113
|
],
|
|
114
114
|
setup: function() {
|
|
115
115
|
var _ref = _async_to_generator(function(param) {
|
|
116
|
-
var useConfigContext, useAppContext, _modernjsConfig_server, _internalOptions_csrConfig, baseName, _userConfig_partialSSRRemotes, partialSSRRemotes, fetchSSRByRouteIds, patchMFConfig, _userConfig_metaName, metaName, _userConfig_serverPlugin, serverPlugin,
|
|
116
|
+
var useConfigContext, useAppContext, _modernjsConfig_server, _internalOptions_csrConfig, baseName, _userConfig_partialSSRRemotes, partialSSRRemotes, fetchSSRByRouteIds, patchMFConfig, _userConfig_metaName, metaName, _userConfig_serverPlugin, serverPlugin, transformRuntimeOptions, modernjsConfig, appContext, enableSSR, name, routesFilePath, transformRuntimeFn;
|
|
117
117
|
return _ts_generator(this, function(_state) {
|
|
118
118
|
useConfigContext = param.useConfigContext, useAppContext = param.useAppContext;
|
|
119
119
|
if (!enable) {
|
|
@@ -121,7 +121,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
121
121
|
2
|
|
122
122
|
];
|
|
123
123
|
}
|
|
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,
|
|
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, transformRuntimeOptions = userConfig.transformRuntimeOptions;
|
|
125
125
|
if (!baseName) {
|
|
126
126
|
throw new Error("".concat(PLUGIN_IDENTIFIER, " 'baseName' is required if you enable 'dataLoader'!"));
|
|
127
127
|
}
|
|
@@ -130,6 +130,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
130
130
|
enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
131
131
|
name = (_internalOptions_csrConfig = internalOptions.csrConfig) === null || _internalOptions_csrConfig === void 0 ? void 0 : _internalOptions_csrConfig.name;
|
|
132
132
|
routesFilePath = path.resolve(appContext.internalDirectory.replace(META_NAME, metaName || META_NAME), "./main/".concat(MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME));
|
|
133
|
+
transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
133
134
|
return [
|
|
134
135
|
2,
|
|
135
136
|
{
|
|
@@ -149,7 +150,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
149
150
|
var plugins = param2.plugins;
|
|
150
151
|
plugins.push({
|
|
151
152
|
name: serverPlugin,
|
|
152
|
-
options:
|
|
153
|
+
options: transformRuntimeFn(internalOptions.csrConfig)
|
|
153
154
|
});
|
|
154
155
|
return {
|
|
155
156
|
plugins
|
|
@@ -87,7 +87,7 @@ function _pathMfConfig(options) {
|
|
|
87
87
|
addShared(options);
|
|
88
88
|
addExpose(options);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function _transformRuntimeOptions(buildOptions) {
|
|
91
91
|
const remotes = buildOptions.remotes || {};
|
|
92
92
|
const runtimeRemotes = Object.entries(remotes).map((remote) => {
|
|
93
93
|
const [_alias, nameAndEntry] = remote;
|
|
@@ -116,7 +116,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
116
116
|
if (!enable) {
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, metaName = META_NAME, serverPlugin = "@module-federation/modern-js/data-loader-server",
|
|
119
|
+
const { baseName, partialSSRRemotes = [], fetchSSRByRouteIds, patchMFConfig, metaName = META_NAME, serverPlugin = "@module-federation/modern-js/data-loader-server", transformRuntimeOptions } = userConfig;
|
|
120
120
|
if (!baseName) {
|
|
121
121
|
throw new Error(`${PLUGIN_IDENTIFIER} 'baseName' is required if you enable 'dataLoader'!`);
|
|
122
122
|
}
|
|
@@ -125,6 +125,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
125
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);
|
|
126
126
|
const name = (_internalOptions_csrConfig = internalOptions.csrConfig) === null || _internalOptions_csrConfig === void 0 ? void 0 : _internalOptions_csrConfig.name;
|
|
127
127
|
const routesFilePath = path.resolve(appContext.internalDirectory.replace(META_NAME, metaName || META_NAME), `./main/${MODERN_JS_FILE_SYSTEM_ROUTES_FILE_NAME}`);
|
|
128
|
+
const transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
128
129
|
return {
|
|
129
130
|
_internalRuntimePlugins: ({ entrypoint, plugins }) => {
|
|
130
131
|
plugins.push({
|
|
@@ -140,7 +141,7 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
140
141
|
_internalServerPlugins({ plugins }) {
|
|
141
142
|
plugins.push({
|
|
142
143
|
name: serverPlugin,
|
|
143
|
-
options:
|
|
144
|
+
options: transformRuntimeFn(internalOptions.csrConfig)
|
|
144
145
|
});
|
|
145
146
|
return {
|
|
146
147
|
plugins
|
|
@@ -23,7 +23,7 @@ export type DataLoaderOptions = {
|
|
|
23
23
|
partialSSRRemotes?: string[];
|
|
24
24
|
metaName?: string;
|
|
25
25
|
serverPlugin?: string;
|
|
26
|
-
|
|
26
|
+
transformRuntimeOptions?: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) => Parameters<typeof init>[0];
|
|
27
27
|
fetchSSRByRouteIds?: (partialSSRRemotes: string[], mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) => Promise<string[] | undefined>;
|
|
28
28
|
patchMFConfig?: (options: {
|
|
29
29
|
mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240814085621",
|
|
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-
|
|
88
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
89
|
-
"@module-federation/node": "0.0.0-next-
|
|
87
|
+
"@module-federation/sdk": "0.0.0-next-20240814085621",
|
|
88
|
+
"@module-federation/enhanced": "0.0.0-next-20240814085621",
|
|
89
|
+
"@module-federation/node": "0.0.0-next-20240814085621"
|
|
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-
|
|
101
|
+
"@module-federation/manifest": "0.0.0-next-20240814085621"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": ">=17",
|