@module-federation/nextjs-mf 7.0.8 → 8.0.1-0
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.
- package/CHANGELOG.md +545 -411
- package/README.md +29 -15
- package/client/MFClient.js +1 -2
- package/client/MFClient.js.map +1 -1
- package/client/RemoteContainer.js +2 -1
- package/client/RemoteContainer.js.map +1 -1
- package/client/RemotePages.js +2 -1
- package/client/RemotePages.js.map +1 -1
- package/client/UrlNode.js +2 -10
- package/client/UrlNode.js.map +1 -1
- package/node.d.ts +1 -1
- package/node.js.map +1 -1
- package/package.json +7 -5
- package/src/default-delegate.js +64 -9
- package/src/default-delegate.js.map +1 -1
- package/src/federation-noop.js +13 -1
- package/src/federation-noop.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/internal.d.ts +18 -12
- package/src/internal.js +83 -71
- package/src/internal.js.map +1 -1
- package/src/loaders/delegateLoader.d.ts +5 -2
- package/src/loaders/delegateLoader.js +19 -9
- package/src/loaders/delegateLoader.js.map +1 -1
- package/src/loaders/fixImageLoader.d.ts +12 -11
- package/src/loaders/fixImageLoader.js +17 -13
- package/src/loaders/fixImageLoader.js.map +1 -1
- package/src/loaders/fixUrlLoader.d.ts +7 -7
- package/src/loaders/fixUrlLoader.js +11 -11
- package/src/loaders/fixUrlLoader.js.map +1 -1
- package/src/loaders/helpers.d.ts +10 -3
- package/src/loaders/helpers.js +22 -13
- package/src/loaders/helpers.js.map +1 -1
- package/src/loaders/inject-hoist.d.ts +11 -0
- package/src/loaders/inject-hoist.js +7 -0
- package/src/loaders/inject-hoist.js.map +1 -1
- package/src/loaders/nextPageMapLoader.d.ts +12 -3
- package/src/loaders/nextPageMapLoader.js +45 -29
- package/src/loaders/nextPageMapLoader.js.map +1 -1
- package/src/loaders/patchDefaultSharedLoader.d.ts +9 -0
- package/src/loaders/patchDefaultSharedLoader.js +11 -0
- package/src/loaders/patchDefaultSharedLoader.js.map +1 -1
- package/src/loaders/patchNextClientPageLoader.d.ts +4 -2
- package/src/loaders/patchNextClientPageLoader.js +36 -18
- package/src/loaders/patchNextClientPageLoader.js.map +1 -1
- package/src/plugins/CopyFederationPlugin.d.ts +13 -0
- package/src/plugins/CopyFederationPlugin.js +40 -19
- package/src/plugins/CopyFederationPlugin.js.map +1 -1
- package/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +2 -3
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js +9 -6
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +17 -10
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js +35 -27
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/src/plugins/NextFederationPlugin/index.d.ts +18 -6
- package/src/plugins/NextFederationPlugin/index.js +108 -75
- package/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/src/plugins/NextFederationPlugin/next-fragments.d.ts +23 -17
- package/src/plugins/NextFederationPlugin/next-fragments.js +26 -18
- package/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
- package/src/plugins/NextFederationPlugin/regex-equal.d.ts +8 -8
- package/src/plugins/NextFederationPlugin/regex-equal.js +7 -7
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +7 -0
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +20 -9
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -1
- package/src/plugins/NextFederationPlugin/set-options.d.ts +6 -6
- package/src/plugins/NextFederationPlugin/set-options.js +10 -6
- package/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
- package/src/plugins/NextFederationPlugin/validate-options.d.ts +13 -14
- package/src/plugins/NextFederationPlugin/validate-options.js +15 -15
- package/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
- package/src/plugins/container/EmbeddedContainerPlugin.d.ts +40 -0
- package/src/plugins/container/EmbeddedContainerPlugin.js +73 -0
- package/src/plugins/container/EmbeddedContainerPlugin.js.map +1 -0
- package/src/plugins/container/InvertedContainerPlugin.d.ts +21 -14
- package/src/plugins/container/InvertedContainerPlugin.js +21 -148
- package/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
- package/src/plugins/container/InvertedContainerRuntimeModule.d.ts +3 -33
- package/src/plugins/container/InvertedContainerRuntimeModule.js +64 -518
- package/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/src/plugins/container/ModuleFederationPlugin.d.ts +17 -0
- package/src/plugins/container/ModuleFederationPlugin.js +97 -0
- package/src/plugins/container/ModuleFederationPlugin.js.map +1 -0
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +28 -6
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +34 -57
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -1
- package/src/plugins/container/types.d.ts +1 -1
- package/src/types.d.ts +3 -0
- package/utilities.js.map +1 -1
- package/utils/Template.d.ts +1 -1
- package/utils/Template.js +23 -15
- package/utils/Template.js.map +1 -1
- package/utils/build-utils.d.ts +9 -0
- package/utils/build-utils.js +9 -0
- package/utils/build-utils.js.map +1 -1
- package/utils/flushedChunks.d.ts +15 -0
- package/utils/flushedChunks.js +8 -0
- package/utils/flushedChunks.js.map +1 -1
- package/utils/index.d.ts +27 -3
- package/utils/index.js +45 -1
- package/utils/index.js.map +1 -1
- package/src/plugins/JsonpChunkLoading.d.ts +0 -7
- package/src/plugins/JsonpChunkLoading.js +0 -43
- package/src/plugins/JsonpChunkLoading.js.map +0 -1
- package/src/plugins/container/custom-jsonp.d.ts +0 -2
- package/src/plugins/container/custom-jsonp.js +0 -90
- package/src/plugins/container/custom-jsonp.js.map +0 -1
package/src/internal.js
CHANGED
|
@@ -15,95 +15,93 @@ const options_1 = require("webpack/lib/container/options");
|
|
|
15
15
|
*/
|
|
16
16
|
exports.DEFAULT_SHARE_SCOPE = {
|
|
17
17
|
'next/dynamic': {
|
|
18
|
-
|
|
19
|
-
requiredVersion: false,
|
|
18
|
+
requiredVersion: undefined,
|
|
20
19
|
singleton: true,
|
|
21
20
|
import: undefined,
|
|
22
21
|
},
|
|
23
22
|
'next/head': {
|
|
24
|
-
|
|
25
|
-
requiredVersion: false,
|
|
23
|
+
requiredVersion: undefined,
|
|
26
24
|
singleton: true,
|
|
27
25
|
import: undefined,
|
|
28
26
|
},
|
|
29
27
|
'next/link': {
|
|
30
|
-
|
|
31
|
-
requiredVersion: false,
|
|
28
|
+
requiredVersion: undefined,
|
|
32
29
|
singleton: true,
|
|
33
30
|
import: undefined,
|
|
34
31
|
},
|
|
35
32
|
'next/router': {
|
|
36
|
-
requiredVersion:
|
|
33
|
+
requiredVersion: undefined,
|
|
37
34
|
singleton: true,
|
|
38
|
-
import:
|
|
39
|
-
|
|
35
|
+
import: undefined
|
|
36
|
+
},
|
|
37
|
+
"@module-federation/utilities": {
|
|
38
|
+
eager: true,
|
|
39
|
+
requiredVersion: false
|
|
40
40
|
},
|
|
41
41
|
'next/image': {
|
|
42
|
-
requiredVersion:
|
|
42
|
+
requiredVersion: undefined,
|
|
43
43
|
singleton: true,
|
|
44
44
|
import: undefined,
|
|
45
|
-
eager: false,
|
|
46
45
|
},
|
|
47
46
|
'next/script': {
|
|
48
|
-
requiredVersion:
|
|
47
|
+
requiredVersion: undefined,
|
|
49
48
|
singleton: true,
|
|
50
49
|
import: undefined,
|
|
51
|
-
eager: false,
|
|
52
50
|
},
|
|
53
51
|
react: {
|
|
54
52
|
singleton: true,
|
|
55
|
-
requiredVersion:
|
|
56
|
-
|
|
53
|
+
requiredVersion: undefined,
|
|
54
|
+
import: false,
|
|
55
|
+
},
|
|
56
|
+
"react/": {
|
|
57
|
+
singleton: true,
|
|
58
|
+
requiredVersion: undefined,
|
|
59
|
+
import: false,
|
|
60
|
+
},
|
|
61
|
+
'react-dom/': {
|
|
62
|
+
singleton: true,
|
|
63
|
+
requiredVersion: undefined,
|
|
57
64
|
import: false,
|
|
58
65
|
},
|
|
59
66
|
'react-dom': {
|
|
60
67
|
singleton: true,
|
|
61
|
-
requiredVersion:
|
|
62
|
-
eager: false,
|
|
68
|
+
requiredVersion: undefined,
|
|
63
69
|
import: false,
|
|
64
70
|
},
|
|
65
71
|
'react/jsx-dev-runtime': {
|
|
66
72
|
singleton: true,
|
|
67
|
-
requiredVersion:
|
|
73
|
+
requiredVersion: undefined,
|
|
68
74
|
import: undefined,
|
|
69
|
-
eager: false,
|
|
70
75
|
},
|
|
71
76
|
'react/jsx-runtime': {
|
|
72
77
|
singleton: true,
|
|
73
|
-
requiredVersion:
|
|
74
|
-
|
|
75
|
-
import: false,
|
|
78
|
+
requiredVersion: undefined,
|
|
79
|
+
// import: false,
|
|
76
80
|
},
|
|
77
81
|
'styled-jsx': {
|
|
78
|
-
requiredVersion:
|
|
82
|
+
requiredVersion: undefined,
|
|
79
83
|
singleton: true,
|
|
80
84
|
import: undefined,
|
|
81
|
-
eager: false,
|
|
82
85
|
},
|
|
83
86
|
'styled-jsx/style': {
|
|
84
87
|
requiredVersion: false,
|
|
85
88
|
singleton: true,
|
|
86
89
|
import: undefined,
|
|
87
|
-
eager: false,
|
|
88
90
|
},
|
|
89
91
|
};
|
|
90
92
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
93
|
+
* Defines a default share scope for the browser environment.
|
|
94
|
+
* This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.
|
|
95
|
+
* For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.
|
|
96
|
+
* The module hoisting system relocates these modules into the right runtime and out of the remote.
|
|
94
97
|
*
|
|
95
98
|
* @type {SharedObject}
|
|
99
|
+
* @returns {SharedObject} - The modified share scope for the browser environment.
|
|
96
100
|
*/
|
|
97
101
|
exports.DEFAULT_SHARE_SCOPE_BROWSER = Object.entries(exports.DEFAULT_SHARE_SCOPE).reduce((acc, item) => {
|
|
98
102
|
const [key, value] = item;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
key === 'react-dom' ||
|
|
102
|
-
key === 'next/router' ||
|
|
103
|
-
key === 'next/link') {
|
|
104
|
-
//@ts-ignore
|
|
105
|
-
acc[key].eager = true;
|
|
106
|
-
}
|
|
103
|
+
// Set eager and import to undefined for all entries, except for the ones specified above
|
|
104
|
+
acc[key] = { ...value, import: undefined };
|
|
107
105
|
return acc;
|
|
108
106
|
}, {});
|
|
109
107
|
/**
|
|
@@ -112,9 +110,7 @@ exports.DEFAULT_SHARE_SCOPE_BROWSER = Object.entries(exports.DEFAULT_SHARE_SCOPE
|
|
|
112
110
|
* @param {string} value - The remote value to check.
|
|
113
111
|
* @returns {boolean} - True if the value is an internal or promise delegate module reference, false otherwise.
|
|
114
112
|
*/
|
|
115
|
-
const isInternalOrPromise = (value) =>
|
|
116
|
-
return value.startsWith('internal ') || value.startsWith('promise ');
|
|
117
|
-
};
|
|
113
|
+
const isInternalOrPromise = (value) => ['internal ', 'promise '].some((prefix) => value.startsWith(prefix));
|
|
118
114
|
/**
|
|
119
115
|
* Checks if the remote value is using the standard remote syntax.
|
|
120
116
|
*
|
|
@@ -125,60 +121,72 @@ const isStandardRemoteSyntax = (value) => {
|
|
|
125
121
|
return value.includes('@');
|
|
126
122
|
};
|
|
127
123
|
/**
|
|
128
|
-
* Parses the remotes object
|
|
124
|
+
* Parses the remotes object and checks if they are using a custom promise template or not.
|
|
129
125
|
* If it's a custom promise template, the remote syntax is parsed to get the module name and version number.
|
|
126
|
+
* If the remote value is using the standard remote syntax, a delegated module is created.
|
|
130
127
|
*
|
|
131
128
|
* @param {Record<string, any>} remotes - The remotes object to be parsed.
|
|
132
|
-
* @returns {Record<string, string>} - The parsed remotes object
|
|
129
|
+
* @returns {Record<string, string>} - The parsed remotes object with either the original value,
|
|
130
|
+
* the value for internal or promise delegate module reference, or the created delegated module.
|
|
133
131
|
*/
|
|
134
132
|
const parseRemotes = (remotes) => {
|
|
135
133
|
return Object.entries(remotes).reduce((acc, [key, value]) => {
|
|
136
134
|
if (isInternalOrPromise(value)) {
|
|
135
|
+
// If the value is an internal or promise delegate module reference, keep the original value
|
|
137
136
|
return { ...acc, [key]: value };
|
|
138
137
|
}
|
|
138
|
+
return { ...acc, [key]: value };
|
|
139
139
|
if (isStandardRemoteSyntax(value)) {
|
|
140
|
+
let resolvePath;
|
|
141
|
+
try {
|
|
142
|
+
resolvePath = require.resolve('./default-delegate.cjs');
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
resolvePath = require.resolve('./default-delegate');
|
|
146
|
+
}
|
|
147
|
+
// If the value is using the standard remote syntax, create a delegated module
|
|
140
148
|
return {
|
|
141
149
|
...acc,
|
|
142
|
-
[key]: (0, utilities_1.createDelegatedModule)(
|
|
150
|
+
[key]: (0, utilities_1.createDelegatedModule)(resolvePath, {
|
|
143
151
|
remote: value,
|
|
144
152
|
}),
|
|
145
153
|
};
|
|
146
154
|
}
|
|
155
|
+
// If none of the above conditions are met, keep the original value
|
|
147
156
|
return { ...acc, [key]: value };
|
|
148
157
|
}, {});
|
|
149
158
|
};
|
|
150
159
|
exports.parseRemotes = parseRemotes;
|
|
151
160
|
/**
|
|
152
161
|
* Checks if the remote value is an internal delegate module reference.
|
|
162
|
+
* An internal delegate module reference starts with the string 'internal '.
|
|
153
163
|
*
|
|
154
164
|
* @param {string} value - The remote value to check.
|
|
155
|
-
* @returns {boolean} -
|
|
165
|
+
* @returns {boolean} - Returns true if the value is an internal delegate module reference, otherwise returns false.
|
|
156
166
|
*/
|
|
157
167
|
const isInternalDelegate = (value) => {
|
|
158
168
|
return value.startsWith('internal ');
|
|
159
169
|
};
|
|
160
170
|
/**
|
|
161
|
-
*
|
|
171
|
+
* Extracts the delegate modules from the provided remotes object.
|
|
172
|
+
* This function iterates over the remotes object and checks if each remote value is an internal delegate module reference.
|
|
173
|
+
* If it is, the function adds it to the returned object.
|
|
162
174
|
*
|
|
163
|
-
* @param {Record<string, any>} remotes - The remotes object containing
|
|
164
|
-
* @returns {Record<string, string>} -
|
|
175
|
+
* @param {Record<string, any>} remotes - The remotes object containing delegate module references.
|
|
176
|
+
* @returns {Record<string, string>} - An object containing only the delegate modules from the remotes object.
|
|
165
177
|
*/
|
|
166
|
-
const getDelegates = (remotes) => {
|
|
167
|
-
return Object.entries(remotes).reduce((acc, [key, value]) => {
|
|
168
|
-
if (isInternalDelegate(value)) {
|
|
169
|
-
return { ...acc, [key]: value };
|
|
170
|
-
}
|
|
171
|
-
return acc;
|
|
172
|
-
}, {});
|
|
173
|
-
};
|
|
178
|
+
const getDelegates = (remotes) => Object.entries(remotes).reduce((acc, [key, value]) => isInternalDelegate(value) ? { ...acc, [key]: value } : acc, {});
|
|
174
179
|
exports.getDelegates = getDelegates;
|
|
175
180
|
/**
|
|
176
|
-
* Validates the shared item type and
|
|
181
|
+
* Validates the shared item type and constructs a shared configuration object based on the item and key.
|
|
182
|
+
* If the item is the same as the key or if the item does not require a specific version,
|
|
183
|
+
* the function returns an object with the import property set to the item.
|
|
184
|
+
* Otherwise, it returns an object with the import property set to the key and the requiredVersion property set to the item.
|
|
177
185
|
*
|
|
178
|
-
* @param {string} item - The shared item.
|
|
179
|
-
* @param {string} key - The key
|
|
180
|
-
* @returns {object} - The shared
|
|
181
|
-
* @throws {Error} -
|
|
186
|
+
* @param {string} item - The shared item to be validated and used in the shared configuration object.
|
|
187
|
+
* @param {string} key - The key associated with the shared item.
|
|
188
|
+
* @returns {object} - The constructed shared configuration object.
|
|
189
|
+
* @throws {Error} - Throws an error if the item type is not a string.
|
|
182
190
|
*/
|
|
183
191
|
const getSharedConfig = (item, key) => {
|
|
184
192
|
if (typeof item !== 'string') {
|
|
@@ -194,12 +202,15 @@ const getSharedConfig = (item, key) => {
|
|
|
194
202
|
};
|
|
195
203
|
};
|
|
196
204
|
/**
|
|
197
|
-
* Parses the share options
|
|
198
|
-
*
|
|
199
|
-
* of
|
|
205
|
+
* Parses the share options from the provided ModuleFederationPluginOptions object and constructs a new object containing all shared configurations.
|
|
206
|
+
* This newly constructed object is then used as the value for the 'shared' property of the Module Federation Plugin Options.
|
|
207
|
+
* The function uses the 'parseOptions' utility function from webpack to parse the 'shared' property of the provided options object.
|
|
208
|
+
* The 'getSharedConfig' function is used as the 'config' argument for 'parseOptions' to construct the shared configuration object for each shared item.
|
|
209
|
+
* The 'item' argument for 'parseOptions' is a function that simply returns the item as it is.
|
|
210
|
+
* The function then reduces the parsed shared options into a new object with the shared configuration for each shared item.
|
|
200
211
|
*
|
|
201
|
-
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions object.
|
|
202
|
-
* @returns {Record<string, SharedConfig>} -
|
|
212
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions object to parse the share options from.
|
|
213
|
+
* @returns {Record<string, SharedConfig>} - An object containing the shared configuration for each shared item.
|
|
203
214
|
*/
|
|
204
215
|
const parseShareOptions = (options) => {
|
|
205
216
|
const sharedOptions = (0, options_1.parseOptions)(options.shared, getSharedConfig, (item) => item);
|
|
@@ -218,10 +229,11 @@ const parseShareOptions = (options) => {
|
|
|
218
229
|
}, {});
|
|
219
230
|
};
|
|
220
231
|
/**
|
|
221
|
-
*
|
|
232
|
+
* Takes an error object and formats it into a displayable string.
|
|
233
|
+
* If the error object contains a stack trace, it is appended to the error message.
|
|
222
234
|
*
|
|
223
|
-
* @param {Error} error - The error object to
|
|
224
|
-
* @returns {string} - The formatted error string.
|
|
235
|
+
* @param {Error} error - The error object to be formatted.
|
|
236
|
+
* @returns {string} - The formatted error message string. If a stack trace is present in the error object, it is appended to the error message.
|
|
225
237
|
*/
|
|
226
238
|
const formatError = (error) => {
|
|
227
239
|
let { message } = error;
|
|
@@ -231,11 +243,11 @@ const formatError = (error) => {
|
|
|
231
243
|
return message;
|
|
232
244
|
};
|
|
233
245
|
/**
|
|
234
|
-
*
|
|
235
|
-
* separated by newline characters.
|
|
246
|
+
* Transforms an array of Error objects into a single string. Each error message is formatted using the 'formatError' function.
|
|
247
|
+
* The resulting error messages are then joined together, separated by newline characters.
|
|
236
248
|
*
|
|
237
|
-
* @param {Error[]} err -
|
|
238
|
-
* @returns {string} -
|
|
249
|
+
* @param {Error[]} err - An array of Error objects that need to be formatted and combined.
|
|
250
|
+
* @returns {string} - A single string containing all the formatted error messages, separated by newline characters.
|
|
239
251
|
*/
|
|
240
252
|
const toDisplayErrors = (err) => {
|
|
241
253
|
return err.map(formatError).join('\n');
|
package/src/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/src/internal.ts"],"names":[],"mappings":";;;AAKA,4DAAqE;AAErE,qDAA8D;AAC9D,2DAA6D;AAE7D;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAiB;IAC/C,cAAc,EAAE;QACd,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/src/internal.ts"],"names":[],"mappings":";;;AAKA,4DAAqE;AAErE,qDAA8D;AAC9D,2DAA6D;AAE7D;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAiB;IAC/C,cAAc,EAAE;QACd,eAAe,EAAE,SAAS;QAC1B,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,SAAS;KAClB;IACD,WAAW,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,SAAS;KAClB;IACD,WAAW,EAAE;QACX,eAAe,EAAE,SAAS;QAC1B,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,SAAS;KAClB;IACD,aAAa,EAAE;QACb,eAAe,EAAE,SAAS;QAC1B,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,SAAS;KAClB;IACD,8BAA8B,EAAC;QAC7B,KAAK,EAAC,IAAI;QACV,eAAe,EAAE,KAAK;KACvB;IACD,YAAY,EAAE;QACZ,eAAe,EAAE,SAAS;QAC1B,SAAS,EAAE,IAAI;QACf,MAA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EF,OAAO,aAAa,CAAC,MAAM,CACzB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;QACtB,GAAG,CAAC,GAAG,CAAC,GAAG;YACT,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,GAAG;YACjC,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAkC,CACnC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,KAAY,EAAU,EAAE;IAC3C,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACxB,IAAI,KAAK,CAAC,KAAK,EAAE;QACf,OAAO,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC;KAC/B;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,CAAC,GAAY,EAAU,EAAE;IACtD,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { LoaderContext } from 'webpack';
|
|
2
2
|
/**
|
|
3
|
+
* This function patches the default shared loader.
|
|
4
|
+
* It requires either the default delegate module or a custom one.
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
+
* @param {LoaderContext<Record<string, unknown>>} this - The loader context.
|
|
7
|
+
* @param {string} content - The content to be processed.
|
|
8
|
+
* @returns {string} The processed content with required delegates.
|
|
6
9
|
*/
|
|
7
10
|
export default function patchDefaultSharedLoader(this: LoaderContext<Record<string, unknown>>, content: string): string;
|
|
@@ -1,32 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
+
* This function patches the default shared loader.
|
|
5
|
+
* It requires either the default delegate module or a custom one.
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
+
* @param {LoaderContext<Record<string, unknown>>} this - The loader context.
|
|
8
|
+
* @param {string} content - The content to be processed.
|
|
9
|
+
* @returns {string} The processed content with required delegates.
|
|
7
10
|
*/
|
|
8
11
|
function patchDefaultSharedLoader(content) {
|
|
9
12
|
const { delegates } = this.getOptions();
|
|
13
|
+
/**
|
|
14
|
+
* Resolves delegates by splitting the delegate into request and query.
|
|
15
|
+
* If a query is present, it is parsed and appended to the request.
|
|
16
|
+
* The request is then contextified and absolutified.
|
|
17
|
+
*/
|
|
10
18
|
const resolvedDelegates = Object.values(delegates).map((delegate) => {
|
|
11
19
|
const [request, query] = delegate.replace('internal ', '').split('?');
|
|
12
20
|
if (query) {
|
|
13
21
|
const queries = [];
|
|
14
22
|
for (const [key, value] of new URLSearchParams(query).entries()) {
|
|
15
|
-
queries.push(`${key}=${value}`);
|
|
23
|
+
queries.push(`${key}=${encodeURIComponent(value)}`);
|
|
16
24
|
}
|
|
17
|
-
|
|
25
|
+
return this.utils.contextify(this.context, this.utils.absolutify(this._compiler?.context || '', request) +
|
|
18
26
|
'?' +
|
|
19
27
|
queries.join('&'));
|
|
20
|
-
return delegatePath;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const delegatePath = this.utils.contextify(this.context, this.utils.absolutify(this._compiler?.context || '', request));
|
|
24
|
-
return delegatePath;
|
|
25
28
|
}
|
|
29
|
+
return request;
|
|
26
30
|
});
|
|
31
|
+
/**
|
|
32
|
+
* If the content includes 'hasDelegateMarkers', return the content as is.
|
|
33
|
+
*/
|
|
27
34
|
if (content.includes('hasDelegateMarkers')) {
|
|
28
35
|
return content;
|
|
29
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Requires each resolved delegate and appends it to the content.
|
|
39
|
+
*/
|
|
30
40
|
const requiredDelegates = resolvedDelegates.map((delegate) => {
|
|
31
41
|
return `require('${delegate}')`;
|
|
32
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegateLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/delegateLoader.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"delegateLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/delegateLoader.ts"],"names":[],"mappings":";;AAEA;;;;;;;GAOG;AACH,SAAwB,wBAAwB,CAE9C,OAAe;IAEf,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,UAAU,EAA4B,CAAC;IAElE;;;;OAIG;IACH,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtE,IAAI,KAAK,EAAE;YACT,MAAM,OAAO,GAAG,EAAE,CAAC;YACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC/D,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aACrD;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAC1B,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC;gBAC3D,GAAG;gBACH,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CACpB,CAAC;SACH;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH;;OAEG;IACH,IAAI,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE;QAC1C,OAAO,OAAO,CAAC;KAChB;IAED;;OAEG;IACH,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC3D,OAAO,YAAY,QAAQ,IAAI,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,EAAE,GAAG,iBAAiB,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChF,CAAC;AA3CD,2CA2CC"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import type { LoaderContext } from 'webpack';
|
|
2
2
|
/**
|
|
3
|
-
* This loader
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* for ssr:
|
|
9
|
-
* remote scope of specific remote url
|
|
10
|
-
* for csr:
|
|
11
|
-
* document.currentScript.src
|
|
12
|
-
* after that, it will choose the full uri before _next
|
|
3
|
+
* This loader is specifically created for tuning the next-image-loader result.
|
|
4
|
+
* It modifies the regular string output of the next-image-loader.
|
|
5
|
+
* For server-side rendering (SSR), it injects the remote scope of a specific remote URL.
|
|
6
|
+
* For client-side rendering (CSR), it injects the document.currentScript.src.
|
|
7
|
+
* After these injections, it selects the full URI before _next.
|
|
13
8
|
*
|
|
14
|
-
*
|
|
9
|
+
* @example
|
|
15
10
|
* http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
|
|
16
11
|
* will become
|
|
17
12
|
* http://localhost:1234/test/test2
|
|
18
13
|
*
|
|
14
|
+
* @param {LoaderContext<Record<string, unknown>>} this - The loader context.
|
|
15
|
+
* @param {string} remaining - The remaining part of the resource path.
|
|
16
|
+
* @returns {string} The modified source code with the injected code.
|
|
19
17
|
*/
|
|
20
18
|
export declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* The pitch function of the loader, which is the same as the fixImageLoader function.
|
|
21
|
+
*/
|
|
21
22
|
export declare const pitch: typeof fixImageLoader;
|
|
@@ -7,27 +7,26 @@ exports.pitch = exports.fixImageLoader = void 0;
|
|
|
7
7
|
const webpack_1 = require("webpack");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
/**
|
|
10
|
-
* This loader
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* for ssr:
|
|
16
|
-
* remote scope of specific remote url
|
|
17
|
-
* for csr:
|
|
18
|
-
* document.currentScript.src
|
|
19
|
-
* after that, it will choose the full uri before _next
|
|
10
|
+
* This loader is specifically created for tuning the next-image-loader result.
|
|
11
|
+
* It modifies the regular string output of the next-image-loader.
|
|
12
|
+
* For server-side rendering (SSR), it injects the remote scope of a specific remote URL.
|
|
13
|
+
* For client-side rendering (CSR), it injects the document.currentScript.src.
|
|
14
|
+
* After these injections, it selects the full URI before _next.
|
|
20
15
|
*
|
|
21
|
-
*
|
|
16
|
+
* @example
|
|
22
17
|
* http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
|
|
23
18
|
* will become
|
|
24
19
|
* http://localhost:1234/test/test2
|
|
25
20
|
*
|
|
21
|
+
* @param {LoaderContext<Record<string, unknown>>} this - The loader context.
|
|
22
|
+
* @param {string} remaining - The remaining part of the resource path.
|
|
23
|
+
* @returns {string} The modified source code with the injected code.
|
|
26
24
|
*/
|
|
27
25
|
async function fixImageLoader(remaining) {
|
|
28
26
|
this.cacheable(true);
|
|
29
27
|
const isServer = this._compiler?.options.name !== 'client';
|
|
30
|
-
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
const { publicPath } = this._compiler?.webpack.RuntimeGlobals;
|
|
31
30
|
const result = await this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!${remaining}`);
|
|
32
31
|
const content = (result.default || result);
|
|
33
32
|
const computedAssetPrefix = isServer
|
|
@@ -36,7 +35,9 @@ async function fixImageLoader(remaining) {
|
|
|
36
35
|
webpack_1.Template.asString([
|
|
37
36
|
'try {',
|
|
38
37
|
webpack_1.Template.indent([
|
|
39
|
-
'const
|
|
38
|
+
'const config = globalThis.__remote_scope__ &&',
|
|
39
|
+
'globalThis.__remote_scope__._config;',
|
|
40
|
+
`const remoteEntry = config[__webpack_runtime_id__] || ${publicPath}`,
|
|
40
41
|
`if (remoteEntry) {`,
|
|
41
42
|
webpack_1.Template.indent([
|
|
42
43
|
`const splitted = remoteEntry.split('/_next')`,
|
|
@@ -97,5 +98,8 @@ async function fixImageLoader(remaining) {
|
|
|
97
98
|
]);
|
|
98
99
|
}
|
|
99
100
|
exports.fixImageLoader = fixImageLoader;
|
|
101
|
+
/**
|
|
102
|
+
* The pitch function of the loader, which is the same as the fixImageLoader function.
|
|
103
|
+
*/
|
|
100
104
|
exports.pitch = fixImageLoader;
|
|
101
105
|
//# sourceMappingURL=fixImageLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;;;AACA,qCAAmC;AACnC,gDAAwB;AAExB;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,cAAc,CAElC,SAAiB;IAEjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErB,MAAM,QAA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BACpE,6DAA6D;oBAC7D,YAAY;iBACb,CAAC;gBACF,GAAG;aACJ,CAAC;YACF,KAAK;SACN,CAAC,EAAE,CAAC;IAET,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CACtD,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACnC,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1B;YACD,GAAG,CAAC,IAAI,CACN,GAAG,GAAG,qCAAqC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACnE,CAAC;YACF,OAAO,GAAG,CAAC;SACZ;QACD,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7C,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAc,CACf,CAAC;IAEF,OAAO,kBAAQ,CAAC,QAAQ,CAAC;QACvB,yCAAyC;QACzC,OAAO;QACP,kBAAQ,CAAC,MAAM,CAAC,mCAAmC,mBAAmB,GAAG,CAAC;QAC1E,gBAAgB;QAChB,kBAAkB;QAClB,kBAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,GAAG;KACJ,CAAC,CAAC;AACL,CAAC;AA5FD,wCA4FC;AAED;;GAEG;AACU,QAAA,KAAK,GAAG,cAAc,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `fixUrlLoader` is a custom loader designed to modify the output of the url-loader.
|
|
3
|
+
* It injects the PUBLIC_PATH from the webpack runtime into the output.
|
|
4
|
+
* The output format is: `export default __webpack_require__.p + "/static/media/ssl.e3019f0e.svg"`
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
+
* `__webpack_require__.p` is a global variable in the webpack container that contains the publicPath.
|
|
7
|
+
* For example, it could be: http://localhost:3000/_next
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @type {(this: import("webpack").LoaderContext<{}>, content: string) => string>}
|
|
9
|
+
* @param {string} content - The original output from the url-loader.
|
|
10
|
+
* @returns {string} The modified output with the injected PUBLIC_PATH.
|
|
11
11
|
*/
|
|
12
12
|
export declare function fixUrlLoader(content: string): string;
|
|
13
13
|
export default fixUrlLoader;
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fixUrlLoader = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* `fixUrlLoader` is a custom loader designed to modify the output of the url-loader.
|
|
6
|
+
* It injects the PUBLIC_PATH from the webpack runtime into the output.
|
|
7
|
+
* The output format is: `export default __webpack_require__.p + "/static/media/ssl.e3019f0e.svg"`
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* `__webpack_require__.p` is a global variable in the webpack container that contains the publicPath.
|
|
10
|
+
* For example, it could be: http://localhost:3000/_next
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @type {(this: import("webpack").LoaderContext<{}>, content: string) => string>}
|
|
12
|
+
* @param {string} content - The original output from the url-loader.
|
|
13
|
+
* @returns {string} The modified output with the injected PUBLIC_PATH.
|
|
14
14
|
*/
|
|
15
15
|
function fixUrlLoader(content) {
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// http://localhost:3000/_next/... -> http://localhost:3000
|
|
16
|
+
// This regular expression extracts the hostname from the publicPath.
|
|
17
|
+
// For example, it transforms http://localhost:3000/_next/... into http://localhost:3000
|
|
19
18
|
const currentHostnameCode = "__webpack_require__.p.replace(/(.+\\:\\/\\/[^\\/]+){0,1}\\/.*/i, '$1')";
|
|
19
|
+
// Replace the default export path in the content with the modified path that includes the hostname.
|
|
20
20
|
return content.replace('export default "/', `export default ${currentHostnameCode}+"/`);
|
|
21
21
|
}
|
|
22
22
|
exports.fixUrlLoader = fixUrlLoader;
|
|
23
|
-
//
|
|
23
|
+
// Export the fixUrlLoader function as the default export of this module.
|
|
24
24
|
exports.default = fixUrlLoader;
|
|
25
25
|
//# sourceMappingURL=fixUrlLoader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixUrlLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixUrlLoader.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,
|
|
1
|
+
{"version":3,"file":"fixUrlLoader.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/loaders/fixUrlLoader.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,qEAAqE;IACrE,wFAAwF;IACxF,MAAM,mBAAmB,GACvB,wEAAwE,CAAC;IAE3E,oGAAoG;IACpG,OAAO,OAAO,CAAC,OAAO,CACpB,mBAAmB,EACnB,kBAAkB,mBAAmB,KAAK,CAC3C,CAAC;AACJ,CAAC;AAXD,oCAWC;AAED,yEAAyE;AACzE,kBAAe,YAAY,CAAC"}
|
package/src/loaders/helpers.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { RuleSetRuleUnion, Loader } from '@module-federation/utilities';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This function mutates `rule` argument
|
|
3
|
+
* This function injects a loader into the current module rule.
|
|
4
|
+
* Note: This function mutates the `rule` argument.
|
|
5
|
+
*
|
|
6
|
+
* @param {RuleSetRuleUnion} rule - The current module rule.
|
|
7
|
+
* @param {Loader} [loader={}] - The loader to be injected.
|
|
5
8
|
*/
|
|
6
9
|
export declare function injectRuleLoader(rule: RuleSetRuleUnion, loader?: Loader): void;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* This function checks if the current module rule has a loader with the provided name.
|
|
12
|
+
*
|
|
13
|
+
* @param {RuleSetRuleUnion} rule - The current module rule.
|
|
14
|
+
* @param {string} loaderName - The name of the loader to check.
|
|
15
|
+
* @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
|
|
9
16
|
*/
|
|
10
17
|
export declare function hasLoader(rule: RuleSetRuleUnion, loaderName: string): boolean;
|