@module-federation/nextjs-mf 8.8.56 → 8.8.57
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/dist/LICENSE +21 -0
- package/dist/_virtual/_rolldown/runtime.js +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/client/UrlNode.js +89 -147
- package/dist/client/UrlNode.js.map +1 -1
- package/dist/client/UrlNode.mjs +91 -0
- package/dist/client/UrlNode.mjs.map +1 -0
- package/dist/src/federation-noop.d.mts +1 -0
- package/dist/src/federation-noop.d.ts +1 -0
- package/dist/src/federation-noop.js +17 -0
- package/dist/src/federation-noop.js.map +1 -1
- package/dist/src/federation-noop.mjs +23 -0
- package/dist/src/federation-noop.mjs.map +1 -0
- package/dist/src/index.d.mts +2 -0
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.js +13 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +8 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/internal.js +140 -243
- package/dist/src/internal.js.map +1 -1
- package/dist/src/internal.mjs +152 -0
- package/dist/src/internal.mjs.map +1 -0
- package/dist/src/loaders/fixImageLoader.d.mts +27 -0
- package/dist/src/loaders/fixImageLoader.d.ts +8 -3
- package/dist/src/loaders/fixImageLoader.js +91 -103
- package/dist/src/loaders/fixImageLoader.js.map +1 -1
- package/dist/src/loaders/fixImageLoader.mjs +101 -0
- package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
- package/dist/src/loaders/fixUrlLoader.d.mts +16 -0
- package/dist/src/loaders/fixUrlLoader.d.ts +5 -2
- package/dist/src/loaders/fixUrlLoader.js +17 -19
- package/dist/src/loaders/fixUrlLoader.js.map +1 -1
- package/dist/src/loaders/fixUrlLoader.mjs +19 -0
- package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
- package/dist/src/loaders/helpers.js +72 -124
- package/dist/src/loaders/helpers.js.map +1 -1
- package/dist/src/loaders/helpers.mjs +79 -0
- package/dist/src/loaders/helpers.mjs.map +1 -0
- package/dist/src/loaders/nextPageMapLoader.d.mts +29 -0
- package/dist/src/loaders/nextPageMapLoader.d.ts +10 -5
- package/dist/src/loaders/nextPageMapLoader.js +126 -144
- package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
- package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
- package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
- package/dist/src/logger.js +7 -7
- package/dist/src/logger.js.map +1 -1
- package/dist/src/logger.mjs +8 -0
- package/dist/src/logger.mjs.map +1 -0
- package/dist/src/plugins/CopyFederationPlugin.js +64 -71
- package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
- package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
- package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +36 -53
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +40 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.mts +31 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.ts +27 -23
- package/dist/src/plugins/NextFederationPlugin/index.js +147 -181
- package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/index.mjs +150 -0
- package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +18 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +16 -18
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js +62 -92
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +68 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
- package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
- package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.js +22 -25
- package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs +23 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/container/runtimePlugin.d.mts +7 -0
- package/dist/src/plugins/container/runtimePlugin.d.ts +6 -2
- package/dist/src/plugins/container/runtimePlugin.js +167 -0
- package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
- package/dist/src/plugins/container/runtimePlugin.mjs +166 -0
- package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
- package/dist/utils/flushedChunks.d.mts +29 -0
- package/dist/utils/flushedChunks.d.ts +12 -5
- package/dist/utils/flushedChunks.js +32 -72
- package/dist/utils/flushedChunks.js.map +1 -1
- package/dist/utils/flushedChunks.mjs +35 -0
- package/dist/utils/flushedChunks.mjs.map +1 -0
- package/dist/utils/index.d.mts +14 -0
- package/dist/utils/index.d.ts +8 -14
- package/dist/utils/index.js +27 -62
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +22 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +29 -9
- package/dist/client/UrlNode.d.ts +0 -17
- package/dist/node.d.ts +0 -1
- package/dist/node.js +0 -18
- package/dist/node.js.map +0 -1
- package/dist/package.json +0 -80
- package/dist/src/federation-noop.cjs +0 -15
- package/dist/src/internal.d.ts +0 -50
- package/dist/src/loaders/helpers.d.ts +0 -17
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +0 -5
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
- package/dist/src/plugins/CopyFederationPlugin.d.ts +0 -20
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +0 -23
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +0 -36
- package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +0 -14
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js +0 -25
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +0 -8
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +0 -16
- package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +0 -25
- package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +0 -5
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +0 -11
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +0 -39
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
- package/dist/src/plugins/container/runtimePlugin.cjs +0 -219
- package/dist/src/plugins/container/types.d.ts +0 -2
- package/dist/src/plugins/container/types.js +0 -3
- package/dist/src/plugins/container/types.js.map +0 -1
- package/dist/src/types.d.ts +0 -28
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
package/dist/src/internal.js
CHANGED
|
@@ -1,255 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.toDisplayErrors = exports.getDelegates = exports.parseRemotes = exports.DEFAULT_SHARE_SCOPE_BROWSER = exports.DEFAULT_SHARE_SCOPE = void 0;
|
|
1
|
+
|
|
2
|
+
//#region src/internal.ts
|
|
4
3
|
const WEBPACK_LAYERS_NAMES = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Server Side Rendering layer for app (ssr).
|
|
16
|
-
*/
|
|
17
|
-
serverSideRendering: 'ssr',
|
|
18
|
-
/**
|
|
19
|
-
* The browser client bundle layer for actions.
|
|
20
|
-
*/
|
|
21
|
-
actionBrowser: 'action-browser',
|
|
22
|
-
/**
|
|
23
|
-
* The layer for the API routes.
|
|
24
|
-
*/
|
|
25
|
-
api: 'api',
|
|
26
|
-
/**
|
|
27
|
-
* The layer for the middleware code.
|
|
28
|
-
*/
|
|
29
|
-
middleware: 'middleware',
|
|
30
|
-
/**
|
|
31
|
-
* The layer for the instrumentation hooks.
|
|
32
|
-
*/
|
|
33
|
-
instrument: 'instrument',
|
|
34
|
-
/**
|
|
35
|
-
* The layer for assets on the edge.
|
|
36
|
-
*/
|
|
37
|
-
edgeAsset: 'edge-asset',
|
|
38
|
-
/**
|
|
39
|
-
* The browser client bundle layer for App directory.
|
|
40
|
-
*/
|
|
41
|
-
appPagesBrowser: 'app-pages-browser',
|
|
4
|
+
shared: "shared",
|
|
5
|
+
reactServerComponents: "rsc",
|
|
6
|
+
serverSideRendering: "ssr",
|
|
7
|
+
actionBrowser: "action-browser",
|
|
8
|
+
api: "api",
|
|
9
|
+
middleware: "middleware",
|
|
10
|
+
instrument: "instrument",
|
|
11
|
+
edgeAsset: "edge-asset",
|
|
12
|
+
appPagesBrowser: "app-pages-browser"
|
|
42
13
|
};
|
|
43
14
|
const createSharedConfig = (name, layers, options = {}) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
15
|
+
return layers.reduce((acc, layer) => {
|
|
16
|
+
const key = layer ? `${name}-${layer}` : name;
|
|
17
|
+
acc[key] = {
|
|
18
|
+
singleton: true,
|
|
19
|
+
requiredVersion: false,
|
|
20
|
+
import: layer ? void 0 : options.import ?? false,
|
|
21
|
+
shareKey: options.request ?? name,
|
|
22
|
+
request: options.request ?? name,
|
|
23
|
+
layer,
|
|
24
|
+
issuerLayer: layer
|
|
25
|
+
};
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
57
28
|
};
|
|
58
29
|
const defaultLayers = [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
30
|
+
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
31
|
+
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
32
|
+
void 0
|
|
62
33
|
];
|
|
63
|
-
const navigationLayers = [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
request: 'react-dom',
|
|
70
|
-
});
|
|
71
|
-
const jsxRuntimeShares = createSharedConfig('react/', navigationLayers, {
|
|
72
|
-
request: 'react/',
|
|
73
|
-
import: undefined,
|
|
34
|
+
const navigationLayers = [WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.serverSideRendering];
|
|
35
|
+
createSharedConfig("react", defaultLayers);
|
|
36
|
+
createSharedConfig("react", defaultLayers, { request: "react-dom" });
|
|
37
|
+
createSharedConfig("react/", navigationLayers, {
|
|
38
|
+
request: "react/",
|
|
39
|
+
import: void 0
|
|
74
40
|
});
|
|
75
|
-
|
|
41
|
+
createSharedConfig("next-navigation", navigationLayers, { request: "next/navigation" });
|
|
76
42
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
import: undefined,
|
|
165
|
-
version: require('styled-jsx/package.json').version,
|
|
166
|
-
requiredVersion: '^' + require('styled-jsx/package.json').version,
|
|
167
|
-
},
|
|
43
|
+
* @typedef SharedObject
|
|
44
|
+
* @type {object}
|
|
45
|
+
* @property {object} [key] - The key representing the shared object's package name.
|
|
46
|
+
* @property {boolean} key.singleton - Whether the shared object should be a singleton.
|
|
47
|
+
* @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required.
|
|
48
|
+
* @property {boolean} key.eager - Whether the shared object should be eagerly loaded.
|
|
49
|
+
* @property {boolean} key.import - Whether the shared object should be imported or not.
|
|
50
|
+
* @property {string} key.layer - The webpack layer this shared module belongs to.
|
|
51
|
+
* @property {string|string[]} key.issuerLayer - The webpack layer that can import this shared module.
|
|
52
|
+
*/
|
|
53
|
+
const DEFAULT_SHARE_SCOPE = {
|
|
54
|
+
"next/dynamic": {
|
|
55
|
+
requiredVersion: void 0,
|
|
56
|
+
singleton: true,
|
|
57
|
+
import: void 0
|
|
58
|
+
},
|
|
59
|
+
"next/head": {
|
|
60
|
+
requiredVersion: void 0,
|
|
61
|
+
singleton: true,
|
|
62
|
+
import: void 0
|
|
63
|
+
},
|
|
64
|
+
"next/link": {
|
|
65
|
+
requiredVersion: void 0,
|
|
66
|
+
singleton: true,
|
|
67
|
+
import: void 0
|
|
68
|
+
},
|
|
69
|
+
"next/router": {
|
|
70
|
+
requiredVersion: false,
|
|
71
|
+
singleton: true,
|
|
72
|
+
import: void 0
|
|
73
|
+
},
|
|
74
|
+
"next/image": {
|
|
75
|
+
requiredVersion: void 0,
|
|
76
|
+
singleton: true,
|
|
77
|
+
import: void 0
|
|
78
|
+
},
|
|
79
|
+
"next/script": {
|
|
80
|
+
requiredVersion: void 0,
|
|
81
|
+
singleton: true,
|
|
82
|
+
import: void 0
|
|
83
|
+
},
|
|
84
|
+
react: {
|
|
85
|
+
singleton: true,
|
|
86
|
+
requiredVersion: false,
|
|
87
|
+
import: false
|
|
88
|
+
},
|
|
89
|
+
"react/": {
|
|
90
|
+
singleton: true,
|
|
91
|
+
requiredVersion: false,
|
|
92
|
+
import: false
|
|
93
|
+
},
|
|
94
|
+
"react-dom/": {
|
|
95
|
+
singleton: true,
|
|
96
|
+
requiredVersion: false,
|
|
97
|
+
import: false
|
|
98
|
+
},
|
|
99
|
+
"react-dom": {
|
|
100
|
+
singleton: true,
|
|
101
|
+
requiredVersion: false,
|
|
102
|
+
import: false
|
|
103
|
+
},
|
|
104
|
+
"react/jsx-dev-runtime": {
|
|
105
|
+
singleton: true,
|
|
106
|
+
requiredVersion: false
|
|
107
|
+
},
|
|
108
|
+
"react/jsx-runtime": {
|
|
109
|
+
singleton: true,
|
|
110
|
+
requiredVersion: false
|
|
111
|
+
},
|
|
112
|
+
"styled-jsx": {
|
|
113
|
+
singleton: true,
|
|
114
|
+
import: void 0,
|
|
115
|
+
version: require("styled-jsx/package.json").version,
|
|
116
|
+
requiredVersion: "^" + require("styled-jsx/package.json").version
|
|
117
|
+
},
|
|
118
|
+
"styled-jsx/style": {
|
|
119
|
+
singleton: true,
|
|
120
|
+
import: false,
|
|
121
|
+
version: require("styled-jsx/package.json").version,
|
|
122
|
+
requiredVersion: "^" + require("styled-jsx/package.json").version
|
|
123
|
+
},
|
|
124
|
+
"styled-jsx/css": {
|
|
125
|
+
singleton: true,
|
|
126
|
+
import: void 0,
|
|
127
|
+
version: require("styled-jsx/package.json").version,
|
|
128
|
+
requiredVersion: "^" + require("styled-jsx/package.json").version
|
|
129
|
+
}
|
|
168
130
|
};
|
|
169
131
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
132
|
+
* Defines a default share scope for the browser environment.
|
|
133
|
+
* This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.
|
|
134
|
+
* For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.
|
|
135
|
+
* The module hoisting system relocates these modules into the right runtime and out of the remote.
|
|
136
|
+
*
|
|
137
|
+
* @type {SharedObject}
|
|
138
|
+
* @returns {SharedObject} - The modified share scope for the browser environment.
|
|
139
|
+
*/
|
|
140
|
+
const DEFAULT_SHARE_SCOPE_BROWSER = Object.entries(DEFAULT_SHARE_SCOPE).reduce((acc, item) => {
|
|
141
|
+
const [key, value] = item;
|
|
142
|
+
acc[key] = {
|
|
143
|
+
...value,
|
|
144
|
+
import: void 0
|
|
145
|
+
};
|
|
146
|
+
return acc;
|
|
183
147
|
}, {});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
* @returns {boolean} - True if the value is an internal or promise delegate module reference, false otherwise.
|
|
189
|
-
*/
|
|
190
|
-
const isInternalOrPromise = (value) => ['internal ', 'promise '].some((prefix) => value.startsWith(prefix));
|
|
191
|
-
/**
|
|
192
|
-
* Parses the remotes object and checks if they are using a custom promise template or not.
|
|
193
|
-
* If it's a custom promise template, the remote syntax is parsed to get the module name and version number.
|
|
194
|
-
* If the remote value is using the standard remote syntax, a delegated module is created.
|
|
195
|
-
*
|
|
196
|
-
* @param {Record<string, any>} remotes - The remotes object to be parsed.
|
|
197
|
-
* @returns {Record<string, string>} - The parsed remotes object with either the original value,
|
|
198
|
-
* the value for internal or promise delegate module reference, or the created delegated module.
|
|
199
|
-
*/
|
|
200
|
-
const parseRemotes = (remotes) => {
|
|
201
|
-
return Object.entries(remotes).reduce((acc, [key, value]) => {
|
|
202
|
-
if (isInternalOrPromise(value)) {
|
|
203
|
-
// If the value is an internal or promise delegate module reference, keep the original value
|
|
204
|
-
return { ...acc, [key]: value };
|
|
205
|
-
}
|
|
206
|
-
return { ...acc, [key]: value };
|
|
207
|
-
}, {});
|
|
208
|
-
};
|
|
209
|
-
exports.parseRemotes = parseRemotes;
|
|
210
|
-
/**
|
|
211
|
-
* Checks if the remote value is an internal delegate module reference.
|
|
212
|
-
* An internal delegate module reference starts with the string 'internal '.
|
|
213
|
-
*
|
|
214
|
-
* @param {string} value - The remote value to check.
|
|
215
|
-
* @returns {boolean} - Returns true if the value is an internal delegate module reference, otherwise returns false.
|
|
216
|
-
*/
|
|
217
|
-
const isInternalDelegate = (value) => {
|
|
218
|
-
return value.startsWith('internal ');
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Extracts the delegate modules from the provided remotes object.
|
|
222
|
-
* This function iterates over the remotes object and checks if each remote value is an internal delegate module reference.
|
|
223
|
-
* If it is, the function adds it to the returned object.
|
|
224
|
-
*
|
|
225
|
-
* @param {Record<string, any>} remotes - The remotes object containing delegate module references.
|
|
226
|
-
* @returns {Record<string, string>} - An object containing only the delegate modules from the remotes object.
|
|
227
|
-
*/
|
|
228
|
-
const getDelegates = (remotes) => Object.entries(remotes).reduce((acc, [key, value]) => isInternalDelegate(value) ? { ...acc, [key]: value } : acc, {});
|
|
229
|
-
exports.getDelegates = getDelegates;
|
|
230
|
-
/**
|
|
231
|
-
* Takes an error object and formats it into a displayable string.
|
|
232
|
-
* If the error object contains a stack trace, it is appended to the error message.
|
|
233
|
-
*
|
|
234
|
-
* @param {Error} error - The error object to be formatted.
|
|
235
|
-
* @returns {string} - The formatted error message string. If a stack trace is present in the error object, it is appended to the error message.
|
|
236
|
-
*/
|
|
237
|
-
const formatError = (error) => {
|
|
238
|
-
let { message } = error;
|
|
239
|
-
if (error.stack) {
|
|
240
|
-
message += `\n${error.stack}`;
|
|
241
|
-
}
|
|
242
|
-
return message;
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* Transforms an array of Error objects into a single string. Each error message is formatted using the 'formatError' function.
|
|
246
|
-
* The resulting error messages are then joined together, separated by newline characters.
|
|
247
|
-
*
|
|
248
|
-
* @param {Error[]} err - An array of Error objects that need to be formatted and combined.
|
|
249
|
-
* @returns {string} - A single string containing all the formatted error messages, separated by newline characters.
|
|
250
|
-
*/
|
|
251
|
-
const toDisplayErrors = (err) => {
|
|
252
|
-
return err.map(formatError).join('\n');
|
|
253
|
-
};
|
|
254
|
-
exports.toDisplayErrors = toDisplayErrors;
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
exports.DEFAULT_SHARE_SCOPE = DEFAULT_SHARE_SCOPE;
|
|
151
|
+
exports.DEFAULT_SHARE_SCOPE_BROWSER = DEFAULT_SHARE_SCOPE_BROWSER;
|
|
255
152
|
//# sourceMappingURL=internal.js.map
|
package/dist/src/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;AAUA,MAAM,oBAAoB,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,QAAQ;IAChB;;;OAGG;IACH,qBAAqB,EAAE,KAAK;IAC5B;;OAEG;IACH,mBAAmB,EAAE,KAAK;IAC1B;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,GAAG,EAAE,KAAK;IACV;;OAEG;IACH,UAAU,EAAE,YAAY;IACxB;;OAEG;IACH,UAAU,EAAE,YAAY;IACxB;;OAEG;IACH,SAAS,EAAE,YAAY;IACvB;;OAEG;IACH,eAAe,EAAE,mBAAmB;CAC5B,CAAC;AAEX,MAAM,kBAAkB,GAAG,CACzB,IAAY,EACZ,MAA8B,EAC9B,UAA4D,EAAE,EAC9D,EAAE;IACF,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACb,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,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+
{"version":3,"file":"internal.js","names":[],"sources":["../../src/internal.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\n\n// Extend the SharedConfig type to include layer properties\ntype ExtendedSharedConfig = moduleFederationPlugin.SharedConfig & {\n layer?: string;\n issuerLayer?: string | string[];\n request?: string;\n shareKey?: string;\n};\n\nconst WEBPACK_LAYERS_NAMES = {\n /**\n * The layer for the shared code between the client and server bundles.\n */\n shared: 'shared',\n /**\n * The layer for server-only runtime and picking up `react-server` export conditions.\n * Including app router RSC pages and app router custom routes and metadata routes.\n */\n reactServerComponents: 'rsc',\n /**\n * Server Side Rendering layer for app (ssr).\n */\n serverSideRendering: 'ssr',\n /**\n * The browser client bundle layer for actions.\n */\n actionBrowser: 'action-browser',\n /**\n * The layer for the API routes.\n */\n api: 'api',\n /**\n * The layer for the middleware code.\n */\n middleware: 'middleware',\n /**\n * The layer for the instrumentation hooks.\n */\n instrument: 'instrument',\n /**\n * The layer for assets on the edge.\n */\n edgeAsset: 'edge-asset',\n /**\n * The browser client bundle layer for App directory.\n */\n appPagesBrowser: 'app-pages-browser',\n} as const;\n\nconst createSharedConfig = (\n name: string,\n layers: (string | undefined)[],\n options: { request?: string; import?: false | undefined } = {},\n) => {\n return layers.reduce(\n (acc, layer) => {\n const key = layer ? `${name}-${layer}` : name;\n acc[key] = {\n singleton: true,\n requiredVersion: false,\n import: layer ? undefined : (options.import ?? false),\n shareKey: options.request ?? name,\n request: options.request ?? name,\n layer,\n issuerLayer: layer,\n };\n return acc;\n },\n {} as Record<string, ExtendedSharedConfig>,\n );\n};\n\nconst defaultLayers = [\n WEBPACK_LAYERS_NAMES.reactServerComponents,\n WEBPACK_LAYERS_NAMES.serverSideRendering,\n undefined,\n];\n\nconst navigationLayers = [\n WEBPACK_LAYERS_NAMES.reactServerComponents,\n WEBPACK_LAYERS_NAMES.serverSideRendering,\n];\n\nconst reactShares = createSharedConfig('react', defaultLayers);\nconst reactDomShares = createSharedConfig('react', defaultLayers, {\n request: 'react-dom',\n});\nconst jsxRuntimeShares = createSharedConfig('react/', navigationLayers, {\n request: 'react/',\n import: undefined,\n});\nconst nextNavigationShares = createSharedConfig(\n 'next-navigation',\n navigationLayers,\n { request: 'next/navigation' },\n);\n\n/**\n * @typedef SharedObject\n * @type {object}\n * @property {object} [key] - The key representing the shared object's package name.\n * @property {boolean} key.singleton - Whether the shared object should be a singleton.\n * @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required.\n * @property {boolean} key.eager - Whether the shared object should be eagerly loaded.\n * @property {boolean} key.import - Whether the shared object should be imported or not.\n * @property {string} key.layer - The webpack layer this shared module belongs to.\n * @property {string|string[]} key.issuerLayer - The webpack layer that can import this shared module.\n */\nexport const DEFAULT_SHARE_SCOPE: moduleFederationPlugin.SharedObject = {\n // ...reactShares,\n // ...reactDomShares,\n // ...nextNavigationShares,\n // ...jsxRuntimeShares,\n 'next/dynamic': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/head': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/link': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/router': {\n requiredVersion: false,\n singleton: true,\n import: undefined,\n },\n 'next/image': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/script': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n react: {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react/': {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react-dom/': {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react-dom': {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react/jsx-dev-runtime': {\n singleton: true,\n requiredVersion: false,\n },\n 'react/jsx-runtime': {\n singleton: true,\n requiredVersion: false,\n },\n 'styled-jsx': {\n singleton: true,\n import: undefined,\n version: require('styled-jsx/package.json').version,\n requiredVersion: '^' + require('styled-jsx/package.json').version,\n },\n 'styled-jsx/style': {\n singleton: true,\n import: false,\n version: require('styled-jsx/package.json').version,\n requiredVersion: '^' + require('styled-jsx/package.json').version,\n },\n 'styled-jsx/css': {\n singleton: true,\n import: undefined,\n version: require('styled-jsx/package.json').version,\n requiredVersion: '^' + require('styled-jsx/package.json').version,\n },\n};\n\n/**\n * Defines a default share scope for the browser environment.\n * This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.\n * For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.\n * The module hoisting system relocates these modules into the right runtime and out of the remote.\n *\n * @type {SharedObject}\n * @returns {SharedObject} - The modified share scope for the browser environment.\n */\n\nexport const DEFAULT_SHARE_SCOPE_BROWSER: moduleFederationPlugin.SharedObject =\n Object.entries(DEFAULT_SHARE_SCOPE).reduce((acc, item) => {\n const [key, value] = item as [string, moduleFederationPlugin.SharedConfig];\n\n // Set eager and import to undefined for all entries, except for the ones specified above\n acc[key] = { ...value, import: undefined };\n\n return acc;\n }, {} as moduleFederationPlugin.SharedObject);\n\n/**\n * Checks if the remote value is an internal or promise delegate module reference.\n *\n * @param {string} value - The remote value to check.\n * @returns {boolean} - True if the value is an internal or promise delegate module reference, false otherwise.\n */\nconst isInternalOrPromise = (value: string): boolean =>\n ['internal ', 'promise '].some((prefix) => value.startsWith(prefix));\n\n/**\n * Parses the remotes object and checks if they are using a custom promise template or not.\n * If it's a custom promise template, the remote syntax is parsed to get the module name and version number.\n * If the remote value is using the standard remote syntax, a delegated module is created.\n *\n * @param {Record<string, any>} remotes - The remotes object to be parsed.\n * @returns {Record<string, string>} - The parsed remotes object with either the original value,\n * the value for internal or promise delegate module reference, or the created delegated module.\n */\nexport const parseRemotes = (\n remotes: Record<string, any>,\n): Record<string, string> => {\n return Object.entries(remotes).reduce(\n (acc, [key, value]) => {\n if (isInternalOrPromise(value)) {\n // If the value is an internal or promise delegate module reference, keep the original value\n return { ...acc, [key]: value };\n }\n\n return { ...acc, [key]: value };\n },\n {} as Record<string, string>,\n );\n};\n/**\n * Checks if the remote value is an internal delegate module reference.\n * An internal delegate module reference starts with the string 'internal '.\n *\n * @param {string} value - The remote value to check.\n * @returns {boolean} - Returns true if the value is an internal delegate module reference, otherwise returns false.\n */\nconst isInternalDelegate = (value: string): boolean => {\n return value.startsWith('internal ');\n};\n/**\n * Extracts the delegate modules from the provided remotes object.\n * This function iterates over the remotes object and checks if each remote value is an internal delegate module reference.\n * If it is, the function adds it to the returned object.\n *\n * @param {Record<string, any>} remotes - The remotes object containing delegate module references.\n * @returns {Record<string, string>} - An object containing only the delegate modules from the remotes object.\n */\nexport const getDelegates = (\n remotes: Record<string, any>,\n): Record<string, string> =>\n Object.entries(remotes).reduce(\n (acc, [key, value]) =>\n isInternalDelegate(value) ? { ...acc, [key]: value } : acc,\n {},\n );\n\n/**\n * Takes an error object and formats it into a displayable string.\n * If the error object contains a stack trace, it is appended to the error message.\n *\n * @param {Error} error - The error object to be formatted.\n * @returns {string} - The formatted error message string. If a stack trace is present in the error object, it is appended to the error message.\n */\nconst formatError = (error: Error): string => {\n let { message } = error;\n if (error.stack) {\n message += `\\n${error.stack}`;\n }\n return message;\n};\n\n/**\n * Transforms an array of Error objects into a single string. Each error message is formatted using the 'formatError' function.\n * The resulting error messages are then joined together, separated by newline characters.\n *\n * @param {Error[]} err - An array of Error objects that need to be formatted and combined.\n * @returns {string} - A single string containing all the formatted error messages, separated by newline characters.\n */\nexport const toDisplayErrors = (err: Error[]): string => {\n return err.map(formatError).join('\\n');\n};\n"],"mappings":";;AAUA,MAAM,uBAAuB;CAI3B,QAAQ;CAKR,uBAAuB;CAIvB,qBAAqB;CAIrB,eAAe;CAIf,KAAK;CAIL,YAAY;CAIZ,YAAY;CAIZ,WAAW;CAIX,iBAAiB;CAClB;AAED,MAAM,sBACJ,MACA,QACA,UAA4D,EAAE,KAC3D;AACH,QAAO,OAAO,QACX,KAAK,UAAU;EACd,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,UAAU;AACzC,MAAI,OAAO;GACT,WAAW;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,CAAC;EAC3D;CACD,oBAAoB;EAClB,WAAW;EACX,QAAQ;EACR,SAAS,QAAQ,0BAA0B,CAAC;EAC5C,iBAAiB,MAAM,QAAQ,0BAA0B,CAAC;EAC3D;CACD,kBAAkB;EAChB,WAAW;EACX,QAAQ;EACR,SAAS,QAAQ,0BAA0B,CAAC;EAC5C,iBAAiB,MAAM,QAAQ,0BAA0B,CAAC;EAC3D;CACF;;;;;;;;;;AAYD,MAAa,8BACX,OAAO,QAAQ,oBAAoB,CAAC,QAAQ,KAAK,SAAS;CACxD,MAAM,CAAC,KAAK,SAAS;AAGrB,KAAI,OAAO;EAAE,GAAG;EAAO,QAAQ;EAAW;AAE1C,QAAO;GACN,EAAE,CAAwC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/internal.ts
|
|
4
|
+
const WEBPACK_LAYERS_NAMES = {
|
|
5
|
+
shared: "shared",
|
|
6
|
+
reactServerComponents: "rsc",
|
|
7
|
+
serverSideRendering: "ssr",
|
|
8
|
+
actionBrowser: "action-browser",
|
|
9
|
+
api: "api",
|
|
10
|
+
middleware: "middleware",
|
|
11
|
+
instrument: "instrument",
|
|
12
|
+
edgeAsset: "edge-asset",
|
|
13
|
+
appPagesBrowser: "app-pages-browser"
|
|
14
|
+
};
|
|
15
|
+
const createSharedConfig = (name, layers, options = {}) => {
|
|
16
|
+
return layers.reduce((acc, layer) => {
|
|
17
|
+
const key = layer ? `${name}-${layer}` : name;
|
|
18
|
+
acc[key] = {
|
|
19
|
+
singleton: true,
|
|
20
|
+
requiredVersion: false,
|
|
21
|
+
import: layer ? void 0 : options.import ?? false,
|
|
22
|
+
shareKey: options.request ?? name,
|
|
23
|
+
request: options.request ?? name,
|
|
24
|
+
layer,
|
|
25
|
+
issuerLayer: layer
|
|
26
|
+
};
|
|
27
|
+
return acc;
|
|
28
|
+
}, {});
|
|
29
|
+
};
|
|
30
|
+
const defaultLayers = [
|
|
31
|
+
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
32
|
+
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
33
|
+
void 0
|
|
34
|
+
];
|
|
35
|
+
const navigationLayers = [WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.serverSideRendering];
|
|
36
|
+
createSharedConfig("react", defaultLayers);
|
|
37
|
+
createSharedConfig("react", defaultLayers, { request: "react-dom" });
|
|
38
|
+
createSharedConfig("react/", navigationLayers, {
|
|
39
|
+
request: "react/",
|
|
40
|
+
import: void 0
|
|
41
|
+
});
|
|
42
|
+
createSharedConfig("next-navigation", navigationLayers, { request: "next/navigation" });
|
|
43
|
+
/**
|
|
44
|
+
* @typedef SharedObject
|
|
45
|
+
* @type {object}
|
|
46
|
+
* @property {object} [key] - The key representing the shared object's package name.
|
|
47
|
+
* @property {boolean} key.singleton - Whether the shared object should be a singleton.
|
|
48
|
+
* @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required.
|
|
49
|
+
* @property {boolean} key.eager - Whether the shared object should be eagerly loaded.
|
|
50
|
+
* @property {boolean} key.import - Whether the shared object should be imported or not.
|
|
51
|
+
* @property {string} key.layer - The webpack layer this shared module belongs to.
|
|
52
|
+
* @property {string|string[]} key.issuerLayer - The webpack layer that can import this shared module.
|
|
53
|
+
*/
|
|
54
|
+
const DEFAULT_SHARE_SCOPE = {
|
|
55
|
+
"next/dynamic": {
|
|
56
|
+
requiredVersion: void 0,
|
|
57
|
+
singleton: true,
|
|
58
|
+
import: void 0
|
|
59
|
+
},
|
|
60
|
+
"next/head": {
|
|
61
|
+
requiredVersion: void 0,
|
|
62
|
+
singleton: true,
|
|
63
|
+
import: void 0
|
|
64
|
+
},
|
|
65
|
+
"next/link": {
|
|
66
|
+
requiredVersion: void 0,
|
|
67
|
+
singleton: true,
|
|
68
|
+
import: void 0
|
|
69
|
+
},
|
|
70
|
+
"next/router": {
|
|
71
|
+
requiredVersion: false,
|
|
72
|
+
singleton: true,
|
|
73
|
+
import: void 0
|
|
74
|
+
},
|
|
75
|
+
"next/image": {
|
|
76
|
+
requiredVersion: void 0,
|
|
77
|
+
singleton: true,
|
|
78
|
+
import: void 0
|
|
79
|
+
},
|
|
80
|
+
"next/script": {
|
|
81
|
+
requiredVersion: void 0,
|
|
82
|
+
singleton: true,
|
|
83
|
+
import: void 0
|
|
84
|
+
},
|
|
85
|
+
react: {
|
|
86
|
+
singleton: true,
|
|
87
|
+
requiredVersion: false,
|
|
88
|
+
import: false
|
|
89
|
+
},
|
|
90
|
+
"react/": {
|
|
91
|
+
singleton: true,
|
|
92
|
+
requiredVersion: false,
|
|
93
|
+
import: false
|
|
94
|
+
},
|
|
95
|
+
"react-dom/": {
|
|
96
|
+
singleton: true,
|
|
97
|
+
requiredVersion: false,
|
|
98
|
+
import: false
|
|
99
|
+
},
|
|
100
|
+
"react-dom": {
|
|
101
|
+
singleton: true,
|
|
102
|
+
requiredVersion: false,
|
|
103
|
+
import: false
|
|
104
|
+
},
|
|
105
|
+
"react/jsx-dev-runtime": {
|
|
106
|
+
singleton: true,
|
|
107
|
+
requiredVersion: false
|
|
108
|
+
},
|
|
109
|
+
"react/jsx-runtime": {
|
|
110
|
+
singleton: true,
|
|
111
|
+
requiredVersion: false
|
|
112
|
+
},
|
|
113
|
+
"styled-jsx": {
|
|
114
|
+
singleton: true,
|
|
115
|
+
import: void 0,
|
|
116
|
+
version: __require("styled-jsx/package.json").version,
|
|
117
|
+
requiredVersion: "^" + __require("styled-jsx/package.json").version
|
|
118
|
+
},
|
|
119
|
+
"styled-jsx/style": {
|
|
120
|
+
singleton: true,
|
|
121
|
+
import: false,
|
|
122
|
+
version: __require("styled-jsx/package.json").version,
|
|
123
|
+
requiredVersion: "^" + __require("styled-jsx/package.json").version
|
|
124
|
+
},
|
|
125
|
+
"styled-jsx/css": {
|
|
126
|
+
singleton: true,
|
|
127
|
+
import: void 0,
|
|
128
|
+
version: __require("styled-jsx/package.json").version,
|
|
129
|
+
requiredVersion: "^" + __require("styled-jsx/package.json").version
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Defines a default share scope for the browser environment.
|
|
134
|
+
* This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.
|
|
135
|
+
* For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.
|
|
136
|
+
* The module hoisting system relocates these modules into the right runtime and out of the remote.
|
|
137
|
+
*
|
|
138
|
+
* @type {SharedObject}
|
|
139
|
+
* @returns {SharedObject} - The modified share scope for the browser environment.
|
|
140
|
+
*/
|
|
141
|
+
const DEFAULT_SHARE_SCOPE_BROWSER = Object.entries(DEFAULT_SHARE_SCOPE).reduce((acc, item) => {
|
|
142
|
+
const [key, value] = item;
|
|
143
|
+
acc[key] = {
|
|
144
|
+
...value,
|
|
145
|
+
import: void 0
|
|
146
|
+
};
|
|
147
|
+
return acc;
|
|
148
|
+
}, {});
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
export { DEFAULT_SHARE_SCOPE, DEFAULT_SHARE_SCOPE_BROWSER };
|
|
152
|
+
//# sourceMappingURL=internal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.mjs","names":[],"sources":["../../src/internal.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\n\n// Extend the SharedConfig type to include layer properties\ntype ExtendedSharedConfig = moduleFederationPlugin.SharedConfig & {\n layer?: string;\n issuerLayer?: string | string[];\n request?: string;\n shareKey?: string;\n};\n\nconst WEBPACK_LAYERS_NAMES = {\n /**\n * The layer for the shared code between the client and server bundles.\n */\n shared: 'shared',\n /**\n * The layer for server-only runtime and picking up `react-server` export conditions.\n * Including app router RSC pages and app router custom routes and metadata routes.\n */\n reactServerComponents: 'rsc',\n /**\n * Server Side Rendering layer for app (ssr).\n */\n serverSideRendering: 'ssr',\n /**\n * The browser client bundle layer for actions.\n */\n actionBrowser: 'action-browser',\n /**\n * The layer for the API routes.\n */\n api: 'api',\n /**\n * The layer for the middleware code.\n */\n middleware: 'middleware',\n /**\n * The layer for the instrumentation hooks.\n */\n instrument: 'instrument',\n /**\n * The layer for assets on the edge.\n */\n edgeAsset: 'edge-asset',\n /**\n * The browser client bundle layer for App directory.\n */\n appPagesBrowser: 'app-pages-browser',\n} as const;\n\nconst createSharedConfig = (\n name: string,\n layers: (string | undefined)[],\n options: { request?: string; import?: false | undefined } = {},\n) => {\n return layers.reduce(\n (acc, layer) => {\n const key = layer ? `${name}-${layer}` : name;\n acc[key] = {\n singleton: true,\n requiredVersion: false,\n import: layer ? undefined : (options.import ?? false),\n shareKey: options.request ?? name,\n request: options.request ?? name,\n layer,\n issuerLayer: layer,\n };\n return acc;\n },\n {} as Record<string, ExtendedSharedConfig>,\n );\n};\n\nconst defaultLayers = [\n WEBPACK_LAYERS_NAMES.reactServerComponents,\n WEBPACK_LAYERS_NAMES.serverSideRendering,\n undefined,\n];\n\nconst navigationLayers = [\n WEBPACK_LAYERS_NAMES.reactServerComponents,\n WEBPACK_LAYERS_NAMES.serverSideRendering,\n];\n\nconst reactShares = createSharedConfig('react', defaultLayers);\nconst reactDomShares = createSharedConfig('react', defaultLayers, {\n request: 'react-dom',\n});\nconst jsxRuntimeShares = createSharedConfig('react/', navigationLayers, {\n request: 'react/',\n import: undefined,\n});\nconst nextNavigationShares = createSharedConfig(\n 'next-navigation',\n navigationLayers,\n { request: 'next/navigation' },\n);\n\n/**\n * @typedef SharedObject\n * @type {object}\n * @property {object} [key] - The key representing the shared object's package name.\n * @property {boolean} key.singleton - Whether the shared object should be a singleton.\n * @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required.\n * @property {boolean} key.eager - Whether the shared object should be eagerly loaded.\n * @property {boolean} key.import - Whether the shared object should be imported or not.\n * @property {string} key.layer - The webpack layer this shared module belongs to.\n * @property {string|string[]} key.issuerLayer - The webpack layer that can import this shared module.\n */\nexport const DEFAULT_SHARE_SCOPE: moduleFederationPlugin.SharedObject = {\n // ...reactShares,\n // ...reactDomShares,\n // ...nextNavigationShares,\n // ...jsxRuntimeShares,\n 'next/dynamic': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/head': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/link': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/router': {\n requiredVersion: false,\n singleton: true,\n import: undefined,\n },\n 'next/image': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n 'next/script': {\n requiredVersion: undefined,\n singleton: true,\n import: undefined,\n },\n react: {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react/': {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react-dom/': {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react-dom': {\n singleton: true,\n requiredVersion: false,\n import: false,\n },\n 'react/jsx-dev-runtime': {\n singleton: true,\n requiredVersion: false,\n },\n 'react/jsx-runtime': {\n singleton: true,\n requiredVersion: false,\n },\n 'styled-jsx': {\n singleton: true,\n import: undefined,\n version: require('styled-jsx/package.json').version,\n requiredVersion: '^' + require('styled-jsx/package.json').version,\n },\n 'styled-jsx/style': {\n singleton: true,\n import: false,\n version: require('styled-jsx/package.json').version,\n requiredVersion: '^' + require('styled-jsx/package.json').version,\n },\n 'styled-jsx/css': {\n singleton: true,\n import: undefined,\n version: require('styled-jsx/package.json').version,\n requiredVersion: '^' + require('styled-jsx/package.json').version,\n },\n};\n\n/**\n * Defines a default share scope for the browser environment.\n * This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.\n * For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.\n * The module hoisting system relocates these modules into the right runtime and out of the remote.\n *\n * @type {SharedObject}\n * @returns {SharedObject} - The modified share scope for the browser environment.\n */\n\nexport const DEFAULT_SHARE_SCOPE_BROWSER: moduleFederationPlugin.SharedObject =\n Object.entries(DEFAULT_SHARE_SCOPE).reduce((acc, item) => {\n const [key, value] = item as [string, moduleFederationPlugin.SharedConfig];\n\n // Set eager and import to undefined for all entries, except for the ones specified above\n acc[key] = { ...value, import: undefined };\n\n return acc;\n }, {} as moduleFederationPlugin.SharedObject);\n\n/**\n * Checks if the remote value is an internal or promise delegate module reference.\n *\n * @param {string} value - The remote value to check.\n * @returns {boolean} - True if the value is an internal or promise delegate module reference, false otherwise.\n */\nconst isInternalOrPromise = (value: string): boolean =>\n ['internal ', 'promise '].some((prefix) => value.startsWith(prefix));\n\n/**\n * Parses the remotes object and checks if they are using a custom promise template or not.\n * If it's a custom promise template, the remote syntax is parsed to get the module name and version number.\n * If the remote value is using the standard remote syntax, a delegated module is created.\n *\n * @param {Record<string, any>} remotes - The remotes object to be parsed.\n * @returns {Record<string, string>} - The parsed remotes object with either the original value,\n * the value for internal or promise delegate module reference, or the created delegated module.\n */\nexport const parseRemotes = (\n remotes: Record<string, any>,\n): Record<string, string> => {\n return Object.entries(remotes).reduce(\n (acc, [key, value]) => {\n if (isInternalOrPromise(value)) {\n // If the value is an internal or promise delegate module reference, keep the original value\n return { ...acc, [key]: value };\n }\n\n return { ...acc, [key]: value };\n },\n {} as Record<string, string>,\n );\n};\n/**\n * Checks if the remote value is an internal delegate module reference.\n * An internal delegate module reference starts with the string 'internal '.\n *\n * @param {string} value - The remote value to check.\n * @returns {boolean} - Returns true if the value is an internal delegate module reference, otherwise returns false.\n */\nconst isInternalDelegate = (value: string): boolean => {\n return value.startsWith('internal ');\n};\n/**\n * Extracts the delegate modules from the provided remotes object.\n * This function iterates over the remotes object and checks if each remote value is an internal delegate module reference.\n * If it is, the function adds it to the returned object.\n *\n * @param {Record<string, any>} remotes - The remotes object containing delegate module references.\n * @returns {Record<string, string>} - An object containing only the delegate modules from the remotes object.\n */\nexport const getDelegates = (\n remotes: Record<string, any>,\n): Record<string, string> =>\n Object.entries(remotes).reduce(\n (acc, [key, value]) =>\n isInternalDelegate(value) ? { ...acc, [key]: value } : acc,\n {},\n );\n\n/**\n * Takes an error object and formats it into a displayable string.\n * If the error object contains a stack trace, it is appended to the error message.\n *\n * @param {Error} error - The error object to be formatted.\n * @returns {string} - The formatted error message string. If a stack trace is present in the error object, it is appended to the error message.\n */\nconst formatError = (error: Error): string => {\n let { message } = error;\n if (error.stack) {\n message += `\\n${error.stack}`;\n }\n return message;\n};\n\n/**\n * Transforms an array of Error objects into a single string. Each error message is formatted using the 'formatError' function.\n * The resulting error messages are then joined together, separated by newline characters.\n *\n * @param {Error[]} err - An array of Error objects that need to be formatted and combined.\n * @returns {string} - A single string containing all the formatted error messages, separated by newline characters.\n */\nexport const toDisplayErrors = (err: Error[]): string => {\n return err.map(formatError).join('\\n');\n};\n"],"mappings":";;;AAUA,MAAM,uBAAuB;CAI3B,QAAQ;CAKR,uBAAuB;CAIvB,qBAAqB;CAIrB,eAAe;CAIf,KAAK;CAIL,YAAY;CAIZ,YAAY;CAIZ,WAAW;CAIX,iBAAiB;CAClB;AAED,MAAM,sBACJ,MACA,QACA,UAA4D,EAAE,KAC3D;AACH,QAAO,OAAO,QACX,KAAK,UAAU;EACd,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,UAAU;AACzC,MAAI,OAAO;GACT,WAAW;GACX,iBAAiB;GACjB,QAAQ,QAAQ,SAAa,QAAQ,UAAU;GAC/C,UAAU,QAAQ,WAAW;GAC7B,SAAS,QAAQ,WAAW;GAC5B;GACA,aAAa;GACd;AACD,SAAO;IAET,EAAE,CACH;;AAGH,MAAM,gBAAgB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB;CACD;AAED,MAAM,mBAAmB,CACvB,qBAAqB,uBACrB,qBAAqB,oBACtB;AAEmB,mBAAmB,SAAS,cAAc;AACvC,mBAAmB,SAAS,eAAe,EAChE,SAAS,aACV,CAAC;AACuB,mBAAmB,UAAU,kBAAkB;CACtE,SAAS;CACT,QAAQ;CACT,CAAC;AAC2B,mBAC3B,mBACA,kBACA,EAAE,S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1
|
+
import { LoaderContext } from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/loaders/fixImageLoader.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* This loader is specifically created for tuning the next-image-loader result.
|
|
6
|
+
* It modifies the regular string output of the next-image-loader.
|
|
7
|
+
* For server-side rendering (SSR), it injects the remote scope of a specific remote URL.
|
|
8
|
+
* For client-side rendering (CSR), it injects the document.currentScript.src.
|
|
9
|
+
* After these injections, it selects the full URI before _next.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* http://localhost:1234/test/test2/_next/static/media/ssl.e3019f0e.svg
|
|
13
|
+
* will become
|
|
14
|
+
* http://localhost:1234/test/test2
|
|
15
|
+
*
|
|
16
|
+
* @param {LoaderContext<Record<string, unknown>>} this - The loader context.
|
|
17
|
+
* @param {string} remaining - The remaining part of the resource path.
|
|
18
|
+
* @returns {string} The modified source code with the injected code.
|
|
19
|
+
*/
|
|
20
|
+
declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* The pitch function of the loader, which is the same as the fixImageLoader function.
|
|
23
|
+
*/
|
|
24
|
+
declare const pitch: typeof fixImageLoader;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { fixImageLoader, pitch };
|
|
27
|
+
//# sourceMappingURL=fixImageLoader.d.mts.map
|