@vercel/microfrontends 0.17.1 → 0.17.3
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 +48 -89
- package/dist/bin/cli.cjs +299 -200
- package/dist/config.cjs +22 -45
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +22 -45
- package/dist/config.js.map +1 -1
- package/dist/{types-a29d224a.d.ts → index-5fcf0863.d.ts} +2 -2
- package/dist/{index-4399aa8e.d.ts → index-f094deb1.d.ts} +5 -4
- package/dist/microfrontends/server.cjs +68 -75
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +4 -4
- package/dist/microfrontends/server.js +68 -75
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends.cjs +24 -48
- package/dist/microfrontends.cjs.map +1 -1
- package/dist/microfrontends.d.ts +4 -4
- package/dist/microfrontends.js +24 -48
- package/dist/microfrontends.js.map +1 -1
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +86 -101
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +86 -101
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.cjs +1 -1
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.d.ts +2 -2
- package/dist/next/endpoints.js +1 -1
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +32 -63
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +32 -63
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +27 -54
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +27 -54
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +1 -2
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/overrides.js +1 -2
- package/dist/overrides.js.map +1 -1
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/{types-fc30696d.d.ts → types-5900be7c.d.ts} +1 -1
- package/dist/{types-cfe3308b.d.ts → types-ecd7b91b.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +68 -75
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +68 -75
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +46 -17
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +46 -17
- package/dist/validation.js.map +1 -1
- package/package.json +18 -22
- package/schema/schema.json +15 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vercel
|
|
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
CHANGED
|
@@ -1,111 +1,74 @@
|
|
|
1
1
|
# `@vercel/microfrontends`
|
|
2
2
|
|
|
3
|
-
Defines configuration and utilities for
|
|
3
|
+
Defines configuration and utilities for microfrontends development.
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
|
-
### Define your `
|
|
7
|
+
### Define your `microfrontends.json` file
|
|
8
8
|
|
|
9
|
-
The first step to get started is to define your `
|
|
10
|
-
listing all the
|
|
11
|
-
|
|
9
|
+
The first step to get started is to define your `microfrontends.json` file
|
|
10
|
+
listing all the microfrontends applications in your setup. This file should live at the root
|
|
11
|
+
of your default application.
|
|
12
12
|
|
|
13
|
-
For example, if your configuration is defined in `
|
|
14
|
-
then you would define a `
|
|
13
|
+
For example, if your configuration is defined in `apps/dot-com`,
|
|
14
|
+
then you would define a `apps/dot-com/microfrontends.json` at the root.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
> [!TIP]
|
|
17
|
+
> If you have a long configuration file, comments are supported by using the `.jsonc` extension.
|
|
18
|
+
|
|
19
|
+
```json filename="microfrontends.jsonc"
|
|
17
20
|
{
|
|
18
|
-
"
|
|
21
|
+
"$schema": "https://openapi.vercel.sh/microfrontends.json",
|
|
19
22
|
"applications": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"local": {
|
|
24
|
-
"protocol": "http",
|
|
25
|
-
"host": "localhost",
|
|
26
|
-
"port": 3331
|
|
27
|
-
},
|
|
28
|
-
"fallback": {
|
|
29
|
-
"protocol": "https",
|
|
30
|
-
"host": "nextjs.org"
|
|
31
|
-
}
|
|
23
|
+
"dot-com": {
|
|
24
|
+
"vercel": {
|
|
25
|
+
"projectId": "prj_123"
|
|
32
26
|
},
|
|
33
27
|
"production": {
|
|
34
|
-
"
|
|
35
|
-
"host": "nextjs.org"
|
|
36
|
-
},
|
|
37
|
-
"vercel": {
|
|
38
|
-
"projectId": "QmbxjYNaxv3Qphmreu8tATuLjwdhJBUxqaXC2fz3CMNwB3",
|
|
39
|
-
"projectName": "next-site"
|
|
28
|
+
"host": "my-site.vercel.sh"
|
|
40
29
|
}
|
|
41
30
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"assetPrefix": "nextjs-conf",
|
|
46
|
-
"matches": [
|
|
47
|
-
{
|
|
48
|
-
"group": "next-conf-pages",
|
|
49
|
-
"paths": ["/conf", "/conf/:path*"]
|
|
50
|
-
}
|
|
51
|
-
]
|
|
31
|
+
"docs": {
|
|
32
|
+
"vercel": {
|
|
33
|
+
"projectId": "prj_456"
|
|
52
34
|
},
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
},
|
|
58
|
-
"local": {
|
|
59
|
-
"protocol": "http",
|
|
60
|
-
"host": "localhost",
|
|
61
|
-
"port": 3000
|
|
35
|
+
"routing": [
|
|
36
|
+
{
|
|
37
|
+
"group": "all_pages",
|
|
38
|
+
"paths": ["/docs/:path*"]
|
|
62
39
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"host": "nextjs.org"
|
|
67
|
-
},
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"admin": {
|
|
68
43
|
"vercel": {
|
|
69
|
-
"projectId": "
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
"projectId": "prj_789"
|
|
45
|
+
},
|
|
46
|
+
"routing": [
|
|
47
|
+
{
|
|
48
|
+
"group": "all_pages",
|
|
49
|
+
"paths": ["/admin/:path*"]
|
|
50
|
+
}
|
|
51
|
+
]
|
|
72
52
|
}
|
|
73
53
|
}
|
|
74
54
|
}
|
|
75
55
|
```
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
the `files` attribute.
|
|
79
|
-
|
|
80
|
-
```json filename="package.json"
|
|
81
|
-
{
|
|
82
|
-
"name": "my-app-micro-frontends-config",
|
|
83
|
-
"files": ["micro-frontends.json"]
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Set up Micro-Frontends in each Next.js application
|
|
57
|
+
### Set up Microfrontends in each Next.js application
|
|
88
58
|
|
|
89
59
|
#### `next.config.js`
|
|
90
60
|
|
|
91
61
|
In the `next.config.js` configuration for your application, wrap your config
|
|
92
|
-
with the `withMicrofrontends` function
|
|
93
|
-
config that you created above.
|
|
62
|
+
with the `withMicrofrontends` function.
|
|
94
63
|
|
|
95
|
-
```js filename="next.config.
|
|
96
|
-
|
|
64
|
+
```js filename="next.config.ts"
|
|
65
|
+
import { withMicrofrontends } from '@vercel/microfrontends/next/config';
|
|
97
66
|
|
|
98
67
|
const nextConfig = {
|
|
99
68
|
// ...
|
|
100
69
|
};
|
|
101
70
|
|
|
102
|
-
|
|
103
|
-
nextConfig,
|
|
104
|
-
path.join(
|
|
105
|
-
__dirname,
|
|
106
|
-
'node_modules/my-app-micro-frontends-config/micro-frontends.json',
|
|
107
|
-
),
|
|
108
|
-
);
|
|
71
|
+
export default withMicrofrontends(nextConfig);
|
|
109
72
|
```
|
|
110
73
|
|
|
111
74
|
This will set up the necessary environment variables and `rewrites` for the
|
|
@@ -113,8 +76,8 @@ application.
|
|
|
113
76
|
|
|
114
77
|
#### Middleware
|
|
115
78
|
|
|
116
|
-
Next you have to include the
|
|
117
|
-
in your middleware to apply the
|
|
79
|
+
Next you have to include the microfrontends middleware. You can run this code
|
|
80
|
+
in your middleware to apply the microfrontends routing logic.
|
|
118
81
|
|
|
119
82
|
```typescript filename="middleware.ts"
|
|
120
83
|
import { runMicrofrontendsMiddleware } from '@vercel/microfrontends/next/middleware';
|
|
@@ -132,26 +95,22 @@ export async function middleware(
|
|
|
132
95
|
|
|
133
96
|
#### `.well-known` API endpoints
|
|
134
97
|
|
|
135
|
-
The Micro-Frontends features rely on information exposed in
|
|
98
|
+
The Micro-Frontends features rely on information exposed in `.well-known`
|
|
136
99
|
endpoints:
|
|
137
100
|
|
|
138
|
-
- `/.well-known/vercel/micro-frontends/server-config`
|
|
139
101
|
- `/.well-known/vercel/microfrontends/client-config`
|
|
140
102
|
|
|
141
103
|
You must define API handlers for these two routes to serve the information to
|
|
142
104
|
the client and Vercel Toolbar for Micro-Frontends features to work.
|
|
143
105
|
|
|
144
|
-
If you are using App Router, add a file under the `app/.well-known/vercel/
|
|
145
|
-
file:
|
|
106
|
+
If you are using App Router, add a file under the `app/.well-known/vercel/microfrontends/client-config/route.ts` file:
|
|
146
107
|
|
|
147
|
-
```typescript filename="app/.well-known/vercel/
|
|
148
|
-
|
|
149
|
-
```
|
|
108
|
+
```typescript filename="app/.well-known/vercel/micrfrontends/client-config/route.ts"
|
|
109
|
+
import { wellKnownNextjsClientConfigAppRoute } from '@vercel/microfrontends/next/endpoints';
|
|
150
110
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
export { wellKnownNextjsClientConfigAppRoute as GET } from '@vercel/microfrontends/next/endpoints';
|
|
111
|
+
export async function GET(): Promise<Response> {
|
|
112
|
+
return wellKnownNextjsClientConfigAppRoute();
|
|
113
|
+
}
|
|
155
114
|
```
|
|
156
115
|
|
|
157
116
|
#### Client-side link navigation and prefetching
|