@module-federation/nextjs-mf 8.1.0-canary.7 → 8.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/LICENSE +21 -0
- package/README.md +469 -0
- package/dist/client/UrlNode.js.map +1 -0
- package/dist/node.js.map +1 -0
- package/dist/package.json +71 -0
- package/dist/src/default-delegate.js.map +1 -0
- package/dist/src/federation-noop.js.map +1 -0
- package/dist/src/index.js.map +1 -0
- package/{src → dist/src}/internal.js +24 -16
- package/dist/src/internal.js.map +1 -0
- package/dist/src/loaders/delegateLoader.js.map +1 -0
- package/{src → dist/src}/loaders/fixImageLoader.js +16 -15
- package/dist/src/loaders/fixImageLoader.js.map +1 -0
- package/dist/src/loaders/fixUrlLoader.js.map +1 -0
- package/{src → dist/src}/loaders/helpers.js +5 -0
- package/dist/src/loaders/helpers.js.map +1 -0
- package/{src → dist/src}/loaders/nextPageMapLoader.js +5 -5
- package/dist/src/loaders/nextPageMapLoader.js.map +1 -0
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
- package/{src → dist/src}/plugins/CopyFederationPlugin.d.ts +2 -2
- package/dist/src/plugins/CopyFederationPlugin.js.map +1 -0
- package/{src → dist/src}/plugins/NextFederationPlugin/apply-client-plugins.d.ts +1 -1
- package/{src → dist/src}/plugins/NextFederationPlugin/apply-client-plugins.js +2 -16
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -0
- package/{src → dist/src}/plugins/NextFederationPlugin/apply-server-plugins.d.ts +1 -1
- package/{src → dist/src}/plugins/NextFederationPlugin/apply-server-plugins.js +5 -5
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -0
- package/{src → dist/src}/plugins/NextFederationPlugin/index.d.ts +1 -1
- package/{src → dist/src}/plugins/NextFederationPlugin/index.js +6 -2
- package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -0
- package/{src → dist/src}/plugins/NextFederationPlugin/next-fragments.d.ts +1 -2
- package/{src → dist/src}/plugins/NextFederationPlugin/next-fragments.js +33 -2
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -0
- package/{src → dist/src}/plugins/NextFederationPlugin/regex-equal.d.ts +1 -1
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -0
- package/{src → dist/src}/plugins/NextFederationPlugin/validate-options.d.ts +1 -1
- package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -0
- package/{src → dist/src}/plugins/container/EmbeddedContainerPlugin.d.ts +1 -1
- package/{src → dist/src}/plugins/container/EmbeddedContainerPlugin.js +2 -2
- package/dist/src/plugins/container/EmbeddedContainerPlugin.js.map +1 -0
- package/{src → dist/src}/plugins/container/HoistPseudoEagerModules.d.ts +1 -1
- package/dist/src/plugins/container/HoistPseudoEagerModules.js.map +1 -0
- package/{src → dist/src}/plugins/container/InvertedContainerPlugin.d.ts +1 -1
- package/{src → dist/src}/plugins/container/InvertedContainerPlugin.js +1 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -0
- package/{src → dist/src}/plugins/container/InvertedContainerRuntimeModule.d.ts +1 -1
- package/{src → dist/src}/plugins/container/InvertedContainerRuntimeModule.js +9 -11
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -0
- package/dist/src/plugins/container/ModuleFederationPlugin.d.ts +14 -0
- package/{src → dist/src}/plugins/container/ModuleFederationPlugin.js +13 -14
- package/dist/src/plugins/container/ModuleFederationPlugin.js.map +1 -0
- package/{src → dist/src}/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +1 -1
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -0
- package/dist/src/plugins/container/types.js.map +1 -0
- package/dist/src/types.js.map +1 -0
- package/dist/utilities.js.map +1 -0
- package/dist/utils/build-utils.js.map +1 -0
- package/dist/utils/flushedChunks.js.map +1 -0
- package/{utils → dist/utils}/index.d.ts +3 -3
- package/{utils → dist/utils}/index.js +4 -4
- package/dist/utils/index.js.map +1 -0
- package/package.json +35 -13
- package/client/UrlNode.js.map +0 -1
- package/client/helpers.d.ts +0 -16
- package/client/helpers.js +0 -94
- package/client/helpers.js.map +0 -1
- package/node.js.map +0 -1
- package/src/default-delegate.js.map +0 -1
- package/src/federation-noop.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/internal.js.map +0 -1
- package/src/loaders/delegateLoader.js.map +0 -1
- package/src/loaders/fixImageLoader.js.map +0 -1
- package/src/loaders/fixUrlLoader.js.map +0 -1
- package/src/loaders/helpers.js.map +0 -1
- package/src/loaders/nextPageMapLoader.js.map +0 -1
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +0 -5
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
- package/src/plugins/CopyFederationPlugin.js.map +0 -1
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +0 -1
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +0 -1
- package/src/plugins/NextFederationPlugin/index.js.map +0 -1
- package/src/plugins/NextFederationPlugin/next-fragments.js.map +0 -1
- package/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
- package/src/plugins/NextFederationPlugin/set-options.js.map +0 -1
- package/src/plugins/NextFederationPlugin/validate-options.js.map +0 -1
- package/src/plugins/container/EmbeddedContainerPlugin.js.map +0 -1
- package/src/plugins/container/HoistPseudoEagerModules.js.map +0 -1
- package/src/plugins/container/InvertedContainerPlugin.js.map +0 -1
- package/src/plugins/container/InvertedContainerRuntimeModule.js.map +0 -1
- package/src/plugins/container/ModuleFederationPlugin.d.ts +0 -17
- package/src/plugins/container/ModuleFederationPlugin.js.map +0 -1
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
- package/src/plugins/container/types.js.map +0 -1
- package/src/types.js.map +0 -1
- package/utilities.js.map +0 -1
- package/utils/Template.d.ts +0 -148
- package/utils/Template.js +0 -389
- package/utils/Template.js.map +0 -1
- package/utils/build-utils.js.map +0 -1
- package/utils/flushedChunks.js.map +0 -1
- package/utils/index.js.map +0 -1
- /package/{client → dist/client}/UrlNode.d.ts +0 -0
- /package/{client → dist/client}/UrlNode.js +0 -0
- /package/{node.d.ts → dist/node.d.ts} +0 -0
- /package/{node.js → dist/node.js} +0 -0
- /package/{src → dist/src}/default-delegate.d.ts +0 -0
- /package/{src → dist/src}/default-delegate.js +0 -0
- /package/{src → dist/src}/federation-noop.d.ts +0 -0
- /package/{src → dist/src}/federation-noop.js +0 -0
- /package/{src → dist/src}/index.d.ts +0 -0
- /package/{src → dist/src}/index.js +0 -0
- /package/{src → dist/src}/internal.d.ts +0 -0
- /package/{src → dist/src}/loaders/delegateLoader.d.ts +0 -0
- /package/{src → dist/src}/loaders/delegateLoader.js +0 -0
- /package/{src → dist/src}/loaders/fixImageLoader.d.ts +0 -0
- /package/{src → dist/src}/loaders/fixUrlLoader.d.ts +0 -0
- /package/{src → dist/src}/loaders/fixUrlLoader.js +0 -0
- /package/{src → dist/src}/loaders/helpers.d.ts +0 -0
- /package/{src → dist/src}/loaders/nextPageMapLoader.d.ts +0 -0
- /package/{src → dist/src}/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -0
- /package/{src → dist/src}/plugins/CopyFederationPlugin.js +0 -0
- /package/{src → dist/src}/plugins/NextFederationPlugin/regex-equal.js +0 -0
- /package/{src → dist/src}/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +0 -0
- /package/{src → dist/src}/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -0
- /package/{src → dist/src}/plugins/NextFederationPlugin/set-options.d.ts +0 -0
- /package/{src → dist/src}/plugins/NextFederationPlugin/set-options.js +0 -0
- /package/{src → dist/src}/plugins/NextFederationPlugin/validate-options.js +0 -0
- /package/{src → dist/src}/plugins/container/HoistPseudoEagerModules.js +0 -0
- /package/{src → dist/src}/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -0
- /package/{src → dist/src}/plugins/container/types.d.ts +0 -0
- /package/{src → dist/src}/plugins/container/types.js +0 -0
- /package/{src → dist/src}/types.d.ts +0 -0
- /package/{src → dist/src}/types.js +0 -0
- /package/{utilities.d.ts → dist/utilities.d.ts} +0 -0
- /package/{utilities.js → dist/utilities.js} +0 -0
- /package/{utils → dist/utils}/build-utils.d.ts +0 -0
- /package/{utils → dist/utils}/build-utils.js +0 -0
- /package/{utils → dist/utils}/flushedChunks.d.ts +0 -0
- /package/{utils → dist/utils}/flushedChunks.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present zhanghang(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<!-- for version -->
|
|
3
|
+
<img src="https://img.shields.io/npm/v/@module-federation/nextjs-mf" alt="version" >
|
|
4
|
+
<img src="https://img.shields.io/npm/l/@module-federation/nextjs-mf.svg?" alt="license" >
|
|
5
|
+
<!-- for downloads -->
|
|
6
|
+
<img src="https://img.shields.io/npm/dt/@module-federation/nextjs-mf" alt="downloads">
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
# Module Federation For Next.js
|
|
10
|
+
|
|
11
|
+
This plugin enables Module Federation on Next.js
|
|
12
|
+
|
|
13
|
+
## Supports
|
|
14
|
+
|
|
15
|
+
- next ^13 || ^12(?)
|
|
16
|
+
- SSR included!
|
|
17
|
+
|
|
18
|
+
I highly recommend referencing this application which takes advantage of the best capabilities:
|
|
19
|
+
https://github.com/module-federation/module-federation-examples
|
|
20
|
+
|
|
21
|
+
## This project supports federated SSR
|
|
22
|
+
|
|
23
|
+
# We are building a micro-frontend ecosystem!
|
|
24
|
+
|
|
25
|
+
While NextFederationPlugin "works", Next.js is staunchly opposed to the technology and Next is very difficult to support.
|
|
26
|
+
|
|
27
|
+
This plugin attempts to make the experience as seamless as possible, but it is not perfect.
|
|
28
|
+
|
|
29
|
+
We are building a micro-frontend ecosystem that is much more powerful than Next.js, built to support micro-frontends from the ground up.
|
|
30
|
+
|
|
31
|
+
**If Federation is a big enabler for your teams and projects, please consider using our ecosystem thats designed for it**
|
|
32
|
+
|
|
33
|
+
| [Rspack](https://github.com/web-infra-dev/rspack) | <a href="https://github.com/web-infra-dev/rspack" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/Rspack-1850.png" width="400" /></a> |
|
|
34
|
+
| :-----------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
35
|
+
| [Modern.js](https://github.com/web-infra-dev/modern.js) | <a href="https://github.com/web-infra-dev/modern.js" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/Modern-0550.png" width="400" /></a> |
|
|
36
|
+
| [Garfish](https://github.com/web-infra-dev/garfish) | <a href="https://github.com/web-infra-dev/garfish" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/Garfish-1630.png" width="400" /></a> |
|
|
37
|
+
| [Oxc](https://github.com/web-infra-dev/oxc) | <a href="https://github.com/web-infra-dev/oxc" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/Oxc-0724.png" width="400" /></a> |
|
|
38
|
+
|
|
39
|
+
## Whats shared by default?
|
|
40
|
+
|
|
41
|
+
Under the hood we share some next internals automatically
|
|
42
|
+
You do not need to share these packages, sharing next internals yourself will cause errors.
|
|
43
|
+
|
|
44
|
+
<details>
|
|
45
|
+
<summary> See DEFAULT_SHARE_SCOPE:</summary>
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
export const DEFAULT_SHARE_SCOPE: SharedObject = {
|
|
49
|
+
'next/dynamic': {
|
|
50
|
+
eager: false,
|
|
51
|
+
requiredVersion: false,
|
|
52
|
+
singleton: true,
|
|
53
|
+
import: undefined,
|
|
54
|
+
},
|
|
55
|
+
'next/head': {
|
|
56
|
+
eager: false,
|
|
57
|
+
requiredVersion: false,
|
|
58
|
+
singleton: true,
|
|
59
|
+
import: undefined,
|
|
60
|
+
},
|
|
61
|
+
'next/link': {
|
|
62
|
+
eager: true,
|
|
63
|
+
requiredVersion: false,
|
|
64
|
+
singleton: true,
|
|
65
|
+
import: undefined,
|
|
66
|
+
},
|
|
67
|
+
'next/router': {
|
|
68
|
+
requiredVersion: false,
|
|
69
|
+
singleton: true,
|
|
70
|
+
import: false,
|
|
71
|
+
eager: false,
|
|
72
|
+
},
|
|
73
|
+
'next/script': {
|
|
74
|
+
requiredVersion: false,
|
|
75
|
+
singleton: true,
|
|
76
|
+
import: undefined,
|
|
77
|
+
eager: false,
|
|
78
|
+
},
|
|
79
|
+
react: {
|
|
80
|
+
singleton: true,
|
|
81
|
+
requiredVersion: false,
|
|
82
|
+
eager: false,
|
|
83
|
+
import: false,
|
|
84
|
+
},
|
|
85
|
+
'react-dom': {
|
|
86
|
+
singleton: true,
|
|
87
|
+
requiredVersion: false,
|
|
88
|
+
eager: false,
|
|
89
|
+
import: false,
|
|
90
|
+
},
|
|
91
|
+
'react/jsx-dev-runtime': {
|
|
92
|
+
singleton: true,
|
|
93
|
+
requiredVersion: false,
|
|
94
|
+
import: undefined,
|
|
95
|
+
eager: false,
|
|
96
|
+
},
|
|
97
|
+
'react/jsx-runtime': {
|
|
98
|
+
singleton: true,
|
|
99
|
+
requiredVersion: false,
|
|
100
|
+
eager: false,
|
|
101
|
+
import: false,
|
|
102
|
+
},
|
|
103
|
+
'styled-jsx': {
|
|
104
|
+
requiredVersion: false,
|
|
105
|
+
singleton: true,
|
|
106
|
+
import: undefined,
|
|
107
|
+
eager: false,
|
|
108
|
+
},
|
|
109
|
+
'styled-jsx/style': {
|
|
110
|
+
requiredVersion: false,
|
|
111
|
+
singleton: true,
|
|
112
|
+
import: undefined,
|
|
113
|
+
eager: false,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
## Requirement
|
|
121
|
+
|
|
122
|
+
I set `process.env.NEXT_PRIVATE_LOCAL_WEBPACK = 'true'` inside this plugin, but its best if its set in env or command line export.
|
|
123
|
+
|
|
124
|
+
"Local Webpack" means you must have webpack installed as a dependency, and next will not use its bundled copy of webpack which cannot be used as i need access to all of webpack internals
|
|
125
|
+
|
|
126
|
+
- `NEXT_PRIVATE_LOCAL_WEBPACK=true next dev` or `next build`
|
|
127
|
+
- `npm install webpack`
|
|
128
|
+
|
|
129
|
+
## Usage
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
import React, { lazy } from 'react';
|
|
133
|
+
const SampleComponent = lazy(() => import('next2/sampleComponent'));
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
To avoid hydration errors, use `React.lazy` instead of `next/dynamic` for lazy loading federated components.
|
|
137
|
+
|
|
138
|
+
#### See the implementation here: https://github.com/module-federation/module-federation-examples/tree/master/nextjs-v13/home/pages
|
|
139
|
+
|
|
140
|
+
With async boundary installed at the page level. You can then do the following
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
const SomeHook = require('next2/someHook');
|
|
144
|
+
import SomeComponent from 'next2/someComponent';
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Demo
|
|
148
|
+
|
|
149
|
+
You can see it in action here: https://github.com/module-federation/module-federation-examples/tree/master/nextjs-ssr
|
|
150
|
+
|
|
151
|
+
## Options
|
|
152
|
+
|
|
153
|
+
This plugin works exactly like ModuleFederationPlugin, use it as you'd normally.
|
|
154
|
+
Note that we already share react and next stuff for you automatically.
|
|
155
|
+
|
|
156
|
+
Also NextFederationPlugin has own optional argument `extraOptions` where you can unlock additional features of this plugin:
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
new NextFederationPlugin({
|
|
160
|
+
name: '',
|
|
161
|
+
filename: '',
|
|
162
|
+
remotes: {},
|
|
163
|
+
exposes: {},
|
|
164
|
+
shared: {},
|
|
165
|
+
extraOptions: {
|
|
166
|
+
debug: boolean, // `false` by default
|
|
167
|
+
exposePages: boolean, // `false` by default
|
|
168
|
+
enableImageLoaderFix: boolean, // `false` by default
|
|
169
|
+
enableUrlLoaderFix: boolean, // `false` by default
|
|
170
|
+
skipSharingNextInternals: boolean, // `false` by default
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- `debug` – enables debug mode. It will print additional information about what is going on under the hood.
|
|
176
|
+
- `exposePages` – exposes automatically all nextjs pages for you and theirs `./pages-map`.
|
|
177
|
+
- `enableImageLoaderFix` – adds public hostname to all assets bundled by `nextjs-image-loader`. So if you serve remoteEntry from `http://example.com` then all bundled assets will get this hostname in runtime. It's something like Base URL in HTML but for federated modules.
|
|
178
|
+
- `enableUrlLoaderFix` – adds public hostname to all assets bundled by `url-loader`.
|
|
179
|
+
- `skipSharingNextInternals` – disables sharing of next internals. You can use it if you want to share next internals yourself or want to use this plugin on non next applications
|
|
180
|
+
|
|
181
|
+
## Demo
|
|
182
|
+
|
|
183
|
+
You can see it in action here: https://github.com/module-federation/module-federation-examples/pull/2147
|
|
184
|
+
|
|
185
|
+
## Implementing the Plugin
|
|
186
|
+
|
|
187
|
+
1. Use `NextFederationPlugin` in your `next.config.js` of the app that you wish to expose modules from. We'll call this "next2".
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
// next.config.js
|
|
191
|
+
// either from default
|
|
192
|
+
const NextFederationPlugin = require('@module-federation/nextjs-mf');
|
|
193
|
+
|
|
194
|
+
module.exports = {
|
|
195
|
+
webpack(config, options) {
|
|
196
|
+
const { isServer } = options;
|
|
197
|
+
config.plugins.push(
|
|
198
|
+
new NextFederationPlugin({
|
|
199
|
+
name: 'next2',
|
|
200
|
+
remotes: {
|
|
201
|
+
next1: `next1@http://localhost:3001/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
202
|
+
},
|
|
203
|
+
filename: 'static/chunks/remoteEntry.js',
|
|
204
|
+
exposes: {
|
|
205
|
+
'./title': './components/exposedTitle.js',
|
|
206
|
+
'./checkout': './pages/checkout',
|
|
207
|
+
},
|
|
208
|
+
shared: {
|
|
209
|
+
// whatever else
|
|
210
|
+
},
|
|
211
|
+
}),
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
return config;
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
```js
|
|
220
|
+
// next.config.js
|
|
221
|
+
|
|
222
|
+
const NextFederationPlugin = require('@module-federation/nextjs-mf');
|
|
223
|
+
|
|
224
|
+
module.exports = {
|
|
225
|
+
webpack(config, options) {
|
|
226
|
+
const { isServer } = options;
|
|
227
|
+
config.plugins.push(
|
|
228
|
+
new NextFederationPlugin({
|
|
229
|
+
name: 'next1',
|
|
230
|
+
remotes: {
|
|
231
|
+
next2: `next2@http://localhost:3000/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
return config;
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
4. Use react.lazy, low level api, or require/import from to import remotes.
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import React, { lazy } from 'react';
|
|
245
|
+
|
|
246
|
+
const SampleComponent = lazy(() =>
|
|
247
|
+
window.next2.get('./sampleComponent').then((factory) => {
|
|
248
|
+
return { default: factory() };
|
|
249
|
+
}),
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
// or
|
|
253
|
+
|
|
254
|
+
const SampleComponent = lazy(() => import('next2/sampleComponent'));
|
|
255
|
+
|
|
256
|
+
//or
|
|
257
|
+
|
|
258
|
+
import Sample from 'next2/sampleComponent';
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Delegate modules
|
|
262
|
+
|
|
263
|
+
Delegated modules are now a standard feature in module federation, giving you the ability to manage the loading procedure of remote modules via an internally bundled file by webpack. This is facilitated by exporting a promise in the delegate file that resolves to a remote/container interface.
|
|
264
|
+
|
|
265
|
+
A container interface represents the fundamental `{get, init}` API that remote entries present to a consuming app. Within the browser, a remote container could be `window.app1`, and in Node, it could be `globalThis.__remote_scope__.app1`.
|
|
266
|
+
|
|
267
|
+
Implementing a method for script loading in the delegate file is necessary for the utilization of delegated modules. Although the built-in `__webpack_require__.l` method of webpack is a prevalent method, any method is suitable. This method is made available to the runtime and is identical to the method webpack employs internally to load remotes.
|
|
268
|
+
|
|
269
|
+
Please note that using delegated modules demands a minimum version of `6.1.x` across all applications, given that consumers must be capable of handling the new container interface.
|
|
270
|
+
|
|
271
|
+
Here's a sample usage of a delegated module with `__webpack_require__.l`:
|
|
272
|
+
|
|
273
|
+
<details>
|
|
274
|
+
<summary>See Example: (click) </summary>
|
|
275
|
+
In this example, the delegated module exports a promise that loads the remote entry script located at "http://localhost:3000/_next/static/chunks/remoteEntry.js",
|
|
276
|
+
based on the `__resourceQuery` variable set by webpack at runtime.
|
|
277
|
+
If an error surfaces while loading the script, a unique error object is generated, and the promise is rejected with this error.
|
|
278
|
+
|
|
279
|
+
```js
|
|
280
|
+
//next.config.js
|
|
281
|
+
const { createDelegatedModule } = require('@module-federation/nextjs-mf/utilities');
|
|
282
|
+
const remotes = {
|
|
283
|
+
checkout: createDelegatedModule(require.resolve('./remote-delegate.js'), {
|
|
284
|
+
remote: `checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
285
|
+
otherParam: 'testing',
|
|
286
|
+
}),
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
//remote-delegate.js
|
|
290
|
+
// Delegates must utilize module.exports, not export default - this is due to a webpack constraint
|
|
291
|
+
// ALL imports MUST BE dynamic imports in here like import()
|
|
292
|
+
module.exports = new Promise(async (resolve, reject) => {
|
|
293
|
+
const { importDelegatedModule } = await import('@module-federation/nextjs-mf/importDelegatedModule');
|
|
294
|
+
// eslint-disable-next-line no-undef
|
|
295
|
+
const currentRequest = new URLSearchParams(__resourceQuery).get('remote');
|
|
296
|
+
const [global, url] = currentRequest.split('@');
|
|
297
|
+
importDelegatedModule({
|
|
298
|
+
global,
|
|
299
|
+
url: url + '?' + Date.now(),
|
|
300
|
+
})
|
|
301
|
+
.then((remote) => {
|
|
302
|
+
resolve(remote);
|
|
303
|
+
})
|
|
304
|
+
.catch((err) => reject(err));
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
</details>
|
|
309
|
+
|
|
310
|
+
In the `next.config.js` file, where remotes are configured in the module federation plugin,
|
|
311
|
+
you can use the internal hint to tell webpack to use an internal file as the remote entry.
|
|
312
|
+
This is done by replacing the typical global@url syntax with `internal ./path/to/module`.
|
|
313
|
+
|
|
314
|
+
Webpack has several hint types:
|
|
315
|
+
|
|
316
|
+
- `internal `
|
|
317
|
+
- `promise `
|
|
318
|
+
- `import `
|
|
319
|
+
- `external `
|
|
320
|
+
- `script `
|
|
321
|
+
|
|
322
|
+
The `global@url` syntax is actually script hint: `script global@url`
|
|
323
|
+
|
|
324
|
+
If you want to use the same file for handling all remote entries, you can pass information to the delegate module using query parameters.
|
|
325
|
+
Webpack will pass the query parameters to the module as a string, this is known as `__resourceQuery`.
|
|
326
|
+
It allows you to pass information to the delegate module, so it knows what webpack is currently asking for.
|
|
327
|
+
|
|
328
|
+
You can use query parameters to pass data to a module, webpack will pass the query parameters to the module as a string.
|
|
329
|
+
|
|
330
|
+
For more information on `__resourceQuery` visit: https://webpack.js.org/api/module-variables/#__resourcequery-webpack-specific.
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
// next.config.js
|
|
334
|
+
// its advised you use {createDelegatedModule} from @module-federation/utilities (re-exported as @module-federation/nextjs-mf/utilities) instead of manually creating the delegate module
|
|
335
|
+
const remotes = {
|
|
336
|
+
// pass pointer to remote-delegate, pass delegate remote name as query param,
|
|
337
|
+
// at runtime webpack will pass this as __resourceQuery
|
|
338
|
+
shop: `internal ./remote-delegate.js?remote=shop@http://localhost:3001/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
339
|
+
checkout: `internal ./remote-delegate.js?remote=checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
340
|
+
};
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
#### Expand below to see a full example:
|
|
344
|
+
|
|
345
|
+
<details>
|
|
346
|
+
<summary>See Full configuration with no helpers: (click) </summary>
|
|
347
|
+
|
|
348
|
+
```js
|
|
349
|
+
// next.config.js
|
|
350
|
+
|
|
351
|
+
const remotes = {
|
|
352
|
+
// pass pointer to remote-delegate, pass deletae remote name as query param,
|
|
353
|
+
// at runtime webpack will pass this as __resourceQuery
|
|
354
|
+
shop: `internal ./remote-delegate.js?remote=shop@http://localhost:3001/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
355
|
+
checkout: `internal ./remote-delegate.js?remote=checkout@http://localhost:3002/_next/static/${isServer ? 'ssr' : 'chunks'}/remoteEntry.js`,
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
// remote-delegate.js
|
|
359
|
+
module.exports = new Promise((resolve, reject) => {
|
|
360
|
+
// some node specific for NodeFederation
|
|
361
|
+
if (!globalThis.__remote_scope__) {
|
|
362
|
+
// create a global scope for container, similar to how remotes are set on window in the browser
|
|
363
|
+
globalThis.__remote_scope__ = {
|
|
364
|
+
_config: {},
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
console.log('Delegate being called for', __resourceQuery);
|
|
368
|
+
// get "remote" off resource query, returns url@global
|
|
369
|
+
const currentRequest = new URLSearchParams(__resourceQuery).get('remote');
|
|
370
|
+
// parse syntax
|
|
371
|
+
const [containerGlobal, url] = currentRequest.split('@');
|
|
372
|
+
// if node server, register the containers known origins
|
|
373
|
+
if (typeof window === 'undefined') {
|
|
374
|
+
globalThis.__remote_scope__._config[global] = url;
|
|
375
|
+
}
|
|
376
|
+
const __webpack_error__ = new Error();
|
|
377
|
+
// if you use NodeFederationPlugin, ive build a server-side version of __webpack_require__.l, with the same api.
|
|
378
|
+
// this is how module federation works on the server, i wrote server-side chunk loading.
|
|
379
|
+
__webpack_require__.l(
|
|
380
|
+
url,
|
|
381
|
+
function (event) {
|
|
382
|
+
// resolve promise with container, for browser env or node env.
|
|
383
|
+
const container = typeof window === 'undefined' ? globalThis.__remote_scope__[containerGlobal] : window[containerGlobal];
|
|
384
|
+
console.log('delegate resolving', container);
|
|
385
|
+
if (typeof container !== 'undefined') return resolve(container);
|
|
386
|
+
var realSrc = event && event.target && event.target.src;
|
|
387
|
+
__webpack_error__.message = 'Loading script failed.\\n(' + event.message + ': ' + realSrc + ')';
|
|
388
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
389
|
+
__webpack_error__.stack = event.stack;
|
|
390
|
+
reject(__webpack_error__);
|
|
391
|
+
},
|
|
392
|
+
containerGlobal,
|
|
393
|
+
);
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
</details>
|
|
398
|
+
|
|
399
|
+
## Utilities
|
|
400
|
+
|
|
401
|
+
Ive added a util for dynamic chunk loading, in the event you need to load remote containers dynamically.
|
|
402
|
+
|
|
403
|
+
**InjectScript**
|
|
404
|
+
|
|
405
|
+
```js
|
|
406
|
+
import { injectScript } from '@module-federation/nextjs-mf/utils';
|
|
407
|
+
// if i have remotes in my federation plugin, i can pass the name of the remote
|
|
408
|
+
injectScript('home').then((remoteContainer) => {
|
|
409
|
+
remoteContainer.get('./exposedModule');
|
|
410
|
+
});
|
|
411
|
+
// if i want to load a custom remote not known at build time.
|
|
412
|
+
|
|
413
|
+
injectScript({
|
|
414
|
+
global: 'home',
|
|
415
|
+
url: 'http://somthing.com/remoteEntry.js',
|
|
416
|
+
}).then((remoteContainer) => {
|
|
417
|
+
remoteContainer.get('./exposedModule');
|
|
418
|
+
});
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
**revalidate**
|
|
422
|
+
|
|
423
|
+
Enables hot reloading of node server (not client) in production.
|
|
424
|
+
This is recommended, without it - servers will not be able to pull remote updates without a full restart.
|
|
425
|
+
|
|
426
|
+
More info here: https://github.com/module-federation/nextjs-mf/tree/main/packages/node#utilities
|
|
427
|
+
|
|
428
|
+
```js
|
|
429
|
+
// __document.js
|
|
430
|
+
|
|
431
|
+
import { revalidate } from '@module-federation/nextjs-mf/utils';
|
|
432
|
+
import Document, { Html, Head, Main, NextScript } from 'next/document';
|
|
433
|
+
class MyDocument extends Document {
|
|
434
|
+
static async getInitialProps(ctx) {
|
|
435
|
+
const initialProps = await Document.getInitialProps(ctx);
|
|
436
|
+
|
|
437
|
+
// can be any lifecycle or implementation you want
|
|
438
|
+
ctx?.res?.on('finish', () => {
|
|
439
|
+
revalidate().then((shouldUpdate) => {
|
|
440
|
+
console.log('finished sending response', shouldUpdate);
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
return initialProps;
|
|
445
|
+
}
|
|
446
|
+
render() {
|
|
447
|
+
return (
|
|
448
|
+
<Html>
|
|
449
|
+
<Head />
|
|
450
|
+
<body>
|
|
451
|
+
<Main />
|
|
452
|
+
<NextScript />
|
|
453
|
+
</body>
|
|
454
|
+
</Html>
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## For Express.js
|
|
461
|
+
|
|
462
|
+
Hot reloading Express.js required additional steps: https://github.com/module-federation/universe/blob/main/packages/node/README.md
|
|
463
|
+
|
|
464
|
+
## Contact
|
|
465
|
+
|
|
466
|
+
If you have any questions or need to report a bug
|
|
467
|
+
<a href="https://twitter.com/ScriptedAlchemy"> Reach me on Twitter @ScriptedAlchemy</a>
|
|
468
|
+
|
|
469
|
+
Or join this discussion thread: https://github.com/module-federation/module-federation-examples/discussions/978
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlNode.js","sourceRoot":"","sources":["../../client/UrlNode.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,6DAA6D;AAC7D;;;;;GAKG;AACH,MAAa,OAAO;IAAp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"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@module-federation/nextjs-mf",
|
|
3
|
+
"version": "8.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"description": "Module Federation helper for NextJS",
|
|
9
|
+
"repository": "https://github.com/module-federation/universe/tree/main/packages/nextjs-mf",
|
|
10
|
+
"author": "Zack Jackson <zackary.l.jackson@gmail.com>",
|
|
11
|
+
"contributors": [
|
|
12
|
+
"Pavel Chertorogov, nodkz <pavel.chertorogov@gmail.com> (www.ps.kz)"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/src/index.js",
|
|
20
|
+
"./utilities": "./dist/utilities.js",
|
|
21
|
+
"./utils": "./dist/utils/index.js",
|
|
22
|
+
"./*": "./*"
|
|
23
|
+
},
|
|
24
|
+
"typesVersions": {
|
|
25
|
+
"*": {
|
|
26
|
+
".": [
|
|
27
|
+
"./dist/src/index.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"utils": [
|
|
30
|
+
"./dist/utils/index.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"utilities": [
|
|
33
|
+
"./dist/utilities.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@module-federation/enhanced": "workspace:*",
|
|
42
|
+
"@module-federation/node": "workspace:*",
|
|
43
|
+
"@module-federation/sdk": "workspace:*",
|
|
44
|
+
"@module-federation/utilities": "workspace:*",
|
|
45
|
+
"@module-federation/webpack-type": "workspace:*",
|
|
46
|
+
"acorn": "7.4.1",
|
|
47
|
+
"buffer": "5.7.1",
|
|
48
|
+
"chrome-trace-event": "1.0.3",
|
|
49
|
+
"enhanced-resolve": "5.15.0",
|
|
50
|
+
"eslint-scope": "7.2.2",
|
|
51
|
+
"eventemitter3": "^5.0.0",
|
|
52
|
+
"events": "3.3.0",
|
|
53
|
+
"fast-glob": "^3.2.11",
|
|
54
|
+
"node-fetch": "2.7.0",
|
|
55
|
+
"schema-utils": "3.3.0",
|
|
56
|
+
"tapable": "2.2.1",
|
|
57
|
+
"webpack-sources": "^3.2.3"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"next": "^12 || ^13 || ^14",
|
|
61
|
+
"react": "^17 || ^18",
|
|
62
|
+
"react-dom": "^17 || ^18",
|
|
63
|
+
"styled-jsx": "*",
|
|
64
|
+
"webpack": "^5.40.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"styled-jsx": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-delegate.js","sourceRoot":"","sources":["../../src/default-delegate.ts"],"names":[],"mappings":";;AAWA;;GAEG;AACH,IAAI,IAAI,GAAG,EAAgB,CAAC;AAC5B,IAAI,CAAC;IACH;;OAEG;IACH,aAAa;IACb,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,wBAAwB;AAC1B,CAAC;AACD;;GAEG;AACH,MAAM,UAAU,GAAG,IAAkB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAAC,YAAoB,EAAoB,EAAE;IACrE,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,KAAK,IAAI,CAAC,IAAI,KAA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Root":"","sources":["../../src/federation-noop.ts"],"names":[],"mappings":";AAAA,OAAO,CAAC,WAAW,CAAC,CAAC;AACrB,OAAO,CAAC,aAAa,CAAC,CAAC;AACvB,OAAO,CAAC,WAAW,CAAC,CAAC;AACrB,OAAO,CAAC,aAAa,CAAC,CAAC;AACvB,OAAO,CAAC,YAAY,CAAC,CAAC;AACtB,OAAO,CAAC,cAAc,CAAC,CAAC;AACxB,OAAO,CAAC,YAAY,CAAC,CAAC;AACtB,OAAO,CAAC,UAAU,CAAC,CAAC;AACpB,OAAO,CAAC,YAAY,CAAC,CAAC;AACtB,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC5B,OAAO,CAAC,YAAY,CAAC,CAAC;AACtB,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACjC,OAAO,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,0FAAkE;AAEzD,+BAFF,8BAAoB,CAEE;AAC7B,kBAAe,8BAAoB,CAAC;AAEpC,MAAM,CAAC,OAAO,GAAG,8BAAoB,CAAC;AACtC,MAAM,CAAC,OAAO,CAAC,oBAAoB,GAAG,8BAAoB,CAAC"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toDisplayErrors = exports.getDelegates = exports.parseRemotes = exports.DEFAULT_SHARE_SCOPE_BROWSER = exports.DEFAULT_SHARE_SCOPE = void 0;
|
|
4
4
|
const utilities_1 = require("@module-federation/utilities");
|
|
5
|
-
const
|
|
6
|
-
const options_1 = require("webpack/lib/container/options");
|
|
5
|
+
const enhanced_1 = require("@module-federation/enhanced");
|
|
7
6
|
/**
|
|
8
7
|
* @typedef SharedObject
|
|
9
8
|
* @type {object}
|
|
@@ -188,28 +187,35 @@ const isInternalDelegate = (value) => {
|
|
|
188
187
|
const getDelegates = (remotes) => Object.entries(remotes).reduce((acc, [key, value]) => isInternalDelegate(value) ? { ...acc, [key]: value } : acc, {});
|
|
189
188
|
exports.getDelegates = getDelegates;
|
|
190
189
|
/**
|
|
191
|
-
*
|
|
192
|
-
* If the item is
|
|
190
|
+
* This function validates the type of the shared item and constructs a shared configuration object based on the item and key.
|
|
191
|
+
* If the item is identical to the key or if the item does not necessitate a specific version,
|
|
193
192
|
* the function returns an object with the import property set to the item.
|
|
194
193
|
* Otherwise, it returns an object with the import property set to the key and the requiredVersion property set to the item.
|
|
195
194
|
*
|
|
196
|
-
* @param {string} item - The shared item to be validated and used
|
|
195
|
+
* @param {string | string[]} item - The shared item to be validated and used to construct the shared configuration object. It can be a string or an array of strings.
|
|
197
196
|
* @param {string} key - The key associated with the shared item.
|
|
198
197
|
* @returns {object} - The constructed shared configuration object.
|
|
199
|
-
* @throws {Error} -
|
|
198
|
+
* @throws {Error} - An error is thrown if the item type is not a string or an array of strings.
|
|
200
199
|
*/
|
|
201
200
|
const getSharedConfig = (item, key) => {
|
|
202
|
-
if (
|
|
203
|
-
|
|
201
|
+
if (Array.isArray(item)) {
|
|
202
|
+
// This handles the case where item is an array
|
|
203
|
+
// Replace the following line with your actual logic
|
|
204
|
+
return item.map((i) => ({
|
|
205
|
+
import: i === key || !(0, enhanced_1.isRequiredVersion)(i) ? i : key,
|
|
206
|
+
requiredVersion: i === key || !(0, enhanced_1.isRequiredVersion)(i) ? undefined : i,
|
|
207
|
+
}));
|
|
204
208
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
import: key,
|
|
211
|
-
requiredVersion: item,
|
|
209
|
+
else if (typeof item === 'string') {
|
|
210
|
+
// Handle the case where item is a string
|
|
211
|
+
return {
|
|
212
|
+
import: item === key || !(0, enhanced_1.isRequiredVersion)(item) ? item : key,
|
|
213
|
+
requiredVersion: item === key || !(0, enhanced_1.isRequiredVersion)(item) ? undefined : item,
|
|
212
214
|
};
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
throw new Error('Unexpected type in shared');
|
|
218
|
+
}
|
|
213
219
|
};
|
|
214
220
|
/**
|
|
215
221
|
* Parses the share options from the provided ModuleFederationPluginOptions object and constructs a new object containing all shared configurations.
|
|
@@ -223,7 +229,9 @@ const getSharedConfig = (item, key) => {
|
|
|
223
229
|
* @returns {Record<string, SharedConfig>} - An object containing the shared configuration for each shared item.
|
|
224
230
|
*/
|
|
225
231
|
const parseShareOptions = (options) => {
|
|
226
|
-
|
|
232
|
+
if (!options.shared)
|
|
233
|
+
return options;
|
|
234
|
+
const sharedOptions = (0, enhanced_1.parseOptions)(options.shared, getSharedConfig, (item) => item);
|
|
227
235
|
return sharedOptions.reduce((acc, [key, options]) => {
|
|
228
236
|
acc[key] = {
|
|
229
237
|
import: options.import,
|