@vercel/microfrontends 0.14.0 → 0.16.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 (121) hide show
  1. package/dist/bin/cli.cjs +392 -1620
  2. package/dist/config.cjs +478 -1001
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +4 -25
  5. package/dist/config.js +474 -980
  6. package/dist/config.js.map +1 -1
  7. package/dist/{v2/microfrontends → microfrontends}/server.cjs +91 -150
  8. package/dist/microfrontends/server.cjs.map +1 -0
  9. package/dist/{v2/microfrontends → microfrontends}/server.d.ts +4 -4
  10. package/dist/{v2/microfrontends → microfrontends}/server.js +91 -150
  11. package/dist/microfrontends/server.js.map +1 -0
  12. package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +49 -28
  13. package/dist/microfrontends.cjs.map +1 -0
  14. package/dist/{v2/microfrontends.d.ts → microfrontends.d.ts} +4 -4
  15. package/dist/{v2/microfrontends.js → microfrontends.js} +48 -27
  16. package/dist/microfrontends.js.map +1 -0
  17. package/dist/next/client.cjs +1 -1
  18. package/dist/next/client.cjs.map +1 -1
  19. package/dist/next/client.js +1 -1
  20. package/dist/next/client.js.map +1 -1
  21. package/dist/next/config.cjs +1344 -1024
  22. package/dist/next/config.cjs.map +1 -1
  23. package/dist/next/config.d.ts +1 -1
  24. package/dist/next/config.js +1343 -1023
  25. package/dist/next/config.js.map +1 -1
  26. package/dist/next/endpoints.cjs +77 -18
  27. package/dist/next/endpoints.cjs.map +1 -1
  28. package/dist/next/endpoints.d.ts +13 -2
  29. package/dist/next/endpoints.js +77 -18
  30. package/dist/next/endpoints.js.map +1 -1
  31. package/dist/next/middleware.cjs +765 -395
  32. package/dist/next/middleware.cjs.map +1 -1
  33. package/dist/next/middleware.d.ts +10 -5
  34. package/dist/next/middleware.js +765 -395
  35. package/dist/next/middleware.js.map +1 -1
  36. package/dist/next/testing.cjs +615 -1031
  37. package/dist/next/testing.cjs.map +1 -1
  38. package/dist/next/testing.d.ts +14 -12
  39. package/dist/next/testing.js +609 -1015
  40. package/dist/next/testing.js.map +1 -1
  41. package/dist/overrides.cjs +40 -108
  42. package/dist/overrides.cjs.map +1 -1
  43. package/dist/overrides.d.ts +24 -2
  44. package/dist/overrides.js +36 -106
  45. package/dist/overrides.js.map +1 -1
  46. package/dist/{v2/routing.cjs → routing.cjs} +3 -3
  47. package/dist/routing.cjs.map +1 -0
  48. package/dist/{v2/schema.cjs → schema.cjs} +1 -1
  49. package/dist/schema.cjs.map +1 -0
  50. package/dist/schema.d.ts +1 -0
  51. package/dist/utils/mfe-port.cjs +237 -1338
  52. package/dist/utils/mfe-port.cjs.map +1 -1
  53. package/dist/utils/mfe-port.js +230 -1331
  54. package/dist/utils/mfe-port.js.map +1 -1
  55. package/dist/validation.cjs +31 -361
  56. package/dist/validation.cjs.map +1 -1
  57. package/dist/validation.d.ts +3 -146
  58. package/dist/validation.js +30 -359
  59. package/dist/validation.js.map +1 -1
  60. package/package.json +29 -92
  61. package/schema/schema.json +174 -244
  62. package/dist/config/client.cjs +0 -54
  63. package/dist/config/client.cjs.map +0 -1
  64. package/dist/config/client.d.ts +0 -23
  65. package/dist/config/client.js +0 -28
  66. package/dist/config/client.js.map +0 -1
  67. package/dist/config/edge.cjs +0 -508
  68. package/dist/config/edge.cjs.map +0 -1
  69. package/dist/config/edge.d.ts +0 -20
  70. package/dist/config/edge.js +0 -481
  71. package/dist/config/edge.js.map +0 -1
  72. package/dist/microfrontend-config-983a5139.d.ts +0 -154
  73. package/dist/schema-2922d49e.d.ts +0 -182
  74. package/dist/v2/config.cjs +0 -709
  75. package/dist/v2/config.cjs.map +0 -1
  76. package/dist/v2/config.d.ts +0 -4
  77. package/dist/v2/config.js +0 -684
  78. package/dist/v2/config.js.map +0 -1
  79. package/dist/v2/microfrontends/server.cjs.map +0 -1
  80. package/dist/v2/microfrontends/server.js.map +0 -1
  81. package/dist/v2/microfrontends.cjs.map +0 -1
  82. package/dist/v2/microfrontends.js.map +0 -1
  83. package/dist/v2/next/client.cjs +0 -3
  84. package/dist/v2/next/client.cjs.map +0 -1
  85. package/dist/v2/next/client.d.ts +0 -45
  86. package/dist/v2/next/client.js +0 -3
  87. package/dist/v2/next/client.js.map +0 -1
  88. package/dist/v2/next/config.cjs +0 -2178
  89. package/dist/v2/next/config.cjs.map +0 -1
  90. package/dist/v2/next/config.d.ts +0 -22
  91. package/dist/v2/next/config.js +0 -2143
  92. package/dist/v2/next/config.js.map +0 -1
  93. package/dist/v2/next/endpoints.cjs +0 -141
  94. package/dist/v2/next/endpoints.cjs.map +0 -1
  95. package/dist/v2/next/endpoints.d.ts +0 -26
  96. package/dist/v2/next/endpoints.js +0 -116
  97. package/dist/v2/next/endpoints.js.map +0 -1
  98. package/dist/v2/next/middleware.cjs +0 -1099
  99. package/dist/v2/next/middleware.cjs.map +0 -1
  100. package/dist/v2/next/middleware.d.ts +0 -34
  101. package/dist/v2/next/middleware.js +0 -1071
  102. package/dist/v2/next/middleware.js.map +0 -1
  103. package/dist/v2/next/testing.cjs +0 -992
  104. package/dist/v2/next/testing.cjs.map +0 -1
  105. package/dist/v2/next/testing.d.ts +0 -55
  106. package/dist/v2/next/testing.js +0 -961
  107. package/dist/v2/next/testing.js.map +0 -1
  108. package/dist/v2/overrides.cjs +0 -75
  109. package/dist/v2/overrides.cjs.map +0 -1
  110. package/dist/v2/overrides.d.ts +0 -24
  111. package/dist/v2/overrides.js +0 -45
  112. package/dist/v2/overrides.js.map +0 -1
  113. package/dist/v2/routing.cjs.map +0 -1
  114. package/dist/v2/schema.cjs.map +0 -1
  115. package/dist/v2/schema.d.ts +0 -1
  116. package/schema/schema-v2.json +0 -266
  117. /package/dist/{v2/routing.d.ts → routing.d.ts} +0 -0
  118. /package/dist/{v2/routing.js → routing.js} +0 -0
  119. /package/dist/{v2/routing.js.map → routing.js.map} +0 -0
  120. /package/dist/{v2/schema.js → schema.js} +0 -0
  121. /package/dist/{v2/schema.js.map → schema.js.map} +0 -0
@@ -1,1165 +1,22 @@
1
1
  // src/utils/mfe-port.ts
2
- import path6 from "node:path";
3
- import fs8 from "node:fs";
4
-
5
- // src/config/types.ts
6
- var isDefaultApplicationConfig = (app) => app.default && typeof app.routing === "undefined";
7
-
8
- // src/config/microfrontend-config.ts
9
- import fs2 from "node:fs";
10
-
11
- // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
12
- import path from "node:path";
13
-
14
- // src/config-v2/microfrontends/server/constants.ts
15
- var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
16
- var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
17
-
18
- // src/utils/is-vercel.ts
19
- function isVercel() {
20
- return process.env.VERCEL === "1";
21
- }
22
-
23
- // src/config-v2/microfrontends/server/utils/get-output-file-path.ts
24
- function getOutputFilePath() {
25
- if (isVercel()) {
26
- return path.join(
27
- ".vercel",
28
- MFE_CONFIG_DEFAULT_FILE_PATH,
29
- MFE_CONFIG_DEFAULT_FILE_NAME
30
- );
31
- }
32
- return path.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
33
- }
34
-
35
- // src/config/errors.ts
36
- var MicrofrontendError = class extends Error {
37
- constructor(message, opts) {
38
- super(message);
39
- this.name = "MicrofrontendsError";
40
- this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
41
- this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
42
- this.subtype = opts == null ? void 0 : opts.subtype;
43
- Error.captureStackTrace(this, MicrofrontendError);
44
- }
45
- isKnown() {
46
- return this.type !== "unknown";
47
- }
48
- isUnknown() {
49
- return !this.isKnown();
50
- }
51
- /**
52
- * Converts an error to a MicrofrontendsError.
53
- * @param original - The original error to convert.
54
- * @returns The converted MicrofrontendsError.
55
- */
56
- static convert(original, opts) {
57
- if (opts == null ? void 0 : opts.fileName) {
58
- const err = MicrofrontendError.convertFSError(original, opts.fileName);
59
- if (err) {
60
- return err;
61
- }
62
- }
63
- if (original.message.includes(
64
- "Code generation from strings disallowed for this context"
65
- )) {
66
- return new MicrofrontendError(original.message, {
67
- type: "config",
68
- subtype: "unsupported_validation_env",
69
- source: "ajv"
70
- });
71
- }
72
- return new MicrofrontendError(original.message);
73
- }
74
- static convertFSError(original, fileName) {
75
- if (original instanceof Error && "code" in original) {
76
- if (original.code === "ENOENT") {
77
- return new MicrofrontendError(`Could not find "${fileName}"`, {
78
- type: "config",
79
- subtype: "unable_to_read_file",
80
- source: "fs"
81
- });
82
- }
83
- if (original.code === "EACCES") {
84
- return new MicrofrontendError(
85
- `Permission denied while accessing "${fileName}"`,
86
- {
87
- type: "config",
88
- subtype: "invalid_permissions",
89
- source: "fs"
90
- }
91
- );
92
- }
93
- }
94
- if (original instanceof SyntaxError) {
95
- return new MicrofrontendError(
96
- `Failed to parse "${fileName}": Invalid JSON format.`,
97
- {
98
- type: "config",
99
- subtype: "invalid_syntax",
100
- source: "fs"
101
- }
102
- );
103
- }
104
- return null;
105
- }
106
- /**
107
- * Handles an unknown error and returns a MicrofrontendsError instance.
108
- * @param err - The error to handle.
109
- * @returns A MicrofrontendsError instance.
110
- */
111
- static handle(err, opts) {
112
- if (err instanceof MicrofrontendError) {
113
- return err;
114
- }
115
- if (err instanceof Error) {
116
- return MicrofrontendError.convert(err, opts);
117
- }
118
- if (typeof err === "object" && err !== null) {
119
- if ("message" in err && typeof err.message === "string") {
120
- return MicrofrontendError.convert(new Error(err.message), opts);
121
- }
122
- }
123
- return new MicrofrontendError("An unknown error occurred");
124
- }
125
- };
126
-
127
- // src/routing/url.ts
128
- function buildUrlSafeString(givenOpts = {}) {
129
- const options = {
130
- joinString: "-",
131
- lowercaseOnly: true,
132
- maxLen: 100,
133
- regexRemovePattern: /(?:(?!(?:[a-z0-9])).)/gi,
134
- trimWhitespace: true,
135
- ...givenOpts
136
- };
137
- return {
138
- generate: (...args) => {
139
- const reJoinString = new RegExp(`${options.joinString}+`, "g");
140
- let tag;
141
- if (args.length === 0) {
142
- throw new Error("generate method must be passed at least one argument");
143
- }
144
- for (let i = 0; i < args.length; i++) {
145
- const arg = args[i];
146
- if (typeof arg !== "string")
147
- throw new Error("all supplied arguments must be Strings");
148
- if (options.trimWhitespace) {
149
- args[i] = arg.trim();
150
- }
151
- }
152
- tag = args.join(options.joinString);
153
- tag = tag.replace(/\s/g, options.joinString);
154
- if (options.lowercaseOnly)
155
- tag = tag.toLowerCase();
156
- tag = tag.replace(options.regexRemovePattern, (match) => {
157
- if (match === options.joinString)
158
- return match;
159
- return "";
160
- });
161
- if (tag.length > options.maxLen)
162
- tag = tag.substring(0, options.maxLen);
163
- tag = tag.replace(reJoinString, options.joinString);
164
- return tag;
165
- }
166
- };
167
- }
168
- var urlSafeString = buildUrlSafeString().generate;
169
- function makeUrlSafe(name) {
170
- return urlSafeString(name.replace(/\//g, "-")).replace(/^-*/g, "").replace(/-*$/g, "");
171
- }
172
-
173
- // src/config/overrides/config.ts
174
- var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
175
- var _Overrides = class {
176
- constructor(config) {
177
- this.config = config;
178
- }
179
- static getAppEnvOverrideCookieName(zone) {
180
- return `${_Overrides.overrideEnvCookiePrefix}${zone}`;
181
- }
182
- static isOverrideCookie(cookie) {
183
- var _a;
184
- return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
185
- }
186
- static getOverrideFromCookie(cookie) {
187
- if (!_Overrides.isOverrideCookie(cookie) || !cookie.value)
188
- return;
189
- return {
190
- zone: cookie.name.replace(_Overrides.overrideEnvCookiePrefix, ""),
191
- host: cookie.value
192
- };
193
- }
194
- static parseOverrides(cookies) {
195
- const overridesConfig = { applications: {} };
196
- cookies.forEach((cookie) => {
197
- const override = _Overrides.getOverrideFromCookie(cookie);
198
- if (!override)
199
- return;
200
- overridesConfig.applications[override.zone] = {
201
- environment: { host: override.host }
202
- };
203
- });
204
- return overridesConfig;
205
- }
206
- static validOverrideDomainsForZone(microfrontendConfig, zone) {
207
- var _a, _b, _c, _d, _e;
208
- const projectName = (_a = microfrontendConfig.getZone(zone).vercel) == null ? void 0 : _a.projectName;
209
- if (!projectName) {
210
- return [microfrontendConfig.getZone(zone).production.host];
211
- }
212
- const parsedProjectName = makeUrlSafe(projectName);
213
- const previewDeploymentSuffix = (_c = (_b = microfrontendConfig.options) == null ? void 0 : _b.vercel) == null ? void 0 : _c.previewDeploymentSuffix;
214
- const teamSlug = (_e = (_d = microfrontendConfig.options) == null ? void 0 : _d.vercel) == null ? void 0 : _e.teamSlug;
215
- if (!teamSlug && !previewDeploymentSuffix) {
216
- return [microfrontendConfig.getZone(zone).production.host];
217
- }
218
- const suffix = previewDeploymentSuffix ? `.${previewDeploymentSuffix}` : `-${teamSlug}.vercel.app`;
219
- return [
220
- `${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,
221
- microfrontendConfig.getZone(zone).production.host
222
- ];
223
- }
224
- static validateOverrideDomain(microfrontendConfig, zone, domain) {
225
- return new RegExp(
226
- `^${_Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(
227
- "|"
228
- )}$`
229
- ).test(domain);
230
- }
231
- serialize() {
232
- return this.config;
233
- }
234
- };
235
- var Overrides = _Overrides;
236
- Overrides.overrideEnvCookiePrefix = `${OVERRIDES_COOKIE_PREFIX}:env:`;
237
-
238
- // src/config/common/host.ts
239
- var Host = class {
240
- constructor({ protocol, host, port }) {
241
- this.protocol = protocol || "https";
242
- this.host = host;
243
- this.port = Host.getPort({ port, protocol: this.protocol });
244
- this.serialized = {
245
- protocol,
246
- host,
247
- ...port ? { port } : void 0
248
- };
249
- }
250
- isLocal() {
251
- return this.host === "localhost" || this.host === "127.0.0.1";
252
- }
253
- static getPort({
254
- protocol,
255
- port
256
- }) {
257
- if (!port) {
258
- if (protocol === "http") {
259
- return 80;
260
- }
261
- return 443;
262
- }
263
- return port;
264
- }
265
- isDefaultPort() {
266
- return this.port === Host.getPort({ protocol: this.protocol });
267
- }
268
- toString(opts = {}) {
269
- const url = this.toUrl(opts);
270
- return url.toString().replace(/\/$/, "");
271
- }
272
- toUrl(opts = {}) {
273
- const { includeDefaultPort } = opts;
274
- const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? "" : `:${this.port}`}`;
275
- return new URL(url);
276
- }
277
- serialize() {
278
- return this.serialized;
279
- }
280
- };
281
-
282
- // src/config/common/application.ts
283
- var Application = class {
284
- constructor(name, {
285
- app,
286
- overrides
287
- }) {
288
- Application.validate(name, app);
289
- this.name = name;
290
- this.default = app.default;
291
- this.routing = app.routing;
292
- this.development = {
293
- local: new Host(app.development.local),
294
- fallback: app.development.fallback ? new Host(app.development.fallback) : void 0
295
- };
296
- this.production = new Host(app.production);
297
- this.vercel = app.vercel;
298
- this.overrides = (overrides == null ? void 0 : overrides.environment) ? {
299
- environment: new Host(overrides.environment)
300
- } : void 0;
301
- }
302
- isDefault() {
303
- return this.default;
304
- }
305
- static validate(name, app) {
306
- var _a, _b, _c, _d, _e;
307
- if (((_b = (_a = app.routing) == null ? void 0 : _a.assetPrefix) == null ? void 0 : _b.startsWith("/")) || ((_d = (_c = app.routing) == null ? void 0 : _c.assetPrefix) == null ? void 0 : _d.endsWith("/"))) {
308
- throw new MicrofrontendError(
309
- `Invalid assetPrefix for application "${name}". Must not start or end with a slash.`,
310
- { type: "zone", subtype: "invalid_asset_prefix" }
311
- );
312
- }
313
- for (const group of ((_e = app.routing) == null ? void 0 : _e.matches) ?? []) {
314
- for (const p of group.paths) {
315
- if (p === "/") {
316
- continue;
317
- }
318
- if (p.endsWith("/")) {
319
- throw new MicrofrontendError(
320
- `Invalid path for application "${name}". ${p} must not end with a slash.`,
321
- { type: "zone", subtype: "invalid_path" }
322
- );
323
- }
324
- if (!p.startsWith("/")) {
325
- throw new MicrofrontendError(
326
- `Invalid path for application "${name}". ${p} must start with a slash.`,
327
- { type: "zone", subtype: "invalid_path" }
328
- );
329
- }
330
- }
331
- }
332
- }
333
- serialize() {
334
- var _a, _b;
335
- if (this.routing === void 0 || this.default) {
336
- return {
337
- default: true,
338
- development: {
339
- local: this.development.local.serialize(),
340
- fallback: (_a = this.development.fallback) == null ? void 0 : _a.serialize()
341
- },
342
- production: this.production.serialize(),
343
- vercel: this.vercel
344
- };
345
- }
346
- return {
347
- default: false,
348
- routing: this.routing,
349
- development: {
350
- local: this.development.local.serialize(),
351
- fallback: (_b = this.development.fallback) == null ? void 0 : _b.serialize()
352
- },
353
- production: this.production.serialize(),
354
- vercel: this.vercel
355
- };
356
- }
357
- };
358
-
359
- // src/config/common/microfrontend-config.ts
360
- var SUPPORTED_VERSIONS = ["1"];
361
- var DEFAULT_LOCAL_PROXY_PORT = 3024;
362
- var MicrofrontendConfigCommon = class {
363
- constructor({
364
- config,
365
- overrides
366
- }) {
367
- this.zones = {};
368
- var _a, _b, _c;
369
- if (!SUPPORTED_VERSIONS.includes(config.version)) {
370
- throw new MicrofrontendError(
371
- `Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
372
- ", "
373
- )}`,
374
- { type: "config", subtype: "unsupported_version" }
375
- );
376
- }
377
- const disableOverrides = ((_b = (_a = config.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
378
- this.overrides = overrides && !disableOverrides ? new Overrides(overrides) : void 0;
379
- for (const [zoneName, zoneConfig] of Object.entries(config.applications)) {
380
- this.zones[zoneName] = new Application(zoneName, {
381
- app: zoneConfig,
382
- overrides: !disableOverrides ? (_c = this.overrides) == null ? void 0 : _c.config.applications[zoneName] : void 0
383
- });
384
- }
385
- this.config = config;
386
- this.name = config.name;
387
- this.version = config.version;
388
- this.options = config.options;
389
- this.$schema = config.$schema;
390
- }
391
- isOverridesDisabled() {
392
- var _a, _b;
393
- return ((_b = (_a = this.options) == null ? void 0 : _a.vercel) == null ? void 0 : _b.disableOverrides) ?? false;
394
- }
395
- static getConfigFromEnv() {
396
- const config = process.env.MFE_CONFIG;
397
- if (!config) {
398
- throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
399
- type: "config",
400
- subtype: "not_found_in_env"
401
- });
402
- }
403
- return config;
404
- }
405
- static fromEnv(_) {
406
- throw new Error("Not implemented");
407
- }
408
- getConfig() {
409
- return this.config;
410
- }
411
- getAllApplications() {
412
- return Object.values(this.zones);
413
- }
414
- getZone(name) {
415
- const zone = this.zones[name];
416
- if (!zone) {
417
- throw new MicrofrontendError(
418
- `Could not find microfrontends configuration for application "${name}"`,
419
- {
420
- type: "zone",
421
- subtype: "not_found"
422
- }
423
- );
424
- }
425
- return zone;
426
- }
427
- getApplicationByProjectId(projectId) {
428
- return Object.values(this.zones).find(
429
- (zone) => {
430
- var _a;
431
- return ((_a = zone.vercel) == null ? void 0 : _a.projectId) === projectId;
432
- }
433
- );
434
- }
435
- getDefaultZone() {
436
- const zone = Object.values(this.zones).find((z) => z.default);
437
- if (!zone) {
438
- throw new MicrofrontendError(
439
- `Could not find default zone in microfrontends configuration`,
440
- {
441
- type: "zone",
442
- subtype: "not_found"
443
- }
444
- );
445
- }
446
- return zone;
447
- }
448
- /**
449
- * Returns the configured port for the local proxy
450
- */
451
- getLocalProxyPort() {
452
- var _a, _b;
453
- return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
454
- }
455
- /**
456
- * Serializes the class back to the Schema type.
457
- *
458
- * NOTE: This is used when writing the config to disk and must always match the input Schema
459
- */
460
- toSchemaJson() {
461
- const applications = {};
462
- for (const [name, zone] of Object.entries(this.zones)) {
463
- applications[name] = zone.serialize();
464
- }
465
- return {
466
- $schema: this.$schema,
467
- name: this.name,
468
- version: this.version,
469
- options: this.options,
470
- applications
471
- };
472
- }
473
- serialize() {
474
- var _a;
475
- const applications = {};
476
- for (const [name, zone] of Object.entries(this.zones)) {
477
- applications[name] = zone.serialize();
478
- }
479
- return {
480
- config: {
481
- name: this.name,
482
- version: this.version,
483
- applications,
484
- options: this.options,
485
- $schema: this.$schema
486
- },
487
- overrides: (_a = this.overrides) == null ? void 0 : _a.serialize()
488
- };
489
- }
490
- write(_) {
491
- throw new MicrofrontendError(
492
- `Writing to file to disk requires using an instance of "MicrofrontendConfig".`,
493
- { type: "config", subtype: "unsupported_operation" }
494
- );
495
- }
496
- };
497
-
498
- // src/config/utils/get-output-file-path.ts
499
- import path2 from "node:path";
500
-
501
- // src/config/constants.ts
502
- var MFE_CONFIG_DEFAULT_FILE_PATH2 = "micro-frontends";
503
- var MFE_CONFIG_DEFAULT_FILE_NAME2 = "micro-frontends.config.json";
504
-
505
- // src/config/utils/get-output-file-path.ts
506
- function getOutputFilePath2() {
507
- if (isVercel()) {
508
- return path2.join(
509
- ".vercel",
510
- MFE_CONFIG_DEFAULT_FILE_PATH2,
511
- MFE_CONFIG_DEFAULT_FILE_NAME2
512
- );
513
- }
514
- return path2.join(MFE_CONFIG_DEFAULT_FILE_PATH2, MFE_CONFIG_DEFAULT_FILE_NAME2);
515
- }
516
-
517
- // src/config/validation.ts
518
- import { parse } from "jsonc-parser";
519
- import { pathToRegexp, parse as parsePathRegexp } from "path-to-regexp";
520
- import { Ajv } from "ajv";
521
-
522
- // schema/schema.json
523
- var schema_default = {
524
- $schema: "http://json-schema.org/draft-07/schema#",
525
- $ref: "#/definitions/Config",
526
- definitions: {
527
- Config: {
528
- type: "object",
529
- properties: {
530
- version: {
531
- type: "string"
532
- },
533
- $schema: {
534
- type: "string"
535
- },
536
- name: {
537
- type: "string",
538
- description: 'Name for the micro-frontend site (eg. "vercel.com", "vercel-site" etc.).'
539
- },
540
- applications: {
541
- $ref: "#/definitions/ApplicationConfigsById"
542
- },
543
- options: {
544
- $ref: "#/definitions/Options",
545
- description: "Optional configuration for the entire micro-frontends setup."
546
- }
547
- },
548
- required: ["version", "applications"],
549
- description: "Configuration for micro-frontend applications\n\nTODO: Add proxy configuration"
550
- },
551
- ApplicationConfigsById: {
552
- type: "object",
553
- additionalProperties: {
554
- $ref: "#/definitions/ApplicationConfig"
555
- }
556
- },
557
- ApplicationConfig: {
558
- anyOf: [
559
- {
560
- $ref: "#/definitions/DefaultApplicationConfig"
561
- },
562
- {
563
- $ref: "#/definitions/CommonApplicationConfig"
564
- }
565
- ],
566
- description: "A Micro-Frontend Deployment Target"
567
- },
568
- DefaultApplicationConfig: {
569
- type: "object",
570
- properties: {
571
- default: {
572
- type: "boolean",
573
- const: true,
574
- description: "The default application is used no other application is matched via the routing config"
575
- },
576
- routing: {
577
- $ref: "#/definitions/Routing"
578
- },
579
- development: {
580
- type: "object",
581
- properties: {
582
- local: {
583
- $ref: "#/definitions/HostConfig"
584
- },
585
- fallback: {
586
- $ref: "#/definitions/HostConfig",
587
- description: "Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error."
588
- },
589
- task: {
590
- type: "string",
591
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
592
- }
593
- },
594
- required: ["local"]
595
- },
596
- production: {
597
- $ref: "#/definitions/HostConfig"
598
- },
599
- metadata: {
600
- type: "object",
601
- additionalProperties: {
602
- type: "string"
603
- }
604
- },
605
- federation: {
606
- type: "object",
607
- properties: {
608
- exposes: {
609
- type: "array",
610
- items: {
611
- type: "object",
612
- properties: {
613
- name: {
614
- type: "string",
615
- description: "The name of the module - should be used when importing the module from another application"
616
- },
617
- path: {
618
- type: "string",
619
- description: "Relative path to the module within its `application`"
620
- }
621
- },
622
- required: ["name", "path"]
623
- },
624
- description: "Modules that are exposed by this application"
625
- },
626
- uses: {
627
- type: "array",
628
- items: {
629
- type: "string"
630
- },
631
- description: "Modules that are used by this application. Only the name of the module is required."
632
- }
633
- }
634
- },
635
- vercel: {
636
- $ref: "#/definitions/Vercel"
637
- }
638
- },
639
- required: ["default", "development", "production"]
640
- },
641
- Routing: {
642
- type: "object",
643
- properties: {
644
- assetPrefix: {
645
- type: "string",
646
- description: "[assetPrefix] for the application"
647
- },
648
- matches: {
649
- type: "array",
650
- items: {
651
- $ref: "#/definitions/PathGroup"
652
- },
653
- description: "Path expressions that are routed to this application."
654
- }
655
- },
656
- required: ["matches"]
657
- },
658
- PathGroup: {
659
- type: "object",
660
- properties: {
661
- group: {
662
- type: "string",
663
- description: "Optional group name for the paths"
664
- },
665
- options: {
666
- type: "object",
667
- properties: {
668
- flag: {
669
- type: "string",
670
- description: "flag name that can be used to enable/disable all paths in the group"
671
- }
672
- }
673
- },
674
- paths: {
675
- type: "array",
676
- items: {
677
- type: "string"
678
- }
679
- }
680
- },
681
- required: ["paths"]
682
- },
683
- HostConfig: {
684
- type: "object",
685
- properties: {
686
- protocol: {
687
- type: "string",
688
- enum: ["http", "https"],
689
- description: 'The protocol to be used for the connection.\n- `http`: Hypertext Transfer Protocol (HTTP).\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\n\n* @defaultValue "https"'
690
- },
691
- host: {
692
- type: "string",
693
- description: "The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`)."
694
- },
695
- port: {
696
- type: "number",
697
- description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS.\n\nThis field is optional and can be omitted if the default ports for the specified protocol are used"
698
- }
699
- },
700
- required: ["host"]
701
- },
702
- Vercel: {
703
- type: "object",
704
- properties: {
705
- projectId: {
706
- type: "string",
707
- description: "Vercel project ID"
708
- },
709
- projectName: {
710
- type: "string",
711
- description: "Vercel project name (temporary until we can use project ID)"
712
- },
713
- defaultRoute: {
714
- type: "string",
715
- description: "The default route for the application. Used to render screenshots, favicons, and provide direct zone links"
716
- },
717
- routeSpeedInsightsToDefaultZone: {
718
- type: "boolean",
719
- description: "Whether to route Speed Insights to the default zone or each individual microfrontend."
720
- }
721
- },
722
- required: ["projectId"]
723
- },
724
- CommonApplicationConfig: {
725
- type: "object",
726
- properties: {
727
- default: {
728
- type: "boolean",
729
- const: false,
730
- description: "The default application is used no other application is matched via the routing config"
731
- },
732
- routing: {
733
- $ref: "#/definitions/Routing"
734
- },
735
- development: {
736
- type: "object",
737
- properties: {
738
- local: {
739
- $ref: "#/definitions/HostConfig"
740
- },
741
- fallback: {
742
- $ref: "#/definitions/HostConfig",
743
- description: "Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error."
744
- },
745
- task: {
746
- type: "string",
747
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
748
- }
749
- },
750
- required: ["local"]
751
- },
752
- production: {
753
- $ref: "#/definitions/HostConfig"
754
- },
755
- metadata: {
756
- type: "object",
757
- additionalProperties: {
758
- type: "string"
759
- }
760
- },
761
- federation: {
762
- type: "object",
763
- properties: {
764
- exposes: {
765
- type: "array",
766
- items: {
767
- type: "object",
768
- properties: {
769
- name: {
770
- type: "string",
771
- description: "The name of the module - should be used when importing the module from another application"
772
- },
773
- path: {
774
- type: "string",
775
- description: "Relative path to the module within its `application`"
776
- }
777
- },
778
- required: ["name", "path"]
779
- },
780
- description: "Modules that are exposed by this application"
781
- },
782
- uses: {
783
- type: "array",
784
- items: {
785
- type: "string"
786
- },
787
- description: "Modules that are used by this application. Only the name of the module is required."
788
- }
789
- }
790
- },
791
- vercel: {
792
- $ref: "#/definitions/Vercel"
793
- }
794
- },
795
- required: ["default", "development", "production", "routing"]
796
- },
797
- Options: {
798
- type: "object",
799
- properties: {
800
- vercel: {
801
- $ref: "#/definitions/VercelOptions",
802
- description: "Micro-Frontends wide options for Vercel."
803
- },
804
- localProxy: {
805
- $ref: "#/definitions/LocalProxyOptions",
806
- description: "Options for local proxy."
807
- }
808
- }
809
- },
810
- VercelOptions: {
811
- type: "object",
812
- properties: {
813
- previewDeploymentSuffix: {
814
- type: "string",
815
- description: "If your team uses a custom Preview Deployment Suffix, please specify it here. See https://vercel.com/docs/deployments/preview-deployment-suffix. The default is `vercel.app`."
816
- },
817
- teamSlug: {
818
- type: "string",
819
- description: "Team slug for the Vercel team"
820
- },
821
- disableOverrides: {
822
- type: "boolean",
823
- description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
824
- }
825
- }
826
- },
827
- LocalProxyOptions: {
828
- type: "object",
829
- properties: {
830
- port: {
831
- type: "number",
832
- description: "The port number used by the local proxy server.\n\nThe default is `3024`."
833
- }
834
- }
835
- }
836
- }
837
- };
838
-
839
- // src/config/utils/load-schema.ts
840
- var SCHEMA = schema_default;
841
-
842
- // src/config/validation.ts
843
- var validateSchema = (configString) => {
844
- const parsedConfig = parse(configString);
845
- const ajv = new Ajv();
846
- const validate = ajv.compile(SCHEMA);
847
- const isValid = validate(parsedConfig);
848
- if (!isValid) {
849
- throw new MicrofrontendError(
850
- `Invalid config: ${ajv.errorsText(validate.errors)}`,
851
- { type: "config", subtype: "does_not_match_schema" }
852
- );
853
- }
854
- return parsedConfig;
855
- };
856
- var SUPPORTED_VERSIONS2 = ["1"];
857
- var validateVersion = (version) => {
858
- if (!SUPPORTED_VERSIONS2.includes(version)) {
859
- throw new MicrofrontendError(
860
- `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS2.join(
861
- ", "
862
- )}`,
863
- { type: "config", subtype: "unsupported_version" }
864
- );
865
- }
866
- };
867
- function validateMainPath(applicationConfigsById) {
868
- for (const [id, app] of Object.entries(applicationConfigsById)) {
869
- const { defaultRoute } = app.vercel ?? {};
870
- if (!defaultRoute) {
871
- continue;
872
- }
873
- if (isDefaultApplicationConfig(app)) {
874
- const pathsWithApp = [];
875
- for (const [otherId, otherApp] of Object.entries(
876
- applicationConfigsById
877
- )) {
878
- if (isDefaultApplicationConfig(otherApp)) {
879
- continue;
880
- }
881
- pathsWithApp.push({
882
- id: otherId,
883
- paths: otherApp.routing.matches.flatMap((match) => match.paths)
884
- });
885
- }
886
- for (const { id: otherId, paths } of pathsWithApp) {
887
- const isValid = paths.every((path7) => {
888
- const matcher = pathToRegexp(path7);
889
- return !matcher.test(defaultRoute);
890
- });
891
- if (!isValid) {
892
- throw new MicrofrontendError(
893
- `default route "${defaultRoute}" cannot be used for "${id}" because it is matched by "${otherId}"`,
894
- { type: "config", subtype: "invalid_main_path" }
895
- );
896
- }
897
- }
898
- } else {
899
- const allPaths = app.routing.matches.flatMap((match) => match.paths);
900
- const isValid = allPaths.some((path7) => {
901
- const matcher = pathToRegexp(path7);
902
- return matcher.test(defaultRoute);
903
- });
904
- if (!isValid) {
905
- throw new MicrofrontendError(
906
- `default route "${defaultRoute}" is not included by the routing config for application "${id}"`,
907
- { type: "config", subtype: "invalid_main_path" }
908
- );
909
- }
910
- }
911
- }
912
- }
913
- var validatePaths = (applicationConfigsById) => {
914
- const pathsByApplicationId = /* @__PURE__ */ new Map();
915
- const errors = [];
916
- for (const [id, app] of Object.entries(applicationConfigsById)) {
917
- if (isDefaultApplicationConfig(app)) {
918
- continue;
919
- }
920
- for (const pathMatch of app.routing.matches) {
921
- for (const path7 of pathMatch.paths) {
922
- const maybeError = validatePathExpression(path7);
923
- if (maybeError) {
924
- errors.push(maybeError);
925
- }
926
- const existing = pathsByApplicationId.get(path7);
927
- if (existing) {
928
- existing.applications.push(id);
929
- } else {
930
- pathsByApplicationId.set(path7, {
931
- applications: [id],
932
- matcher: pathToRegexp(path7),
933
- applicationId: id
934
- });
935
- }
936
- }
937
- }
938
- }
939
- const entries = Array.from(pathsByApplicationId.entries());
940
- entries.forEach(([path7, { applications: ids, matcher, applicationId }]) => {
941
- if (ids.length > 1) {
942
- errors.push(
943
- `Duplicate path "${path7}" for applications "${ids.join(", ")}"`
944
- );
945
- }
946
- entries.forEach(
947
- ([
948
- matchPath,
949
- { applications: matchIds, applicationId: matchApplicationId }
950
- ]) => {
951
- if (path7 === matchPath) {
952
- return;
953
- }
954
- if (applicationId === matchApplicationId) {
955
- return;
956
- }
957
- if (matcher.test(matchPath)) {
958
- const source = `"${path7}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
959
- const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
960
- errors.push(
961
- `Overlapping path detected between ${source} and ${destination}`
962
- );
963
- }
964
- }
965
- );
966
- });
967
- if (errors.length) {
968
- throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
969
- type: "config",
970
- subtype: "conflicting_paths"
971
- });
972
- }
973
- };
974
- var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
975
- function validatePathExpression(path7) {
976
- const tokens = parsePathRegexp(path7);
977
- for (let i = 0; i < tokens.length; i++) {
978
- const token = tokens[i];
979
- if (token === void 0) {
980
- return `token ${i} in ${path7} is undefined, this shouldn't happen`;
981
- }
982
- if (typeof token !== "string") {
983
- if (token.pattern !== PATH_DEFAULT_PATTERN) {
984
- return `Path ${path7} cannot use a regular expression wildcard`;
985
- }
986
- if (token.prefix !== "/") {
987
- return `Wildcard :${token.name} must be immediately after a / in ${path7}`;
988
- }
989
- if (token.suffix) {
990
- return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;
991
- }
992
- if (token.modifier && i !== tokens.length - 1) {
993
- return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path7}. Modifiers are only allowed in the last path component`;
994
- }
995
- }
996
- }
997
- return void 0;
998
- }
999
- var validateDefaults = (applicationConfigsById) => {
1000
- const defaultApplicationIds = Object.entries(applicationConfigsById).reduce((acc, [id, app]) => app.default ? [...acc, id] : acc, []);
1001
- if (defaultApplicationIds.length === 0) {
1002
- throw new MicrofrontendError(
1003
- `No default application found. At least one application must be marked as default.`,
1004
- { type: "config", subtype: "no_default_application" }
1005
- );
1006
- }
1007
- if (defaultApplicationIds.length > 1) {
1008
- throw new MicrofrontendError(
1009
- `Only one default application is allowed. Found ${defaultApplicationIds.join(", ")}.`,
1010
- { type: "config", subtype: "multiple_default_applications" }
1011
- );
1012
- }
1013
- };
1014
- var validateOptions = (options) => {
1015
- var _a;
1016
- if ((_a = options == null ? void 0 : options.vercel) == null ? void 0 : _a.previewDeploymentSuffix) {
1017
- if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
1018
- options.vercel.previewDeploymentSuffix
1019
- )) {
1020
- throw new MicrofrontendError(
1021
- `Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
1022
- { type: "config", subtype: "invalid_preview_deployment_suffix" }
1023
- );
1024
- }
1025
- }
1026
- };
1027
-
1028
- // src/config/utils/convert.ts
1029
- function convertV1RoutingToV2Routing(routing) {
1030
- return routing.matches.map((group) => {
1031
- var _a;
1032
- return {
1033
- group: group.group,
1034
- flag: (_a = group.options) == null ? void 0 : _a.flag,
1035
- paths: group.paths
1036
- };
1037
- });
1038
- }
1039
- function convertV1ApplicationToV2Application(application) {
1040
- const common = {
1041
- production: application.production,
1042
- development: application.development,
1043
- vercel: application.vercel
1044
- };
1045
- if (application.default) {
1046
- return common;
1047
- }
1048
- return {
1049
- ...common,
1050
- routing: convertV1RoutingToV2Routing(application.routing)
1051
- };
1052
- }
1053
- function convertV1ConfigToV2Config(config, fromApp) {
1054
- if (!config.applications[fromApp]) {
1055
- throw new Error(`Application "${fromApp}" not found in the config`);
1056
- }
1057
- const common = {
1058
- version: "2",
1059
- options: config.options
1060
- };
1061
- if (config.applications[fromApp].default) {
1062
- return {
1063
- ...common,
1064
- applications: Object.fromEntries(
1065
- Object.entries(config.applications).map(([id, application]) => [
1066
- id,
1067
- convertV1ApplicationToV2Application(application)
1068
- ])
1069
- )
1070
- };
1071
- }
1072
- const defaultApplication = Object.entries(config.applications).find(
1073
- ([, application]) => application.default
1074
- );
1075
- if (!defaultApplication) {
1076
- throw new Error("No default application found in the config");
1077
- }
1078
- return {
1079
- ...common,
1080
- partOf: defaultApplication[0]
1081
- };
1082
- }
1083
-
1084
- // src/config/utils/write-file.ts
1085
- import fs from "node:fs";
1086
- import { dirname } from "node:path";
1087
- function writeFile(outputPath, config, prettify) {
1088
- fs.mkdirSync(dirname(outputPath), { recursive: true });
1089
- fs.writeFileSync(
1090
- outputPath,
1091
- JSON.stringify(config, null, prettify ? 2 : void 0)
1092
- );
1093
- }
1094
-
1095
- // src/config/microfrontend-config.ts
1096
- var MicrofrontendConfig = class extends MicrofrontendConfigCommon {
1097
- static validate(configString) {
1098
- const config = validateSchema(configString);
1099
- validateVersion(config.version);
1100
- validatePaths(config.applications);
1101
- validateMainPath(config.applications);
1102
- validateDefaults(config.applications);
1103
- validateOptions(config.options);
1104
- return config;
1105
- }
1106
- static fromEnv({
1107
- cookies
1108
- }) {
1109
- return new MicrofrontendConfigCommon({
1110
- config: MicrofrontendConfig.validate(
1111
- MicrofrontendConfigCommon.getConfigFromEnv()
1112
- ),
1113
- overrides: Overrides.parseOverrides(cookies)
1114
- });
1115
- }
1116
- static fromFile({
1117
- filePath
1118
- }) {
1119
- try {
1120
- const config = fs2.readFileSync(filePath, "utf-8");
1121
- return new MicrofrontendConfig({
1122
- config: MicrofrontendConfig.validate(config)
1123
- });
1124
- } catch (e) {
1125
- throw MicrofrontendError.handle(e, {
1126
- fileName: filePath
1127
- });
1128
- }
1129
- }
1130
- /**
1131
- * Writes the configuration to a file.
1132
- */
1133
- write(fromApp, opts = {}) {
1134
- const { pretty = true, versions = ["v1", "v2"] } = opts;
1135
- const config = this.toSchemaJson();
1136
- if (versions.includes("v1")) {
1137
- const outputPath = getOutputFilePath2();
1138
- writeFile(outputPath, config, pretty);
1139
- }
1140
- if (versions.includes("v2")) {
1141
- const outputPath = getOutputFilePath();
1142
- const v2Config = convertV1ConfigToV2Config(config, fromApp);
1143
- writeFile(outputPath, v2Config, pretty);
1144
- }
1145
- }
1146
- };
2
+ import path5 from "node:path";
3
+ import fs6 from "node:fs";
1147
4
 
1148
- // src/config-v2/microfrontends/server/index.ts
1149
- import fs7 from "node:fs";
1150
- import { dirname as dirname4, join as join2 } from "node:path";
5
+ // src/config/microfrontends/server/index.ts
6
+ import fs5 from "node:fs";
7
+ import { dirname as dirname3, join as join2 } from "node:path";
1151
8
 
1152
- // src/config-v2/overrides/constants.ts
1153
- var OVERRIDES_COOKIE_PREFIX2 = "vercel-micro-frontends-override";
1154
- var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX2}:env:`;
9
+ // src/config/overrides/constants.ts
10
+ var OVERRIDES_COOKIE_PREFIX = "vercel-micro-frontends-override";
11
+ var OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;
1155
12
 
1156
- // src/config-v2/overrides/is-override-cookie.ts
13
+ // src/config/overrides/is-override-cookie.ts
1157
14
  function isOverrideCookie(cookie) {
1158
15
  var _a;
1159
- return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX2));
16
+ return Boolean((_a = cookie.name) == null ? void 0 : _a.startsWith(OVERRIDES_COOKIE_PREFIX));
1160
17
  }
1161
18
 
1162
- // src/config-v2/overrides/get-override-from-cookie.ts
19
+ // src/config/overrides/get-override-from-cookie.ts
1163
20
  function getOverrideFromCookie(cookie) {
1164
21
  if (!isOverrideCookie(cookie) || !cookie.value)
1165
22
  return;
@@ -1169,7 +26,7 @@ function getOverrideFromCookie(cookie) {
1169
26
  };
1170
27
  }
1171
28
 
1172
- // src/config-v2/overrides/parse-overrides.ts
29
+ // src/config/overrides/parse-overrides.ts
1173
30
  function parseOverrides(cookies) {
1174
31
  const overridesConfig = { applications: {} };
1175
32
  cookies.forEach((cookie) => {
@@ -1183,15 +40,15 @@ function parseOverrides(cookies) {
1183
40
  return overridesConfig;
1184
41
  }
1185
42
 
1186
- // src/config-v2/errors.ts
1187
- var MicrofrontendError2 = class extends Error {
43
+ // src/config/errors.ts
44
+ var MicrofrontendError = class extends Error {
1188
45
  constructor(message, opts) {
1189
46
  super(message);
1190
47
  this.name = "MicrofrontendsError";
1191
48
  this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
1192
49
  this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
1193
50
  this.subtype = opts == null ? void 0 : opts.subtype;
1194
- Error.captureStackTrace(this, MicrofrontendError2);
51
+ Error.captureStackTrace(this, MicrofrontendError);
1195
52
  }
1196
53
  isKnown() {
1197
54
  return this.type !== "unknown";
@@ -1206,7 +63,7 @@ var MicrofrontendError2 = class extends Error {
1206
63
  */
1207
64
  static convert(original, opts) {
1208
65
  if (opts == null ? void 0 : opts.fileName) {
1209
- const err = MicrofrontendError2.convertFSError(original, opts.fileName);
66
+ const err = MicrofrontendError.convertFSError(original, opts.fileName);
1210
67
  if (err) {
1211
68
  return err;
1212
69
  }
@@ -1214,25 +71,25 @@ var MicrofrontendError2 = class extends Error {
1214
71
  if (original.message.includes(
1215
72
  "Code generation from strings disallowed for this context"
1216
73
  )) {
1217
- return new MicrofrontendError2(original.message, {
74
+ return new MicrofrontendError(original.message, {
1218
75
  type: "config",
1219
76
  subtype: "unsupported_validation_env",
1220
77
  source: "ajv"
1221
78
  });
1222
79
  }
1223
- return new MicrofrontendError2(original.message);
80
+ return new MicrofrontendError(original.message);
1224
81
  }
1225
82
  static convertFSError(original, fileName) {
1226
83
  if (original instanceof Error && "code" in original) {
1227
84
  if (original.code === "ENOENT") {
1228
- return new MicrofrontendError2(`Could not find "${fileName}"`, {
85
+ return new MicrofrontendError(`Could not find "${fileName}"`, {
1229
86
  type: "config",
1230
87
  subtype: "unable_to_read_file",
1231
88
  source: "fs"
1232
89
  });
1233
90
  }
1234
91
  if (original.code === "EACCES") {
1235
- return new MicrofrontendError2(
92
+ return new MicrofrontendError(
1236
93
  `Permission denied while accessing "${fileName}"`,
1237
94
  {
1238
95
  type: "config",
@@ -1243,7 +100,7 @@ var MicrofrontendError2 = class extends Error {
1243
100
  }
1244
101
  }
1245
102
  if (original instanceof SyntaxError) {
1246
- return new MicrofrontendError2(
103
+ return new MicrofrontendError(
1247
104
  `Failed to parse "${fileName}": Invalid JSON format.`,
1248
105
  {
1249
106
  type: "config",
@@ -1260,26 +117,26 @@ var MicrofrontendError2 = class extends Error {
1260
117
  * @returns A MicrofrontendsError instance.
1261
118
  */
1262
119
  static handle(err, opts) {
1263
- if (err instanceof MicrofrontendError2) {
120
+ if (err instanceof MicrofrontendError) {
1264
121
  return err;
1265
122
  }
1266
123
  if (err instanceof Error) {
1267
- return MicrofrontendError2.convert(err, opts);
124
+ return MicrofrontendError.convert(err, opts);
1268
125
  }
1269
126
  if (typeof err === "object" && err !== null) {
1270
127
  if ("message" in err && typeof err.message === "string") {
1271
- return MicrofrontendError2.convert(new Error(err.message), opts);
128
+ return MicrofrontendError.convert(new Error(err.message), opts);
1272
129
  }
1273
130
  }
1274
- return new MicrofrontendError2("An unknown error occurred");
131
+ return new MicrofrontendError("An unknown error occurred");
1275
132
  }
1276
133
  };
1277
134
 
1278
- // src/config-v2/microfrontends-config/utils/get-config-from-env.ts
135
+ // src/config/microfrontends-config/utils/get-config-from-env.ts
1279
136
  function getConfigStringFromEnv() {
1280
137
  const config = process.env.MFE_CONFIG;
1281
138
  if (!config) {
1282
- throw new MicrofrontendError2(`Missing "MFE_CONFIG" in environment.`, {
139
+ throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
1283
140
  type: "config",
1284
141
  subtype: "not_found_in_env"
1285
142
  });
@@ -1287,21 +144,21 @@ function getConfigStringFromEnv() {
1287
144
  return config;
1288
145
  }
1289
146
 
1290
- // src/config-v2/microfrontends-config/isomorphic/index.ts
1291
- import { parse as parse2 } from "jsonc-parser";
147
+ // src/config/microfrontends-config/isomorphic/index.ts
148
+ import { parse } from "jsonc-parser";
1292
149
 
1293
- // src/config-v2/schema/utils/is-main-config.ts
150
+ // src/config/schema/utils/is-main-config.ts
1294
151
  function isMainConfig(c) {
1295
152
  return !("partOf" in c);
1296
153
  }
1297
154
 
1298
- // src/config-v2/schema/utils/is-default-app.ts
155
+ // src/config/schema/utils/is-default-app.ts
1299
156
  function isDefaultApp(a) {
1300
157
  return !("routing" in a);
1301
158
  }
1302
159
 
1303
- // src/config-v2/microfrontends-config/client/index.ts
1304
- import { pathToRegexp as pathToRegexp2 } from "path-to-regexp";
160
+ // src/config/microfrontends-config/client/index.ts
161
+ import { pathToRegexp } from "path-to-regexp";
1305
162
  var MicrofrontendConfigClient = class {
1306
163
  constructor(config, opts) {
1307
164
  this.pathCache = {};
@@ -1331,21 +188,21 @@ var MicrofrontendConfigClient = class {
1331
188
  isEqual(other) {
1332
189
  return JSON.stringify(this.applications) === JSON.stringify(other.applications);
1333
190
  }
1334
- getApplicationNameForPath(path7) {
1335
- if (!path7.startsWith("/")) {
191
+ getApplicationNameForPath(path6) {
192
+ if (!path6.startsWith("/")) {
1336
193
  throw new Error(`Path must start with a /`);
1337
194
  }
1338
- if (this.pathCache[path7]) {
1339
- return this.pathCache[path7];
195
+ if (this.pathCache[path6]) {
196
+ return this.pathCache[path6];
1340
197
  }
1341
- const pathname = new URL(path7, "https://example.com").pathname;
198
+ const pathname = new URL(path6, "https://example.com").pathname;
1342
199
  for (const [name, application] of Object.entries(this.applications)) {
1343
200
  if (application.routing) {
1344
201
  for (const group of application.routing) {
1345
202
  for (const childPath of group.paths) {
1346
- const regexp = pathToRegexp2(childPath);
203
+ const regexp = pathToRegexp(childPath);
1347
204
  if (regexp.test(pathname)) {
1348
- this.pathCache[path7] = name;
205
+ this.pathCache[path6] = name;
1349
206
  return name;
1350
207
  }
1351
208
  }
@@ -1358,7 +215,7 @@ var MicrofrontendConfigClient = class {
1358
215
  if (!defaultApplication) {
1359
216
  return null;
1360
217
  }
1361
- this.pathCache[path7] = defaultApplication[0];
218
+ this.pathCache[path6] = defaultApplication[0];
1362
219
  return defaultApplication[0];
1363
220
  }
1364
221
  serialize() {
@@ -1366,13 +223,13 @@ var MicrofrontendConfigClient = class {
1366
223
  }
1367
224
  };
1368
225
 
1369
- // src/config-v2/microfrontends-config/isomorphic/validation.ts
1370
- import { pathToRegexp as pathToRegexp3, parse as parsePathRegexp2 } from "path-to-regexp";
1371
- var SUPPORTED_VERSIONS3 = ["2"];
226
+ // src/config/microfrontends-config/isomorphic/validation.ts
227
+ import { pathToRegexp as pathToRegexp2, parse as parsePathRegexp } from "path-to-regexp";
228
+ var SUPPORTED_VERSIONS = ["2"];
1372
229
  var validateConfigVersion = (version) => {
1373
- if (!SUPPORTED_VERSIONS3.includes(version)) {
1374
- throw new MicrofrontendError2(
1375
- `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS3.join(
230
+ if (!SUPPORTED_VERSIONS.includes(version)) {
231
+ throw new MicrofrontendError(
232
+ `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
1376
233
  ", "
1377
234
  )}`,
1378
235
  { type: "config", subtype: "unsupported_version" }
@@ -1390,22 +247,18 @@ var validateConfigPaths = (applicationConfigsById) => {
1390
247
  continue;
1391
248
  }
1392
249
  for (const pathMatch of app.routing) {
1393
- for (const path7 of pathMatch.paths) {
1394
- const tokens = parsePathRegexp2(path7);
1395
- for (const token of tokens.slice(0, -1)) {
1396
- if (typeof token !== "string") {
1397
- errors.push(
1398
- `Path ${path7} may only have a :wildcard in the last path component`
1399
- );
1400
- }
250
+ for (const path6 of pathMatch.paths) {
251
+ const maybeError = validatePathExpression(path6);
252
+ if (maybeError) {
253
+ errors.push(maybeError);
1401
254
  }
1402
- const existing = pathsByApplicationId.get(path7);
255
+ const existing = pathsByApplicationId.get(path6);
1403
256
  if (existing) {
1404
257
  existing.applications.push(id);
1405
258
  } else {
1406
- pathsByApplicationId.set(path7, {
259
+ pathsByApplicationId.set(path6, {
1407
260
  applications: [id],
1408
- matcher: pathToRegexp3(path7),
261
+ matcher: pathToRegexp2(path6),
1409
262
  applicationId: id
1410
263
  });
1411
264
  }
@@ -1413,10 +266,10 @@ var validateConfigPaths = (applicationConfigsById) => {
1413
266
  }
1414
267
  }
1415
268
  const entries = Array.from(pathsByApplicationId.entries());
1416
- entries.forEach(([path7, { applications: ids, matcher, applicationId }]) => {
269
+ entries.forEach(([path6, { applications: ids, matcher, applicationId }]) => {
1417
270
  if (ids.length > 1) {
1418
271
  errors.push(
1419
- `Duplicate path "${path7}" for applications "${ids.join(", ")}"`
272
+ `Duplicate path "${path6}" for applications "${ids.join(", ")}"`
1420
273
  );
1421
274
  }
1422
275
  entries.forEach(
@@ -1424,14 +277,14 @@ var validateConfigPaths = (applicationConfigsById) => {
1424
277
  matchPath,
1425
278
  { applications: matchIds, applicationId: matchApplicationId }
1426
279
  ]) => {
1427
- if (path7 === matchPath) {
280
+ if (path6 === matchPath) {
1428
281
  return;
1429
282
  }
1430
283
  if (applicationId === matchApplicationId) {
1431
284
  return;
1432
285
  }
1433
286
  if (matcher.test(matchPath)) {
1434
- const source = `"${path7}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
287
+ const source = `"${path6}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
1435
288
  const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
1436
289
  errors.push(
1437
290
  `Overlapping path detected between ${source} and ${destination}`
@@ -1441,12 +294,37 @@ var validateConfigPaths = (applicationConfigsById) => {
1441
294
  );
1442
295
  });
1443
296
  if (errors.length) {
1444
- throw new MicrofrontendError2(`Invalid paths: ${errors.join(", ")}`, {
297
+ throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
1445
298
  type: "config",
1446
299
  subtype: "conflicting_paths"
1447
300
  });
1448
301
  }
1449
302
  };
303
+ var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
304
+ function validatePathExpression(path6) {
305
+ const tokens = parsePathRegexp(path6);
306
+ for (let i = 0; i < tokens.length; i++) {
307
+ const token = tokens[i];
308
+ if (token === void 0) {
309
+ return `token ${i} in ${path6} is undefined, this shouldn't happen`;
310
+ }
311
+ if (typeof token !== "string") {
312
+ if (token.pattern !== PATH_DEFAULT_PATTERN) {
313
+ return `Path ${path6} cannot use a regular expression wildcard`;
314
+ }
315
+ if (token.prefix !== "/") {
316
+ return `Wildcard :${token.name} must be immediately after a / in ${path6}`;
317
+ }
318
+ if (token.suffix) {
319
+ return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;
320
+ }
321
+ if (token.modifier && i !== tokens.length - 1) {
322
+ return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path6}. Modifiers are only allowed in the last path component`;
323
+ }
324
+ }
325
+ }
326
+ return void 0;
327
+ }
1450
328
  var validateAppPaths = (name, app) => {
1451
329
  for (const group of app.routing) {
1452
330
  for (const p of group.paths) {
@@ -1454,13 +332,13 @@ var validateAppPaths = (name, app) => {
1454
332
  continue;
1455
333
  }
1456
334
  if (p.endsWith("/")) {
1457
- throw new MicrofrontendError2(
335
+ throw new MicrofrontendError(
1458
336
  `Invalid path for application "${name}". ${p} must not end with a slash.`,
1459
337
  { type: "application", subtype: "invalid_path" }
1460
338
  );
1461
339
  }
1462
340
  if (!p.startsWith("/")) {
1463
- throw new MicrofrontendError2(
341
+ throw new MicrofrontendError(
1464
342
  `Invalid path for application "${name}". ${p} must start with a slash.`,
1465
343
  { type: "application", subtype: "invalid_path" }
1466
344
  );
@@ -1482,20 +360,20 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
1482
360
  const numApplicationsWithRouting = applicationsWithRoutingNames.length;
1483
361
  const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
1484
362
  if (numApplicationsWithoutRouting === 0) {
1485
- throw new MicrofrontendError2(
363
+ throw new MicrofrontendError(
1486
364
  `No default application found. At least one application needs to be the default by omitting routing.`,
1487
365
  { type: "config", subtype: "no_default_application" }
1488
366
  );
1489
367
  }
1490
368
  if (numApplicationsWithoutRouting > 1) {
1491
- throw new MicrofrontendError2(
369
+ throw new MicrofrontendError(
1492
370
  `Only one application can omit "routing". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,
1493
371
  { type: "config", subtype: "multiple_default_applications" }
1494
372
  );
1495
373
  }
1496
374
  };
1497
375
 
1498
- // src/config-v2/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
376
+ // src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
1499
377
  var PREFIX = "vc-ap";
1500
378
  function generateAssetPrefixFromName({
1501
379
  name
@@ -1506,7 +384,7 @@ function generateAssetPrefixFromName({
1506
384
  return `${PREFIX}-${name}`;
1507
385
  }
1508
386
 
1509
- // src/config-v2/microfrontends-config/isomorphic/utils/generate-port.ts
387
+ // src/config/microfrontends-config/isomorphic/utils/generate-port.ts
1510
388
  function generatePortFromName({
1511
389
  name,
1512
390
  minPort = 3e3,
@@ -1526,13 +404,13 @@ function generatePortFromName({
1526
404
  return port;
1527
405
  }
1528
406
 
1529
- // src/config-v2/microfrontends-config/isomorphic/host.ts
1530
- var Host2 = class {
407
+ // src/config/microfrontends-config/isomorphic/host.ts
408
+ var Host = class {
1531
409
  constructor(hostConfig, options) {
1532
410
  const { protocol = "https", host, port } = hostConfig;
1533
411
  this.protocol = protocol;
1534
412
  this.host = host;
1535
- this.port = Host2.getPort({ port, protocol: this.protocol });
413
+ this.port = Host.getPort({ port, protocol: this.protocol });
1536
414
  this.local = options == null ? void 0 : options.isLocal;
1537
415
  }
1538
416
  isLocal() {
@@ -1551,7 +429,7 @@ var Host2 = class {
1551
429
  return port;
1552
430
  }
1553
431
  isDefaultPort() {
1554
- return this.port === Host2.getPort({ protocol: this.protocol });
432
+ return this.port === Host.getPort({ protocol: this.protocol });
1555
433
  }
1556
434
  toString(opts = {}) {
1557
435
  const url = this.toUrl(opts);
@@ -1563,7 +441,7 @@ var Host2 = class {
1563
441
  return new URL(url);
1564
442
  }
1565
443
  };
1566
- var LocalHost = class extends Host2 {
444
+ var LocalHost = class extends Host {
1567
445
  constructor({
1568
446
  appName,
1569
447
  ...hostConfig
@@ -1575,8 +453,8 @@ var LocalHost = class extends Host2 {
1575
453
  }
1576
454
  };
1577
455
 
1578
- // src/config-v2/microfrontends-config/isomorphic/application.ts
1579
- var Application2 = class {
456
+ // src/config/microfrontends-config/isomorphic/application.ts
457
+ var Application = class {
1580
458
  constructor(name, {
1581
459
  app,
1582
460
  overrides,
@@ -1589,12 +467,12 @@ var Application2 = class {
1589
467
  appName: name,
1590
468
  ...(_a = app.development) == null ? void 0 : _a.local
1591
469
  }),
1592
- fallback: ((_b = app.development) == null ? void 0 : _b.fallback) ? new Host2(app.development.fallback) : void 0
470
+ fallback: ((_b = app.development) == null ? void 0 : _b.fallback) ? new Host(app.development.fallback) : void 0
1593
471
  };
1594
- this.production = app.production ? new Host2(app.production) : void 0;
472
+ this.production = app.production ? new Host(app.production) : void 0;
1595
473
  this.vercel = app.vercel;
1596
474
  this.overrides = (overrides == null ? void 0 : overrides.environment) ? {
1597
- environment: new Host2(overrides.environment)
475
+ environment: new Host(overrides.environment)
1598
476
  } : void 0;
1599
477
  this.default = isDefault ?? false;
1600
478
  this.serialized = app;
@@ -1609,7 +487,7 @@ var Application2 = class {
1609
487
  return this.serialized;
1610
488
  }
1611
489
  };
1612
- var DefaultApplication = class extends Application2 {
490
+ var DefaultApplication = class extends Application {
1613
491
  constructor(name, {
1614
492
  app,
1615
493
  overrides
@@ -1620,13 +498,13 @@ var DefaultApplication = class extends Application2 {
1620
498
  isDefault: true
1621
499
  });
1622
500
  this.default = true;
1623
- this.production = new Host2(app.production);
501
+ this.production = new Host(app.production);
1624
502
  }
1625
503
  getAssetPrefix() {
1626
504
  return "";
1627
505
  }
1628
506
  };
1629
- var ChildApplication = class extends Application2 {
507
+ var ChildApplication = class extends Application {
1630
508
  constructor(name, {
1631
509
  app,
1632
510
  overrides
@@ -1645,10 +523,10 @@ var ChildApplication = class extends Application2 {
1645
523
  }
1646
524
  };
1647
525
 
1648
- // src/config-v2/microfrontends-config/isomorphic/constants.ts
1649
- var DEFAULT_LOCAL_PROXY_PORT2 = 3024;
526
+ // src/config/microfrontends-config/isomorphic/constants.ts
527
+ var DEFAULT_LOCAL_PROXY_PORT = 3024;
1650
528
 
1651
- // src/config-v2/microfrontends-config/isomorphic/index.ts
529
+ // src/config/microfrontends-config/isomorphic/index.ts
1652
530
  var MicrofrontendConfigIsomorphic = class {
1653
531
  constructor({
1654
532
  config,
@@ -1689,7 +567,7 @@ var MicrofrontendConfigIsomorphic = class {
1689
567
  );
1690
568
  }
1691
569
  if (isMainConfig(config) && !this.defaultApplication) {
1692
- throw new MicrofrontendError2(
570
+ throw new MicrofrontendError(
1693
571
  `Could not find default application in microfrontends configuration`,
1694
572
  {
1695
573
  type: "application",
@@ -1706,7 +584,7 @@ var MicrofrontendConfigIsomorphic = class {
1706
584
  };
1707
585
  }
1708
586
  static validate(config) {
1709
- const c = typeof config === "string" ? parse2(config) : config;
587
+ const c = typeof config === "string" ? parse(config) : config;
1710
588
  if (isMainConfig(c)) {
1711
589
  validateConfigVersion(c.version);
1712
590
  validateConfigPaths(c.applications);
@@ -1719,7 +597,7 @@ var MicrofrontendConfigIsomorphic = class {
1719
597
  cookies
1720
598
  }) {
1721
599
  return new MicrofrontendConfigIsomorphic({
1722
- config: parse2(getConfigStringFromEnv()),
600
+ config: parse(getConfigStringFromEnv()),
1723
601
  overrides: parseOverrides(cookies ?? []),
1724
602
  meta
1725
603
  });
@@ -1753,7 +631,7 @@ var MicrofrontendConfigIsomorphic = class {
1753
631
  }
1754
632
  const app = this.childApplications[name];
1755
633
  if (!app) {
1756
- throw new MicrofrontendError2(
634
+ throw new MicrofrontendError(
1757
635
  `Could not find microfrontends configuration for application "${name}"`,
1758
636
  {
1759
637
  type: "application",
@@ -1781,7 +659,7 @@ var MicrofrontendConfigIsomorphic = class {
1781
659
  */
1782
660
  getDefaultApplication() {
1783
661
  if (!this.defaultApplication) {
1784
- throw new MicrofrontendError2(
662
+ throw new MicrofrontendError(
1785
663
  `Could not find default application in microfrontends configuration`,
1786
664
  {
1787
665
  type: "application",
@@ -1796,7 +674,7 @@ var MicrofrontendConfigIsomorphic = class {
1796
674
  */
1797
675
  getLocalProxyPort() {
1798
676
  var _a, _b;
1799
- return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT2;
677
+ return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
1800
678
  }
1801
679
  /**
1802
680
  * Serializes the class back to the Schema type.
@@ -1830,7 +708,7 @@ var MicrofrontendConfigIsomorphic = class {
1830
708
  }
1831
709
  };
1832
710
 
1833
- // src/config-v2/microfrontends-config/isomorphic/child.ts
711
+ // src/config/microfrontends-config/isomorphic/child.ts
1834
712
  var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
1835
713
  constructor({
1836
714
  config,
@@ -1843,7 +721,7 @@ var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
1843
721
  }
1844
722
  };
1845
723
 
1846
- // src/config-v2/microfrontends-config/isomorphic/main.ts
724
+ // src/config/microfrontends-config/isomorphic/main.ts
1847
725
  var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1848
726
  constructor({
1849
727
  config,
@@ -1870,7 +748,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1870
748
  }
1871
749
  }
1872
750
  if (!defaultApplication) {
1873
- throw new MicrofrontendError2(
751
+ throw new MicrofrontendError(
1874
752
  `Could not find default application in microfrontends configuration`,
1875
753
  {
1876
754
  type: "application",
@@ -1882,7 +760,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1882
760
  }
1883
761
  };
1884
762
 
1885
- // src/config-v2/microfrontends/isomorphic/index.ts
763
+ // src/config/microfrontends/isomorphic/index.ts
1886
764
  var Microfrontends = class {
1887
765
  constructor({
1888
766
  config,
@@ -1910,26 +788,26 @@ var Microfrontends = class {
1910
788
  }
1911
789
  };
1912
790
 
1913
- // src/config-v2/microfrontends/utils/find-repository-root.ts
1914
- import fs3 from "node:fs";
1915
- import path3 from "node:path";
791
+ // src/config/microfrontends/utils/find-repository-root.ts
792
+ import fs from "node:fs";
793
+ import path from "node:path";
1916
794
  var GIT_DIRECTORY = ".git";
1917
795
  function findRepositoryRoot(startDir) {
1918
796
  let currentDir = startDir || process.cwd();
1919
- while (currentDir !== path3.parse(currentDir).root) {
1920
- const gitPath = path3.join(currentDir, GIT_DIRECTORY);
1921
- if (fs3.existsSync(gitPath) && fs3.statSync(gitPath).isDirectory()) {
797
+ while (currentDir !== path.parse(currentDir).root) {
798
+ const gitPath = path.join(currentDir, GIT_DIRECTORY);
799
+ if (fs.existsSync(gitPath) && fs.statSync(gitPath).isDirectory()) {
1922
800
  return currentDir;
1923
801
  }
1924
- currentDir = path3.dirname(currentDir);
802
+ currentDir = path.dirname(currentDir);
1925
803
  }
1926
804
  throw new Error(
1927
805
  "Repository root not found. Specify the root of the repository with the `repository.root` option."
1928
806
  );
1929
807
  }
1930
808
 
1931
- // src/config-v2/microfrontends/utils/find-package-path.ts
1932
- import { dirname as dirname2 } from "node:path";
809
+ // src/config/microfrontends/utils/find-package-path.ts
810
+ import { dirname } from "node:path";
1933
811
  import { readFileSync } from "node:fs";
1934
812
  import fg from "fast-glob";
1935
813
  var configCache = {};
@@ -1964,7 +842,7 @@ function findPackagePathWithGlob({
1964
842
  );
1965
843
  }
1966
844
  const [packageJsonPath] = matchingPaths;
1967
- return dirname2(packageJsonPath);
845
+ return dirname(packageJsonPath);
1968
846
  } catch (error) {
1969
847
  return null;
1970
848
  }
@@ -1984,19 +862,19 @@ function findPackagePath(opts) {
1984
862
  return result;
1985
863
  }
1986
864
 
1987
- // src/config-v2/microfrontends/utils/find-default-package.ts
1988
- import { dirname as dirname3 } from "node:path";
865
+ // src/config/microfrontends/utils/find-default-package.ts
866
+ import { dirname as dirname2 } from "node:path";
1989
867
  import { readFileSync as readFileSync2 } from "node:fs";
1990
- import { parse as parse3 } from "jsonc-parser";
868
+ import { parse as parse2 } from "jsonc-parser";
1991
869
  import fg2 from "fast-glob";
1992
870
 
1993
- // src/config-v2/constants.ts
871
+ // src/config/constants.ts
1994
872
  var CONFIGURATION_FILENAMES = [
1995
873
  "microfrontends.jsonc",
1996
874
  "microfrontends.json"
1997
875
  ];
1998
876
 
1999
- // src/config-v2/microfrontends/utils/find-default-package.ts
877
+ // src/config/microfrontends/utils/find-default-package.ts
2000
878
  var configCache2 = {};
2001
879
  function findDefaultMicrofrontendsPackages({
2002
880
  repositoryRoot,
@@ -2019,7 +897,7 @@ function findDefaultMicrofrontendsPackages({
2019
897
  microfrontendsJsonPath,
2020
898
  "utf-8"
2021
899
  );
2022
- const microfrontendsJson = parse3(microfrontendsJsonContent);
900
+ const microfrontendsJson = parse2(microfrontendsJsonContent);
2023
901
  if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
2024
902
  matchingPaths.push(microfrontendsJsonPath);
2025
903
  }
@@ -2036,7 +914,7 @@ ${matchingPaths.join("\n \u2022 ")}`
2036
914
  );
2037
915
  }
2038
916
  const [packageJsonPath] = matchingPaths;
2039
- return dirname3(packageJsonPath);
917
+ return dirname2(packageJsonPath);
2040
918
  } catch (error) {
2041
919
  return null;
2042
920
  }
@@ -2056,25 +934,25 @@ function findDefaultMicrofrontendsPackage(opts) {
2056
934
  return result;
2057
935
  }
2058
936
 
2059
- // src/config-v2/microfrontends/utils/is-monorepo.ts
2060
- import fs4 from "node:fs";
2061
- import path4 from "node:path";
937
+ // src/config/microfrontends/utils/is-monorepo.ts
938
+ import fs2 from "node:fs";
939
+ import path2 from "node:path";
2062
940
  function isMonorepo({
2063
941
  repositoryRoot
2064
942
  }) {
2065
943
  try {
2066
- if (fs4.existsSync(path4.join(repositoryRoot, "pnpm-workspace.yaml"))) {
944
+ if (fs2.existsSync(path2.join(repositoryRoot, "pnpm-workspace.yaml"))) {
2067
945
  return true;
2068
946
  }
2069
- if (fs4.existsSync(path4.join(repositoryRoot, "vlt-workspaces.json"))) {
947
+ if (fs2.existsSync(path2.join(repositoryRoot, "vlt-workspaces.json"))) {
2070
948
  return true;
2071
949
  }
2072
- const packageJsonPath = path4.join(repositoryRoot, "package.json");
2073
- if (!fs4.existsSync(packageJsonPath)) {
950
+ const packageJsonPath = path2.join(repositoryRoot, "package.json");
951
+ if (!fs2.existsSync(packageJsonPath)) {
2074
952
  return false;
2075
953
  }
2076
954
  const packageJson = JSON.parse(
2077
- fs4.readFileSync(packageJsonPath, "utf-8")
955
+ fs2.readFileSync(packageJsonPath, "utf-8")
2078
956
  );
2079
957
  return packageJson.workspaces !== void 0;
2080
958
  } catch (error) {
@@ -2083,43 +961,67 @@ function isMonorepo({
2083
961
  }
2084
962
  }
2085
963
 
2086
- // src/config-v2/microfrontends/utils/find-package-root.ts
2087
- import fs5 from "node:fs";
2088
- import path5 from "node:path";
964
+ // src/config/microfrontends/utils/find-package-root.ts
965
+ import fs3 from "node:fs";
966
+ import path3 from "node:path";
2089
967
  var PACKAGE_JSON = "package.json";
2090
968
  function findPackageRoot(startDir) {
2091
969
  let currentDir = startDir || process.cwd();
2092
- while (currentDir !== path5.parse(currentDir).root) {
2093
- const pkgJsonPath = path5.join(currentDir, PACKAGE_JSON);
2094
- if (fs5.existsSync(pkgJsonPath)) {
970
+ while (currentDir !== path3.parse(currentDir).root) {
971
+ const pkgJsonPath = path3.join(currentDir, PACKAGE_JSON);
972
+ if (fs3.existsSync(pkgJsonPath)) {
2095
973
  return currentDir;
2096
974
  }
2097
- currentDir = path5.dirname(currentDir);
975
+ currentDir = path3.dirname(currentDir);
2098
976
  }
2099
977
  throw new Error(
2100
978
  "Package root not found. Specify the root of the package with the `package.root` option."
2101
979
  );
2102
980
  }
2103
981
 
2104
- // src/config-v2/microfrontends/utils/find-config.ts
2105
- import fs6 from "node:fs";
982
+ // src/config/microfrontends/utils/find-config.ts
983
+ import fs4 from "node:fs";
2106
984
  import { join } from "node:path";
2107
985
  function findConfig({ dir }) {
2108
986
  for (const filename of CONFIGURATION_FILENAMES) {
2109
987
  const maybeConfig = join(dir, filename);
2110
- if (fs6.existsSync(maybeConfig)) {
988
+ if (fs4.existsSync(maybeConfig)) {
2111
989
  return maybeConfig;
2112
990
  }
2113
991
  }
2114
992
  return null;
2115
993
  }
2116
994
 
2117
- // src/config-v2/microfrontends/server/validation.ts
2118
- import { parse as parse4 } from "jsonc-parser";
2119
- import { Ajv as Ajv2 } from "ajv";
995
+ // src/config/microfrontends/server/utils/get-output-file-path.ts
996
+ import path4 from "node:path";
997
+
998
+ // src/config/microfrontends/server/constants.ts
999
+ var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
1000
+ var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
1001
+
1002
+ // src/utils/is-vercel.ts
1003
+ function isVercel() {
1004
+ return process.env.VERCEL === "1";
1005
+ }
1006
+
1007
+ // src/config/microfrontends/server/utils/get-output-file-path.ts
1008
+ function getOutputFilePath() {
1009
+ if (isVercel()) {
1010
+ return path4.join(
1011
+ ".vercel",
1012
+ MFE_CONFIG_DEFAULT_FILE_PATH,
1013
+ MFE_CONFIG_DEFAULT_FILE_NAME
1014
+ );
1015
+ }
1016
+ return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
1017
+ }
1018
+
1019
+ // src/config/microfrontends/server/validation.ts
1020
+ import { parse as parse3 } from "jsonc-parser";
1021
+ import { Ajv } from "ajv";
2120
1022
 
2121
- // schema/schema-v2.json
2122
- var schema_v2_default = {
1023
+ // schema/schema.json
1024
+ var schema_default = {
2123
1025
  $schema: "http://json-schema.org/draft-07/schema#",
2124
1026
  $ref: "#/definitions/Config",
2125
1027
  definitions: {
@@ -2158,7 +1060,8 @@ var schema_v2_default = {
2158
1060
  description: "Mapping of application names to the routes that they host. Only needs to be defined in the application that owns the primary microfrontend domain"
2159
1061
  }
2160
1062
  },
2161
- required: ["applications", "version"]
1063
+ required: ["applications", "version"],
1064
+ additionalProperties: false
2162
1065
  },
2163
1066
  Options: {
2164
1067
  type: "object",
@@ -2171,7 +1074,8 @@ var schema_v2_default = {
2171
1074
  $ref: "#/definitions/LocalProxyOptions",
2172
1075
  description: "Options for local proxy."
2173
1076
  }
2174
- }
1077
+ },
1078
+ additionalProperties: false
2175
1079
  },
2176
1080
  VercelOptions: {
2177
1081
  type: "object",
@@ -2184,7 +1088,8 @@ var schema_v2_default = {
2184
1088
  type: "boolean",
2185
1089
  description: "If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect."
2186
1090
  }
2187
- }
1091
+ },
1092
+ additionalProperties: false
2188
1093
  },
2189
1094
  LocalProxyOptions: {
2190
1095
  type: "object",
@@ -2193,7 +1098,8 @@ var schema_v2_default = {
2193
1098
  type: "number",
2194
1099
  description: "The port number used by the local proxy server.\n\nThe default is `3024`."
2195
1100
  }
2196
- }
1101
+ },
1102
+ additionalProperties: false
2197
1103
  },
2198
1104
  Application: {
2199
1105
  anyOf: [
@@ -2218,7 +1124,8 @@ var schema_v2_default = {
2218
1124
  $ref: "#/definitions/HostConfig"
2219
1125
  }
2220
1126
  },
2221
- required: ["production"]
1127
+ required: ["production"],
1128
+ additionalProperties: false
2222
1129
  },
2223
1130
  Vercel: {
2224
1131
  type: "object",
@@ -2228,7 +1135,8 @@ var schema_v2_default = {
2228
1135
  description: "Vercel project ID"
2229
1136
  }
2230
1137
  },
2231
- required: ["projectId"]
1138
+ required: ["projectId"],
1139
+ additionalProperties: false
2232
1140
  },
2233
1141
  Development: {
2234
1142
  type: "object",
@@ -2244,10 +1152,12 @@ var schema_v2_default = {
2244
1152
  type: "string",
2245
1153
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
2246
1154
  }
2247
- }
1155
+ },
1156
+ additionalProperties: false
2248
1157
  },
2249
1158
  LocalHostConfig: {
2250
1159
  type: "object",
1160
+ additionalProperties: false,
2251
1161
  properties: {
2252
1162
  host: {
2253
1163
  type: "string",
@@ -2281,7 +1191,8 @@ var schema_v2_default = {
2281
1191
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
2282
1192
  }
2283
1193
  },
2284
- required: ["host"]
1194
+ required: ["host"],
1195
+ additionalProperties: false
2285
1196
  },
2286
1197
  ChildApplication: {
2287
1198
  type: "object",
@@ -2300,7 +1211,8 @@ var schema_v2_default = {
2300
1211
  $ref: "#/definitions/HostConfig"
2301
1212
  }
2302
1213
  },
2303
- required: ["routing"]
1214
+ required: ["routing"],
1215
+ additionalProperties: false
2304
1216
  },
2305
1217
  Routing: {
2306
1218
  type: "array",
@@ -2326,7 +1238,8 @@ var schema_v2_default = {
2326
1238
  }
2327
1239
  }
2328
1240
  },
2329
- required: ["paths"]
1241
+ required: ["paths"],
1242
+ additionalProperties: false
2330
1243
  },
2331
1244
  ApplicationRouting: {
2332
1245
  type: "object",
@@ -2359,19 +1272,20 @@ var schema_v2_default = {
2359
1272
  description: "Applications that only serve a subset of the microfrontend routes only need to reference the name of the primary application that owns the full microfrontends configuration."
2360
1273
  }
2361
1274
  },
2362
- required: ["partOf", "version"]
1275
+ required: ["partOf", "version"],
1276
+ additionalProperties: false
2363
1277
  }
2364
1278
  }
2365
1279
  };
2366
1280
 
2367
- // src/config-v2/schema/utils/load.ts
2368
- var SCHEMA2 = schema_v2_default;
1281
+ // src/config/schema/utils/load.ts
1282
+ var SCHEMA = schema_default;
2369
1283
 
2370
- // src/config-v2/microfrontends/server/validation.ts
2371
- function validateSchema2(configString) {
2372
- const parsedConfig = parse4(configString);
2373
- const ajv = new Ajv2();
2374
- const validate = ajv.compile(SCHEMA2);
1284
+ // src/config/microfrontends/server/validation.ts
1285
+ function validateSchema(configString) {
1286
+ const parsedConfig = parse3(configString);
1287
+ const ajv = new Ajv();
1288
+ const validate = ajv.compile(SCHEMA);
2375
1289
  const isValid = validate(parsedConfig);
2376
1290
  if (!isValid) {
2377
1291
  throw new MicrofrontendError(
@@ -2382,7 +1296,7 @@ function validateSchema2(configString) {
2382
1296
  return parsedConfig;
2383
1297
  }
2384
1298
 
2385
- // src/config-v2/microfrontends/server/index.ts
1299
+ // src/config/microfrontends/server/index.ts
2386
1300
  var MicrofrontendsServer = class extends Microfrontends {
2387
1301
  /**
2388
1302
  * Writes the configuration to a file.
@@ -2391,8 +1305,8 @@ var MicrofrontendsServer = class extends Microfrontends {
2391
1305
  pretty: true
2392
1306
  }) {
2393
1307
  const outputPath = getOutputFilePath();
2394
- fs7.mkdirSync(dirname4(outputPath), { recursive: true });
2395
- fs7.writeFileSync(
1308
+ fs5.mkdirSync(dirname3(outputPath), { recursive: true });
1309
+ fs5.writeFileSync(
2396
1310
  outputPath,
2397
1311
  JSON.stringify(
2398
1312
  this.config.toSchemaJson(),
@@ -2425,7 +1339,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2425
1339
  meta
2426
1340
  });
2427
1341
  }
2428
- throw new MicrofrontendError2(
1342
+ throw new MicrofrontendError(
2429
1343
  "Invalid config: must be a string or an object",
2430
1344
  { type: "config", subtype: "does_not_match_schema" }
2431
1345
  );
@@ -2449,7 +1363,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2449
1363
  */
2450
1364
  static validate(config) {
2451
1365
  if (typeof config === "string") {
2452
- const c = validateSchema2(config);
1366
+ const c = validateSchema(config);
2453
1367
  return c;
2454
1368
  }
2455
1369
  return config;
@@ -2480,7 +1394,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2480
1394
  const packageRoot = findPackageRoot(directory);
2481
1395
  const packageJsonPath = join2(packageRoot, "package.json");
2482
1396
  const packageJson = JSON.parse(
2483
- fs7.readFileSync(packageJsonPath, "utf-8")
1397
+ fs5.readFileSync(packageJsonPath, "utf-8")
2484
1398
  );
2485
1399
  if (!packageJson.name) {
2486
1400
  throw new Error(`No name found in package.json at ${packageJsonPath}`);
@@ -2514,7 +1428,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2514
1428
  }
2515
1429
  throw new Error("Unable to infer");
2516
1430
  } catch (e) {
2517
- throw new MicrofrontendError2(
1431
+ throw new MicrofrontendError(
2518
1432
  "Unable to infer microfrontends configuration",
2519
1433
  { type: "config", subtype: "inference_failed" }
2520
1434
  );
@@ -2530,7 +1444,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2530
1444
  options
2531
1445
  }) {
2532
1446
  try {
2533
- const configJson = fs7.readFileSync(filePath, "utf-8");
1447
+ const configJson = fs5.readFileSync(filePath, "utf-8");
2534
1448
  const config = MicrofrontendsServer.validate(configJson);
2535
1449
  if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
2536
1450
  const repositoryRoot = findRepositoryRoot();
@@ -2541,14 +1455,14 @@ var MicrofrontendsServer = class extends Microfrontends {
2541
1455
  name: config.partOf
2542
1456
  });
2543
1457
  if (!packagePath) {
2544
- throw new MicrofrontendError2(
1458
+ throw new MicrofrontendError(
2545
1459
  `Could not find default application "${config.partOf}" in the repository`,
2546
1460
  { type: "config", subtype: "not_found" }
2547
1461
  );
2548
1462
  }
2549
1463
  const maybeConfig = findConfig({ dir: packagePath });
2550
1464
  if (!maybeConfig) {
2551
- throw new MicrofrontendError2(
1465
+ throw new MicrofrontendError(
2552
1466
  `Could not find microfrontends configuration in ${packagePath}`,
2553
1467
  { type: "config", subtype: "not_found" }
2554
1468
  );
@@ -2565,7 +1479,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2565
1479
  meta
2566
1480
  });
2567
1481
  } catch (e) {
2568
- throw MicrofrontendError2.handle(e, {
1482
+ throw MicrofrontendError.handle(e, {
2569
1483
  fileName: filePath
2570
1484
  });
2571
1485
  }
@@ -2578,10 +1492,10 @@ var MicrofrontendsServer = class extends Microfrontends {
2578
1492
  overrides
2579
1493
  }) {
2580
1494
  try {
2581
- const config = fs7.readFileSync(filePath, "utf-8");
1495
+ const config = fs5.readFileSync(filePath, "utf-8");
2582
1496
  const validatedConfig = MicrofrontendsServer.validate(config);
2583
1497
  if (!isMainConfig(validatedConfig)) {
2584
- throw new MicrofrontendError2(
1498
+ throw new MicrofrontendError(
2585
1499
  `${filePath} is not a main microfrontend config`,
2586
1500
  {
2587
1501
  type: "config",
@@ -2591,7 +1505,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2591
1505
  }
2592
1506
  const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
2593
1507
  if (!defaultApplication) {
2594
- throw new MicrofrontendError2(
1508
+ throw new MicrofrontendError(
2595
1509
  `No default application found. At least one application needs to be the default by omitting routing.`,
2596
1510
  { type: "config", subtype: "no_default_application" }
2597
1511
  );
@@ -2602,7 +1516,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2602
1516
  meta: { fromApp: defaultApplication }
2603
1517
  });
2604
1518
  } catch (e) {
2605
- throw MicrofrontendError2.handle(e, {
1519
+ throw MicrofrontendError.handle(e, {
2606
1520
  fileName: filePath
2607
1521
  });
2608
1522
  }
@@ -2612,9 +1526,9 @@ var MicrofrontendsServer = class extends Microfrontends {
2612
1526
  // src/utils/mfe-port.ts
2613
1527
  function mfePort(packageDir) {
2614
1528
  const { name: appName, version } = getPackageJson(packageDir);
2615
- const result = loadV2({ packageDir, appName }) || loadV1({ packageDir, appName });
1529
+ const result = loadConfig({ packageDir, appName });
2616
1530
  if (!result) {
2617
- throw new MicrofrontendError2(
1531
+ throw new MicrofrontendError(
2618
1532
  `Unable to determine configured port for ${appName}`,
2619
1533
  { type: "config", subtype: "not_found" }
2620
1534
  );
@@ -2627,10 +1541,10 @@ function mfePort(packageDir) {
2627
1541
  };
2628
1542
  }
2629
1543
  function getPackageJson(packageDir) {
2630
- const filePath = path6.join(packageDir, "package.json");
2631
- return JSON.parse(fs8.readFileSync(filePath, "utf-8"));
1544
+ const filePath = path5.join(packageDir, "package.json");
1545
+ return JSON.parse(fs6.readFileSync(filePath, "utf-8"));
2632
1546
  }
2633
- function loadV2({
1547
+ function loadConfig({
2634
1548
  packageDir,
2635
1549
  appName
2636
1550
  }) {
@@ -2648,21 +1562,6 @@ function loadV2({
2648
1562
  const port = app.development.local.port;
2649
1563
  return { port };
2650
1564
  }
2651
- function loadV1({
2652
- packageDir,
2653
- appName
2654
- }) {
2655
- const filePath = path6.join(packageDir, "micro-frontends.jsonc");
2656
- let config;
2657
- try {
2658
- config = MicrofrontendConfig.fromFile({ filePath });
2659
- } catch (e) {
2660
- return void 0;
2661
- }
2662
- const zone = config.getZone(appName);
2663
- const port = zone.development.local.port;
2664
- return { port };
2665
- }
2666
1565
  export {
2667
1566
  mfePort
2668
1567
  };