@vercel/microfrontends 0.9.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.
Files changed (100) hide show
  1. package/README.md +202 -0
  2. package/cli/index.cjs +21 -0
  3. package/dist/bin/cli.cjs +1604 -0
  4. package/dist/config/client.cjs +54 -0
  5. package/dist/config/client.cjs.map +1 -0
  6. package/dist/config/client.d.ts +23 -0
  7. package/dist/config/client.js +28 -0
  8. package/dist/config/client.js.map +1 -0
  9. package/dist/config/edge.cjs +508 -0
  10. package/dist/config/edge.cjs.map +1 -0
  11. package/dist/config/edge.d.ts +20 -0
  12. package/dist/config/edge.js +481 -0
  13. package/dist/config/edge.js.map +1 -0
  14. package/dist/config.cjs +1254 -0
  15. package/dist/config.cjs.map +1 -0
  16. package/dist/config.d.ts +25 -0
  17. package/dist/config.js +1212 -0
  18. package/dist/config.js.map +1 -0
  19. package/dist/index-eff254d8.d.ts +175 -0
  20. package/dist/micro-frontend-config-42886104.d.ts +154 -0
  21. package/dist/next/client.cjs +3 -0
  22. package/dist/next/client.cjs.map +1 -0
  23. package/dist/next/client.d.ts +45 -0
  24. package/dist/next/client.js +3 -0
  25. package/dist/next/client.js.map +1 -0
  26. package/dist/next/config.cjs +1793 -0
  27. package/dist/next/config.cjs.map +1 -0
  28. package/dist/next/config.d.ts +22 -0
  29. package/dist/next/config.js +1758 -0
  30. package/dist/next/config.js.map +1 -0
  31. package/dist/next/endpoints.cjs +82 -0
  32. package/dist/next/endpoints.cjs.map +1 -0
  33. package/dist/next/endpoints.d.ts +15 -0
  34. package/dist/next/endpoints.js +57 -0
  35. package/dist/next/endpoints.js.map +1 -0
  36. package/dist/next/middleware.cjs +763 -0
  37. package/dist/next/middleware.cjs.map +1 -0
  38. package/dist/next/middleware.d.ts +29 -0
  39. package/dist/next/middleware.js +735 -0
  40. package/dist/next/middleware.js.map +1 -0
  41. package/dist/next/testing.cjs +1430 -0
  42. package/dist/next/testing.cjs.map +1 -0
  43. package/dist/next/testing.d.ts +53 -0
  44. package/dist/next/testing.js +1389 -0
  45. package/dist/next/testing.js.map +1 -0
  46. package/dist/overrides.cjs +143 -0
  47. package/dist/overrides.cjs.map +1 -0
  48. package/dist/overrides.d.ts +2 -0
  49. package/dist/overrides.js +115 -0
  50. package/dist/overrides.js.map +1 -0
  51. package/dist/schema-83a75e61.d.ts +188 -0
  52. package/dist/types-4fd1c7c6.d.ts +157 -0
  53. package/dist/v2/config.cjs +720 -0
  54. package/dist/v2/config.cjs.map +1 -0
  55. package/dist/v2/config.d.ts +2 -0
  56. package/dist/v2/config.js +695 -0
  57. package/dist/v2/config.js.map +1 -0
  58. package/dist/v2/microfrontends/server.cjs +1312 -0
  59. package/dist/v2/microfrontends/server.cjs.map +1 -0
  60. package/dist/v2/microfrontends/server.d.ts +48 -0
  61. package/dist/v2/microfrontends/server.js +1277 -0
  62. package/dist/v2/microfrontends/server.js.map +1 -0
  63. package/dist/v2/microfrontends.cjs +803 -0
  64. package/dist/v2/microfrontends.cjs.map +1 -0
  65. package/dist/v2/microfrontends.d.ts +44 -0
  66. package/dist/v2/microfrontends.js +776 -0
  67. package/dist/v2/microfrontends.js.map +1 -0
  68. package/dist/v2/next/client.cjs +3 -0
  69. package/dist/v2/next/client.cjs.map +1 -0
  70. package/dist/v2/next/client.d.ts +45 -0
  71. package/dist/v2/next/client.js +3 -0
  72. package/dist/v2/next/client.js.map +1 -0
  73. package/dist/v2/next/config.cjs +1829 -0
  74. package/dist/v2/next/config.cjs.map +1 -0
  75. package/dist/v2/next/config.d.ts +22 -0
  76. package/dist/v2/next/config.js +1794 -0
  77. package/dist/v2/next/config.js.map +1 -0
  78. package/dist/v2/next/endpoints.cjs +138 -0
  79. package/dist/v2/next/endpoints.cjs.map +1 -0
  80. package/dist/v2/next/endpoints.d.ts +15 -0
  81. package/dist/v2/next/endpoints.js +113 -0
  82. package/dist/v2/next/endpoints.js.map +1 -0
  83. package/dist/v2/next/middleware.cjs +1110 -0
  84. package/dist/v2/next/middleware.cjs.map +1 -0
  85. package/dist/v2/next/middleware.d.ts +29 -0
  86. package/dist/v2/next/middleware.js +1082 -0
  87. package/dist/v2/next/middleware.js.map +1 -0
  88. package/dist/v2/schema.cjs +19 -0
  89. package/dist/v2/schema.cjs.map +1 -0
  90. package/dist/v2/schema.d.ts +1 -0
  91. package/dist/v2/schema.js +1 -0
  92. package/dist/v2/schema.js.map +1 -0
  93. package/dist/validation.cjs +754 -0
  94. package/dist/validation.cjs.map +1 -0
  95. package/dist/validation.d.ts +163 -0
  96. package/dist/validation.js +726 -0
  97. package/dist/validation.js.map +1 -0
  98. package/package.json +204 -0
  99. package/schema/schema-v2.json +288 -0
  100. package/schema/schema.json +352 -0
@@ -0,0 +1,188 @@
1
+ /**
2
+ * The unique identifier for a MicroFrontEnd Application.
3
+ * Must match the `name` field of the application's `package.json`.
4
+ */
5
+ type ApplicationId = string;
6
+ interface PathConfigurationOptions {
7
+ /**
8
+ * flag name that can be used to enable/disable all paths in the group
9
+ */
10
+ flag?: string;
11
+ /**
12
+ * True to route the request to the default application for this micro-frontends set-up.
13
+ * This must be `true` when using `flag` or when you want to use custom logic to make
14
+ * the routing decision for this group of paths.
15
+ */
16
+ routeToDefaultApplication?: boolean;
17
+ }
18
+ interface PathGroup {
19
+ /**
20
+ * Optional group name for the paths
21
+ */
22
+ group?: string;
23
+ options?: PathConfigurationOptions;
24
+ paths: string[];
25
+ }
26
+ interface HostConfig {
27
+ /**
28
+ * The protocol to be used for the connection.
29
+ * - `http`: Hypertext Transfer Protocol (HTTP).
30
+ * - `https`: Secure Hypertext Transfer Protocol (HTTPS).
31
+ *
32
+ * * @defaultValue "https"
33
+ */
34
+ protocol?: 'http' | 'https';
35
+ /**
36
+ * The hostname or IP address of the server.
37
+ * This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`).
38
+ */
39
+ host: string;
40
+ /**
41
+ * The port number to be used for the connection.
42
+ * Common values include `80` for HTTP and `443` for HTTPS.
43
+ *
44
+ * This field is optional and can be omitted if the default ports for the specified protocol are used
45
+ */
46
+ port?: number;
47
+ }
48
+ interface Development {
49
+ local: HostConfig;
50
+ /**
51
+ * Fallback for local development, could be a host config that points to any environment.
52
+ * If this is not provided, or the application is not running - requests to the application
53
+ * in local development will error.
54
+ */
55
+ fallback?: HostConfig;
56
+ /**
57
+ * Optional task to run when starting the development server. Should reference a script in the package.json of the application.
58
+ *
59
+ * @defaultValue "dev"
60
+ */
61
+ task?: string;
62
+ }
63
+ interface Vercel {
64
+ /**
65
+ * Vercel project ID
66
+ */
67
+ projectId: string;
68
+ /**
69
+ * Vercel project name (temporary until we can use project ID)
70
+ */
71
+ projectName?: string;
72
+ /**
73
+ * The default route for the application. Used to render screenshots, favicons, and provide direct zone links
74
+ */
75
+ defaultRoute?: string;
76
+ /**
77
+ * Whether to route Speed Insights to the default zone or each individual microfrontend.
78
+ */
79
+ routeSpeedInsightsToDefaultZone?: boolean;
80
+ }
81
+ interface Routing {
82
+ /**
83
+ * [assetPrefix] for the application
84
+ */
85
+ assetPrefix?: string;
86
+ /**
87
+ * Path expressions that are routed to this application.
88
+ */
89
+ matches: PathGroup[];
90
+ }
91
+ interface Module {
92
+ /**
93
+ * The name of the module - should be used when importing the module from another application
94
+ */
95
+ name: string;
96
+ /**
97
+ * Relative path to the module within its `application`
98
+ */
99
+ path: string;
100
+ }
101
+ interface Federation {
102
+ /**
103
+ * Modules that are exposed by this application
104
+ */
105
+ exposes?: Module[];
106
+ /**
107
+ * Modules that are used by this application. Only the name of the module is required.
108
+ */
109
+ uses?: string[];
110
+ }
111
+ interface ApplicationConfigCommon {
112
+ /**
113
+ * The default application is used no other application is matched via the routing config
114
+ */
115
+ default: boolean;
116
+ routing?: Routing;
117
+ development: Development;
118
+ production: HostConfig;
119
+ metadata?: Record<string, string>;
120
+ federation?: Federation;
121
+ vercel?: Vercel;
122
+ }
123
+ interface DefaultApplicationConfig extends ApplicationConfigCommon {
124
+ default: true;
125
+ }
126
+ interface CommonApplicationConfig extends ApplicationConfigCommon {
127
+ default: false;
128
+ routing: Routing;
129
+ }
130
+ /** A Micro-Frontend Deployment Target */
131
+ type ApplicationConfig = DefaultApplicationConfig | CommonApplicationConfig;
132
+ type ApplicationConfigsById = Record<ApplicationId, ApplicationConfig>;
133
+ interface VercelOptions {
134
+ /**
135
+ * If your team uses a custom Preview Deployment Suffix, please specify it here.
136
+ * See https://vercel.com/docs/deployments/preview-deployment-suffix.
137
+ * The default is `vercel.app`.
138
+ */
139
+ previewDeploymentSuffix?: string;
140
+ /**
141
+ * Team slug for the Vercel team
142
+ */
143
+ teamSlug?: string;
144
+ /**
145
+ * If you want to disable the overrides for the site. For example, if you are managing rewrites
146
+ * between applications externally, you may wish to disable the overrides on the toolbar as
147
+ * they will have no effect.
148
+ */
149
+ disableOverrides?: boolean;
150
+ }
151
+ interface Options {
152
+ /**
153
+ * Micro-Frontends wide options for Vercel.
154
+ */
155
+ vercel?: VercelOptions;
156
+ /**
157
+ * Options for local proxy.
158
+ */
159
+ localProxy?: LocalProxyOptions;
160
+ }
161
+ interface LocalProxyOptions {
162
+ /**
163
+ * The port number used by the local proxy server.
164
+ *
165
+ * The default is `3024`.
166
+ */
167
+ port?: number;
168
+ }
169
+ /**
170
+ * Configuration for micro-frontend applications
171
+ *
172
+ * TODO: Add proxy configuration
173
+ */
174
+ interface Config {
175
+ version: string;
176
+ $schema?: string;
177
+ /**
178
+ * Name for the micro-frontend site (eg. "vercel.com", "vercel-site" etc.).
179
+ */
180
+ name?: string;
181
+ applications: ApplicationConfigsById;
182
+ /**
183
+ * Optional configuration for the entire micro-frontends setup.
184
+ */
185
+ options?: Options;
186
+ }
187
+
188
+ export { ApplicationConfig as A, Config as C, DefaultApplicationConfig as D, HostConfig as H, Options as O, Routing as R, Vercel as V, CommonApplicationConfig as a };
@@ -0,0 +1,157 @@
1
+ type Config = MainConfig | ChildConfig;
2
+ interface CommonConfig {
3
+ $schema?: string;
4
+ version: '2';
5
+ options?: Options;
6
+ /**
7
+ * Applications that only serve a subset of the microfrontend routes
8
+ * only need to reference the name of the primary application that owns the
9
+ * full microfrontends configuration.
10
+ */
11
+ remotes?: Record<ApplicationId, Application>;
12
+ }
13
+ interface MainConfig extends CommonConfig {
14
+ provider: Provider;
15
+ /**
16
+ * Mapping of application names to the routes that they host.
17
+ * Only needs to be defined in the application that owns the primary
18
+ * microfrontend domain
19
+ */
20
+ applications: ApplicationRouting;
21
+ }
22
+ interface ChildConfig extends CommonConfig {
23
+ /**
24
+ * Applications that only serve a subset of the microfrontend routes
25
+ * only need to reference the name of the primary application that owns the
26
+ * full microfrontends configuration.
27
+ */
28
+ partOf: string;
29
+ }
30
+ type Provider = 'vercel' | 'other';
31
+ type ApplicationRouting = Record<ApplicationId, Application>;
32
+ /**
33
+ * The unique identifier for a MicroFrontEnd Application.
34
+ * Must match the `name` field of the application's `package.json`.
35
+ */
36
+ type ApplicationId = string;
37
+ type Routing = PathGroup[];
38
+ interface PathGroup {
39
+ /**
40
+ * Optional group name for the paths
41
+ */
42
+ group?: string;
43
+ /**
44
+ * flag name that can be used to enable/disable all paths in the group
45
+ */
46
+ flag?: string;
47
+ /**
48
+ * True to route the request to the default application for this micro-frontends set-up.
49
+ * This must be `true` when using `flag` or when you want to use custom logic to make
50
+ * the routing decision for this group of paths.
51
+ */
52
+ routeToDefaultApplication?: boolean;
53
+ paths: string[];
54
+ }
55
+ interface HostConfig {
56
+ /**
57
+ * The protocol to be used for the connection.
58
+ * - `http`: Hypertext Transfer Protocol (HTTP).
59
+ * - `https`: Secure Hypertext Transfer Protocol (HTTPS).
60
+ *
61
+ * * @defaultValue "http" for local development, "https" for otherwise
62
+ */
63
+ protocol?: 'http' | 'https';
64
+ /**
65
+ * The hostname or IP address of the server.
66
+ * This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`).
67
+ */
68
+ host: string;
69
+ /**
70
+ * The port number to be used for the connection.
71
+ * Common values include `80` for HTTP and `443` for HTTPS.
72
+ *
73
+ */
74
+ port?: number;
75
+ }
76
+ type LocalHostConfig = Omit<HostConfig, 'host'> & {
77
+ /**
78
+ * The hostname or IP address of the server.
79
+ * This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`).
80
+ */
81
+ host?: string;
82
+ };
83
+ interface Development {
84
+ local?: LocalHostConfig;
85
+ /**
86
+ * Fallback for local development, could be a host config that points to any environment.
87
+ * If this is not provided, or the application is not running - requests to the application
88
+ * in local development will error.
89
+ */
90
+ fallback?: HostConfig;
91
+ /**
92
+ * Optional task to run when starting the development server. Should reference a script in the package.json of the application.
93
+ *
94
+ * @defaultValue "dev"
95
+ */
96
+ task?: string;
97
+ }
98
+ type Application = DefaultApplication | ChildApplication;
99
+ interface CommonApplication {
100
+ vercel?: Vercel;
101
+ development?: Development;
102
+ }
103
+ interface DefaultApplication extends CommonApplication {
104
+ production: HostConfig;
105
+ }
106
+ interface ChildApplication extends CommonApplication {
107
+ /**
108
+ * Groups of path expressions that are routed to this application.
109
+ */
110
+ routing: Routing;
111
+ production?: HostConfig;
112
+ }
113
+ interface Vercel {
114
+ /**
115
+ * Vercel project ID
116
+ */
117
+ projectId: string;
118
+ routeSpeedInsightsToDefaultZone?: boolean;
119
+ }
120
+ interface VercelOptions {
121
+ /**
122
+ * If your team uses a custom Preview Deployment Suffix, please specify it here.
123
+ * See https://vercel.com/docs/deployments/preview-deployment-suffix.
124
+ * The default is `vercel.app`.
125
+ */
126
+ previewDeploymentSuffix?: string;
127
+ /**
128
+ * Team slug for the Vercel team
129
+ */
130
+ teamSlug?: string;
131
+ /**
132
+ * If you want to disable the overrides for the site. For example, if you are managing rewrites
133
+ * between applications externally, you may wish to disable the overrides on the toolbar as
134
+ * they will have no effect.
135
+ */
136
+ disableOverrides?: boolean;
137
+ }
138
+ interface Options {
139
+ /**
140
+ * Micro-Frontends wide options for Vercel.
141
+ */
142
+ vercel?: VercelOptions;
143
+ /**
144
+ * Options for local proxy.
145
+ */
146
+ localProxy?: LocalProxyOptions;
147
+ }
148
+ interface LocalProxyOptions {
149
+ /**
150
+ * The port number used by the local proxy server.
151
+ *
152
+ * The default is `3024`.
153
+ */
154
+ port?: number;
155
+ }
156
+
157
+ export { ApplicationId as A, Config as C, DefaultApplication as D, HostConfig as H, LocalHostConfig as L, MainConfig as M, Provider as P, Vercel as V, ChildConfig as a, PathGroup as b, ChildApplication as c, Application as d };