@vercel/microfrontends 0.13.0 → 0.15.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 (120) hide show
  1. package/README.md +3 -3
  2. package/dist/bin/cli.cjs +403 -1627
  3. package/dist/config.cjs +460 -1004
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +4 -25
  6. package/dist/config.js +456 -983
  7. package/dist/config.js.map +1 -1
  8. package/dist/{index-83133f2d.d.ts → index-bf67a461.d.ts} +3 -10
  9. package/dist/{v2/microfrontends → microfrontends}/server.cjs +128 -194
  10. package/dist/microfrontends/server.cjs.map +1 -0
  11. package/dist/{v2/microfrontends → microfrontends}/server.d.ts +6 -5
  12. package/dist/{v2/microfrontends → microfrontends}/server.js +125 -191
  13. package/dist/microfrontends/server.js.map +1 -0
  14. package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +21 -35
  15. package/dist/microfrontends.cjs.map +1 -0
  16. package/dist/{v2/microfrontends.d.ts → microfrontends.d.ts} +4 -3
  17. package/dist/{v2/microfrontends.js → microfrontends.js} +20 -34
  18. package/dist/microfrontends.js.map +1 -0
  19. package/dist/next/client.cjs +1 -1
  20. package/dist/next/client.cjs.map +1 -1
  21. package/dist/next/client.js +1 -1
  22. package/dist/next/client.js.map +1 -1
  23. package/dist/next/config.cjs +1323 -1024
  24. package/dist/next/config.cjs.map +1 -1
  25. package/dist/next/config.d.ts +1 -1
  26. package/dist/next/config.js +1327 -1028
  27. package/dist/next/config.js.map +1 -1
  28. package/dist/next/endpoints.cjs +77 -18
  29. package/dist/next/endpoints.cjs.map +1 -1
  30. package/dist/next/endpoints.d.ts +14 -3
  31. package/dist/next/endpoints.js +77 -18
  32. package/dist/next/endpoints.js.map +1 -1
  33. package/dist/next/middleware.cjs +745 -425
  34. package/dist/next/middleware.cjs.map +1 -1
  35. package/dist/next/middleware.d.ts +10 -5
  36. package/dist/next/middleware.js +745 -425
  37. package/dist/next/middleware.js.map +1 -1
  38. package/dist/next/testing.cjs +595 -1032
  39. package/dist/next/testing.cjs.map +1 -1
  40. package/dist/next/testing.d.ts +14 -12
  41. package/dist/next/testing.js +589 -1016
  42. package/dist/next/testing.js.map +1 -1
  43. package/dist/overrides.cjs +40 -108
  44. package/dist/overrides.cjs.map +1 -1
  45. package/dist/overrides.d.ts +24 -2
  46. package/dist/overrides.js +36 -106
  47. package/dist/overrides.js.map +1 -1
  48. package/dist/routing.cjs +19 -0
  49. package/dist/routing.cjs.map +1 -0
  50. package/dist/routing.d.ts +26 -0
  51. package/dist/routing.js +1 -0
  52. package/dist/{v2/schema.cjs → schema.cjs} +1 -1
  53. package/dist/schema.cjs.map +1 -0
  54. package/dist/schema.d.ts +1 -0
  55. package/dist/schema.js.map +1 -0
  56. package/dist/{types-a995174e.d.ts → types-a29d224a.d.ts} +1 -7
  57. package/dist/{types-15b7f215.d.ts → types-cfe3308b.d.ts} +1 -1
  58. package/dist/types-fc30696d.d.ts +11 -0
  59. package/dist/utils/mfe-port.cjs +254 -1362
  60. package/dist/utils/mfe-port.cjs.map +1 -1
  61. package/dist/utils/mfe-port.js +250 -1358
  62. package/dist/utils/mfe-port.js.map +1 -1
  63. package/dist/validation.cjs +31 -365
  64. package/dist/validation.cjs.map +1 -1
  65. package/dist/validation.d.ts +3 -152
  66. package/dist/validation.js +30 -363
  67. package/dist/validation.js.map +1 -1
  68. package/package.json +32 -80
  69. package/schema/schema.json +174 -244
  70. package/dist/config/client.cjs +0 -54
  71. package/dist/config/client.cjs.map +0 -1
  72. package/dist/config/client.d.ts +0 -23
  73. package/dist/config/client.js +0 -28
  74. package/dist/config/client.js.map +0 -1
  75. package/dist/config/edge.cjs +0 -508
  76. package/dist/config/edge.cjs.map +0 -1
  77. package/dist/config/edge.d.ts +0 -20
  78. package/dist/config/edge.js +0 -481
  79. package/dist/config/edge.js.map +0 -1
  80. package/dist/microfrontend-config-983a5139.d.ts +0 -154
  81. package/dist/schema-2922d49e.d.ts +0 -182
  82. package/dist/v2/config.cjs +0 -723
  83. package/dist/v2/config.cjs.map +0 -1
  84. package/dist/v2/config.d.ts +0 -3
  85. package/dist/v2/config.js +0 -698
  86. package/dist/v2/config.js.map +0 -1
  87. package/dist/v2/microfrontends/server.cjs.map +0 -1
  88. package/dist/v2/microfrontends/server.js.map +0 -1
  89. package/dist/v2/microfrontends.cjs.map +0 -1
  90. package/dist/v2/microfrontends.js.map +0 -1
  91. package/dist/v2/next/client.cjs +0 -3
  92. package/dist/v2/next/client.cjs.map +0 -1
  93. package/dist/v2/next/client.d.ts +0 -45
  94. package/dist/v2/next/client.js +0 -3
  95. package/dist/v2/next/client.js.map +0 -1
  96. package/dist/v2/next/config.cjs +0 -2132
  97. package/dist/v2/next/config.cjs.map +0 -1
  98. package/dist/v2/next/config.d.ts +0 -22
  99. package/dist/v2/next/config.js +0 -2097
  100. package/dist/v2/next/config.js.map +0 -1
  101. package/dist/v2/next/endpoints.cjs +0 -141
  102. package/dist/v2/next/endpoints.cjs.map +0 -1
  103. package/dist/v2/next/endpoints.d.ts +0 -15
  104. package/dist/v2/next/endpoints.js +0 -116
  105. package/dist/v2/next/endpoints.js.map +0 -1
  106. package/dist/v2/next/middleware.cjs +0 -1143
  107. package/dist/v2/next/middleware.cjs.map +0 -1
  108. package/dist/v2/next/middleware.d.ts +0 -29
  109. package/dist/v2/next/middleware.js +0 -1115
  110. package/dist/v2/next/middleware.js.map +0 -1
  111. package/dist/v2/overrides.cjs +0 -75
  112. package/dist/v2/overrides.cjs.map +0 -1
  113. package/dist/v2/overrides.d.ts +0 -24
  114. package/dist/v2/overrides.js +0 -45
  115. package/dist/v2/overrides.js.map +0 -1
  116. package/dist/v2/schema.cjs.map +0 -1
  117. package/dist/v2/schema.d.ts +0 -1
  118. package/schema/schema-v2.json +0 -270
  119. /package/dist/{v2/schema.js.map → routing.js.map} +0 -0
  120. /package/dist/{v2/schema.js → schema.js} +0 -0
@@ -1,154 +0,0 @@
1
- import { H as HostConfig, C as Config, R as Routing, V as Vercel, A as ApplicationConfig, O as Options } from './schema-2922d49e.js';
2
-
3
- interface ApplicationOverrideConfig {
4
- environment?: HostConfig;
5
- }
6
- /**
7
- * Used to override the configuration for the application zone at runtime.
8
- * The configuration is used by the `vercel-micro-frontends-overrides` cookie set by the Vercel Toolbar.
9
- * The overrides config has the same shape as the `Config` type.
10
- */
11
- interface OverridesConfig {
12
- applications: Record<keyof Config['applications'], ApplicationOverrideConfig>;
13
- }
14
-
15
- declare const OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
16
- declare class Overrides {
17
- config: OverridesConfig;
18
- constructor(config: OverridesConfig);
19
- static overrideEnvCookiePrefix: string;
20
- static getAppEnvOverrideCookieName(zone: string): string;
21
- static isOverrideCookie(cookie: {
22
- name?: string;
23
- }): boolean;
24
- static getOverrideFromCookie(cookie: {
25
- name: string;
26
- value?: string | null;
27
- }): {
28
- zone: string;
29
- host: string;
30
- } | undefined;
31
- static parseOverrides(cookies: {
32
- name: string;
33
- value?: string | null;
34
- }[]): OverridesConfig;
35
- static validOverrideDomainsForZone(microfrontendConfig: MicrofrontendConfig, zone: string): string[];
36
- static validateOverrideDomain(microfrontendConfig: MicrofrontendConfig, zone: string, domain: string): boolean;
37
- serialize(): OverridesConfig;
38
- }
39
-
40
- interface HostDisplayOptions {
41
- includeDefaultPort?: boolean;
42
- }
43
- declare class Host {
44
- protocol: 'http' | 'https';
45
- host: HostConfig['host'];
46
- port: number;
47
- serialized: HostConfig;
48
- constructor({ protocol, host, port }: HostConfig);
49
- isLocal(): boolean;
50
- static getPort({ protocol, port, }: {
51
- protocol: HostConfig['protocol'];
52
- port?: HostConfig['port'];
53
- }): number;
54
- isDefaultPort(): boolean;
55
- toString(opts?: HostDisplayOptions): string;
56
- toUrl(opts?: HostDisplayOptions): URL;
57
- serialize(): HostConfig;
58
- }
59
-
60
- declare class Application {
61
- default: boolean;
62
- routing?: Routing;
63
- name: string;
64
- development: {
65
- local: Host;
66
- fallback?: Host;
67
- };
68
- production: Host;
69
- vercel?: Vercel;
70
- overrides?: {
71
- environment?: Host;
72
- };
73
- constructor(name: string, { app, overrides, }: {
74
- app: ApplicationConfig;
75
- overrides?: ApplicationOverrideConfig;
76
- });
77
- isDefault(): boolean;
78
- static validate(name: string, app: ApplicationConfig): void;
79
- serialize(): ApplicationConfig;
80
- }
81
-
82
- /**
83
- * A class to manage the microfrontends configuration.
84
- *
85
- * This class should not be used directly. Instead, use the `MicrofrontendConfig` or `MicrofrontendConfigEdgeRuntime` classes.
86
- */
87
- declare class MicrofrontendConfigCommon {
88
- config: Config;
89
- name?: string;
90
- zones: Record<string, Application>;
91
- version: string;
92
- overrides?: Overrides;
93
- options?: Options;
94
- $schema: string | undefined;
95
- constructor({ config, overrides, }: {
96
- config: Config;
97
- overrides?: OverridesConfig;
98
- });
99
- isOverridesDisabled(): boolean;
100
- protected static getConfigFromEnv(): string;
101
- static fromEnv(_: {
102
- cookies: {
103
- name: string;
104
- value: string;
105
- }[];
106
- }): MicrofrontendConfigCommon | Promise<MicrofrontendConfigCommon>;
107
- getConfig(): Config;
108
- getAllApplications(): Application[];
109
- getZone(name: string): Application;
110
- getApplicationByProjectId(projectId: string): Application | undefined;
111
- getDefaultZone(): Application;
112
- /**
113
- * Returns the configured port for the local proxy
114
- */
115
- getLocalProxyPort(): number;
116
- /**
117
- * Serializes the class back to the Schema type.
118
- *
119
- * NOTE: This is used when writing the config to disk and must always match the input Schema
120
- */
121
- toSchemaJson(): Config;
122
- serialize(): {
123
- config: Config;
124
- overrides?: OverridesConfig;
125
- };
126
- write(_: string): void;
127
- }
128
-
129
- /**
130
- * A class to manage the microfrontends configuration with config validation.
131
- *
132
- * Cannot be used by the middleware which runs in the Edge Runtime. For middleware use `MicrofrontendConfigEdgeRuntime`.
133
- */
134
- declare class MicrofrontendConfig extends MicrofrontendConfigCommon {
135
- static validate(configString: string): Config;
136
- static fromEnv({ cookies, }: {
137
- cookies: {
138
- name: string;
139
- value: string;
140
- }[];
141
- }): MicrofrontendConfig;
142
- static fromFile({ filePath, }: {
143
- filePath: string;
144
- }): MicrofrontendConfig;
145
- /**
146
- * Writes the configuration to a file.
147
- */
148
- write(fromApp: string, opts?: {
149
- pretty?: boolean;
150
- versions?: ('v1' | 'v2')[];
151
- }): void;
152
- }
153
-
154
- export { ApplicationOverrideConfig as A, MicrofrontendConfig as M, OverridesConfig as O, MicrofrontendConfigCommon as a, OVERRIDES_COOKIE_PREFIX as b, Overrides as c };
@@ -1,182 +0,0 @@
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
- interface PathGroup {
13
- /**
14
- * Optional group name for the paths
15
- */
16
- group?: string;
17
- options?: PathConfigurationOptions;
18
- paths: string[];
19
- }
20
- interface HostConfig {
21
- /**
22
- * The protocol to be used for the connection.
23
- * - `http`: Hypertext Transfer Protocol (HTTP).
24
- * - `https`: Secure Hypertext Transfer Protocol (HTTPS).
25
- *
26
- * * @defaultValue "https"
27
- */
28
- protocol?: 'http' | 'https';
29
- /**
30
- * The hostname or IP address of the server.
31
- * This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`).
32
- */
33
- host: string;
34
- /**
35
- * The port number to be used for the connection.
36
- * Common values include `80` for HTTP and `443` for HTTPS.
37
- *
38
- * This field is optional and can be omitted if the default ports for the specified protocol are used
39
- */
40
- port?: number;
41
- }
42
- interface Development {
43
- local: HostConfig;
44
- /**
45
- * Fallback for local development, could be a host config that points to any environment.
46
- * If this is not provided, or the application is not running - requests to the application
47
- * in local development will error.
48
- */
49
- fallback?: HostConfig;
50
- /**
51
- * Optional task to run when starting the development server. Should reference a script in the package.json of the application.
52
- *
53
- * @defaultValue "dev"
54
- */
55
- task?: string;
56
- }
57
- interface Vercel {
58
- /**
59
- * Vercel project ID
60
- */
61
- projectId: string;
62
- /**
63
- * Vercel project name (temporary until we can use project ID)
64
- */
65
- projectName?: string;
66
- /**
67
- * The default route for the application. Used to render screenshots, favicons, and provide direct zone links
68
- */
69
- defaultRoute?: string;
70
- /**
71
- * Whether to route Speed Insights to the default zone or each individual microfrontend.
72
- */
73
- routeSpeedInsightsToDefaultZone?: boolean;
74
- }
75
- interface Routing {
76
- /**
77
- * [assetPrefix] for the application
78
- */
79
- assetPrefix?: string;
80
- /**
81
- * Path expressions that are routed to this application.
82
- */
83
- matches: PathGroup[];
84
- }
85
- interface Module {
86
- /**
87
- * The name of the module - should be used when importing the module from another application
88
- */
89
- name: string;
90
- /**
91
- * Relative path to the module within its `application`
92
- */
93
- path: string;
94
- }
95
- interface Federation {
96
- /**
97
- * Modules that are exposed by this application
98
- */
99
- exposes?: Module[];
100
- /**
101
- * Modules that are used by this application. Only the name of the module is required.
102
- */
103
- uses?: string[];
104
- }
105
- interface ApplicationConfigCommon {
106
- /**
107
- * The default application is used no other application is matched via the routing config
108
- */
109
- default: boolean;
110
- routing?: Routing;
111
- development: Development;
112
- production: HostConfig;
113
- metadata?: Record<string, string>;
114
- federation?: Federation;
115
- vercel?: Vercel;
116
- }
117
- interface DefaultApplicationConfig extends ApplicationConfigCommon {
118
- default: true;
119
- }
120
- interface CommonApplicationConfig extends ApplicationConfigCommon {
121
- default: false;
122
- routing: Routing;
123
- }
124
- /** A Micro-Frontend Deployment Target */
125
- type ApplicationConfig = DefaultApplicationConfig | CommonApplicationConfig;
126
- type ApplicationConfigsById = Record<ApplicationId, ApplicationConfig>;
127
- interface VercelOptions {
128
- /**
129
- * If your team uses a custom Preview Deployment Suffix, please specify it here.
130
- * See https://vercel.com/docs/deployments/preview-deployment-suffix.
131
- * The default is `vercel.app`.
132
- */
133
- previewDeploymentSuffix?: string;
134
- /**
135
- * Team slug for the Vercel team
136
- */
137
- teamSlug?: string;
138
- /**
139
- * If you want to disable the overrides for the site. For example, if you are managing rewrites
140
- * between applications externally, you may wish to disable the overrides on the toolbar as
141
- * they will have no effect.
142
- */
143
- disableOverrides?: boolean;
144
- }
145
- interface Options {
146
- /**
147
- * Micro-Frontends wide options for Vercel.
148
- */
149
- vercel?: VercelOptions;
150
- /**
151
- * Options for local proxy.
152
- */
153
- localProxy?: LocalProxyOptions;
154
- }
155
- interface LocalProxyOptions {
156
- /**
157
- * The port number used by the local proxy server.
158
- *
159
- * The default is `3024`.
160
- */
161
- port?: number;
162
- }
163
- /**
164
- * Configuration for micro-frontend applications
165
- *
166
- * TODO: Add proxy configuration
167
- */
168
- interface Config {
169
- version: string;
170
- $schema?: string;
171
- /**
172
- * Name for the micro-frontend site (eg. "vercel.com", "vercel-site" etc.).
173
- */
174
- name?: string;
175
- applications: ApplicationConfigsById;
176
- /**
177
- * Optional configuration for the entire micro-frontends setup.
178
- */
179
- options?: Options;
180
- }
181
-
182
- 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 };