@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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -89
  3. package/dist/bin/cli.cjs +299 -200
  4. package/dist/config.cjs +22 -45
  5. package/dist/config.cjs.map +1 -1
  6. package/dist/config.d.ts +4 -4
  7. package/dist/config.js +22 -45
  8. package/dist/config.js.map +1 -1
  9. package/dist/{types-a29d224a.d.ts → index-5fcf0863.d.ts} +2 -2
  10. package/dist/{index-4399aa8e.d.ts → index-f094deb1.d.ts} +5 -4
  11. package/dist/microfrontends/server.cjs +68 -75
  12. package/dist/microfrontends/server.cjs.map +1 -1
  13. package/dist/microfrontends/server.d.ts +4 -4
  14. package/dist/microfrontends/server.js +68 -75
  15. package/dist/microfrontends/server.js.map +1 -1
  16. package/dist/microfrontends.cjs +24 -48
  17. package/dist/microfrontends.cjs.map +1 -1
  18. package/dist/microfrontends.d.ts +4 -4
  19. package/dist/microfrontends.js +24 -48
  20. package/dist/microfrontends.js.map +1 -1
  21. package/dist/next/client.cjs +1 -1
  22. package/dist/next/client.cjs.map +1 -1
  23. package/dist/next/client.js +1 -1
  24. package/dist/next/client.js.map +1 -1
  25. package/dist/next/config.cjs +86 -101
  26. package/dist/next/config.cjs.map +1 -1
  27. package/dist/next/config.js +86 -101
  28. package/dist/next/config.js.map +1 -1
  29. package/dist/next/endpoints.cjs +1 -1
  30. package/dist/next/endpoints.cjs.map +1 -1
  31. package/dist/next/endpoints.d.ts +2 -2
  32. package/dist/next/endpoints.js +1 -1
  33. package/dist/next/endpoints.js.map +1 -1
  34. package/dist/next/middleware.cjs +32 -63
  35. package/dist/next/middleware.cjs.map +1 -1
  36. package/dist/next/middleware.js +32 -63
  37. package/dist/next/middleware.js.map +1 -1
  38. package/dist/next/testing.cjs +27 -54
  39. package/dist/next/testing.cjs.map +1 -1
  40. package/dist/next/testing.d.ts +4 -4
  41. package/dist/next/testing.js +27 -54
  42. package/dist/next/testing.js.map +1 -1
  43. package/dist/overrides.cjs +1 -2
  44. package/dist/overrides.cjs.map +1 -1
  45. package/dist/overrides.d.ts +3 -3
  46. package/dist/overrides.js +1 -2
  47. package/dist/overrides.js.map +1 -1
  48. package/dist/schema.cjs.map +1 -1
  49. package/dist/schema.d.ts +1 -1
  50. package/dist/{types-fc30696d.d.ts → types-5900be7c.d.ts} +1 -1
  51. package/dist/{types-cfe3308b.d.ts → types-ecd7b91b.d.ts} +1 -1
  52. package/dist/utils/mfe-port.cjs +68 -75
  53. package/dist/utils/mfe-port.cjs.map +1 -1
  54. package/dist/utils/mfe-port.js +68 -75
  55. package/dist/utils/mfe-port.js.map +1 -1
  56. package/dist/validation.cjs +46 -17
  57. package/dist/validation.cjs.map +1 -1
  58. package/dist/validation.d.ts +1 -1
  59. package/dist/validation.js +46 -17
  60. package/dist/validation.js.map +1 -1
  61. package/package.json +18 -22
  62. 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 micro-frontend development.
3
+ Defines configuration and utilities for microfrontends development.
4
4
 
5
5
  ## Getting started
6
6
 
7
- ### Define your `micro-frontend.json` file
7
+ ### Define your `microfrontends.json` file
8
8
 
9
- The first step to get started is to define your `micro-frontend.json` file
10
- listing all the micro-frontend applications in your setup. Since this file will
11
- be used by all the micro-frontends, you can define it in a new NPM package.
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 `packages/my-app-micro-frontends-config`,
14
- then you would define a `micro-frontends.json` at the root.
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
- ```json filename="micro-frontends.json"
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
- "version": "1",
21
+ "$schema": "https://openapi.vercel.sh/microfrontends.json",
19
22
  "applications": {
20
- "next-site": {
21
- "default": true,
22
- "development": {
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
- "protocol": "https",
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
- "nextjs-conf": {
43
- "default": false,
44
- "routing": {
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
- "development": {
54
- "fallback": {
55
- "protocol": "https",
56
- "host": "nextjs-conf.vercel.sh"
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
- "production": {
65
- "protocol": "https",
66
- "host": "nextjs.org"
67
- },
40
+ ]
41
+ },
42
+ "admin": {
68
43
  "vercel": {
69
- "projectId": "prj_iv3tCRmwhF1ETZx2rH9NeoJJsoOc",
70
- "projectName": "nextjs-conf"
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
- In the `package.json` for the package, add the `micro-frontends.json` file to
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 specifying the `micro-frontends.json`
93
- config that you created above.
62
+ with the `withMicrofrontends` function.
94
63
 
95
- ```js filename="next.config.js"
96
- const { withMicrofrontends } = require('@vercel/microfrontends/next/config');
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
- module.exports = withMicrofrontends(
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 micro-frontends middleware. You can run this code
117
- in your middleware to apply the micro-frontends routing logic.
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 two `.well-known`
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/micro-frontends/server-config/route.ts`
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/micro-frontends/server-config/route.ts"
148
- export { wellKnownNextjsServerConfigAppRoute as GET } from '@vercel/microfrontends/next/endpoints';
149
- ```
108
+ ```typescript filename="app/.well-known/vercel/micrfrontends/client-config/route.ts"
109
+ import { wellKnownNextjsClientConfigAppRoute } from '@vercel/microfrontends/next/endpoints';
150
110
 
151
- Then do the same for `app/.well-known/vercel/microfrontends/client-config/route.ts`:
152
-
153
- ```typescript filename
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