@vercel/microfrontends 0.14.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 (121) hide show
  1. package/dist/bin/cli.cjs +377 -1626
  2. package/dist/config.cjs +460 -1004
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +4 -25
  5. package/dist/config.js +456 -983
  6. package/dist/config.js.map +1 -1
  7. package/dist/{v2/microfrontends → microfrontends}/server.cjs +63 -143
  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 +63 -143
  11. package/dist/microfrontends/server.js.map +1 -0
  12. package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +21 -21
  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} +20 -20
  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 +1323 -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 +1327 -1028
  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 +745 -396
  32. package/dist/next/middleware.cjs.map +1 -1
  33. package/dist/next/middleware.d.ts +10 -5
  34. package/dist/next/middleware.js +745 -396
  35. package/dist/next/middleware.js.map +1 -1
  36. package/dist/next/testing.cjs +595 -1032
  37. package/dist/next/testing.cjs.map +1 -1
  38. package/dist/next/testing.d.ts +14 -12
  39. package/dist/next/testing.js +589 -1016
  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 +211 -1333
  52. package/dist/utils/mfe-port.cjs.map +1 -1
  53. package/dist/utils/mfe-port.js +204 -1326
  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,22 @@ 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);
250
+ for (const path6 of pathMatch.paths) {
251
+ const tokens = parsePathRegexp(path6);
1395
252
  for (const token of tokens.slice(0, -1)) {
1396
253
  if (typeof token !== "string") {
1397
254
  errors.push(
1398
- `Path ${path7} may only have a :wildcard in the last path component`
255
+ `Path ${path6} may only have a :wildcard in the last path component`
1399
256
  );
1400
257
  }
1401
258
  }
1402
- const existing = pathsByApplicationId.get(path7);
259
+ const existing = pathsByApplicationId.get(path6);
1403
260
  if (existing) {
1404
261
  existing.applications.push(id);
1405
262
  } else {
1406
- pathsByApplicationId.set(path7, {
263
+ pathsByApplicationId.set(path6, {
1407
264
  applications: [id],
1408
- matcher: pathToRegexp3(path7),
265
+ matcher: pathToRegexp2(path6),
1409
266
  applicationId: id
1410
267
  });
1411
268
  }
@@ -1413,10 +270,10 @@ var validateConfigPaths = (applicationConfigsById) => {
1413
270
  }
1414
271
  }
1415
272
  const entries = Array.from(pathsByApplicationId.entries());
1416
- entries.forEach(([path7, { applications: ids, matcher, applicationId }]) => {
273
+ entries.forEach(([path6, { applications: ids, matcher, applicationId }]) => {
1417
274
  if (ids.length > 1) {
1418
275
  errors.push(
1419
- `Duplicate path "${path7}" for applications "${ids.join(", ")}"`
276
+ `Duplicate path "${path6}" for applications "${ids.join(", ")}"`
1420
277
  );
1421
278
  }
1422
279
  entries.forEach(
@@ -1424,14 +281,14 @@ var validateConfigPaths = (applicationConfigsById) => {
1424
281
  matchPath,
1425
282
  { applications: matchIds, applicationId: matchApplicationId }
1426
283
  ]) => {
1427
- if (path7 === matchPath) {
284
+ if (path6 === matchPath) {
1428
285
  return;
1429
286
  }
1430
287
  if (applicationId === matchApplicationId) {
1431
288
  return;
1432
289
  }
1433
290
  if (matcher.test(matchPath)) {
1434
- const source = `"${path7}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
291
+ const source = `"${path6}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
1435
292
  const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
1436
293
  errors.push(
1437
294
  `Overlapping path detected between ${source} and ${destination}`
@@ -1441,7 +298,7 @@ var validateConfigPaths = (applicationConfigsById) => {
1441
298
  );
1442
299
  });
1443
300
  if (errors.length) {
1444
- throw new MicrofrontendError2(`Invalid paths: ${errors.join(", ")}`, {
301
+ throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
1445
302
  type: "config",
1446
303
  subtype: "conflicting_paths"
1447
304
  });
@@ -1454,13 +311,13 @@ var validateAppPaths = (name, app) => {
1454
311
  continue;
1455
312
  }
1456
313
  if (p.endsWith("/")) {
1457
- throw new MicrofrontendError2(
314
+ throw new MicrofrontendError(
1458
315
  `Invalid path for application "${name}". ${p} must not end with a slash.`,
1459
316
  { type: "application", subtype: "invalid_path" }
1460
317
  );
1461
318
  }
1462
319
  if (!p.startsWith("/")) {
1463
- throw new MicrofrontendError2(
320
+ throw new MicrofrontendError(
1464
321
  `Invalid path for application "${name}". ${p} must start with a slash.`,
1465
322
  { type: "application", subtype: "invalid_path" }
1466
323
  );
@@ -1482,20 +339,20 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
1482
339
  const numApplicationsWithRouting = applicationsWithRoutingNames.length;
1483
340
  const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
1484
341
  if (numApplicationsWithoutRouting === 0) {
1485
- throw new MicrofrontendError2(
342
+ throw new MicrofrontendError(
1486
343
  `No default application found. At least one application needs to be the default by omitting routing.`,
1487
344
  { type: "config", subtype: "no_default_application" }
1488
345
  );
1489
346
  }
1490
347
  if (numApplicationsWithoutRouting > 1) {
1491
- throw new MicrofrontendError2(
348
+ throw new MicrofrontendError(
1492
349
  `Only one application can omit "routing". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,
1493
350
  { type: "config", subtype: "multiple_default_applications" }
1494
351
  );
1495
352
  }
1496
353
  };
1497
354
 
1498
- // src/config-v2/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
355
+ // src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
1499
356
  var PREFIX = "vc-ap";
1500
357
  function generateAssetPrefixFromName({
1501
358
  name
@@ -1506,7 +363,7 @@ function generateAssetPrefixFromName({
1506
363
  return `${PREFIX}-${name}`;
1507
364
  }
1508
365
 
1509
- // src/config-v2/microfrontends-config/isomorphic/utils/generate-port.ts
366
+ // src/config/microfrontends-config/isomorphic/utils/generate-port.ts
1510
367
  function generatePortFromName({
1511
368
  name,
1512
369
  minPort = 3e3,
@@ -1526,13 +383,13 @@ function generatePortFromName({
1526
383
  return port;
1527
384
  }
1528
385
 
1529
- // src/config-v2/microfrontends-config/isomorphic/host.ts
1530
- var Host2 = class {
386
+ // src/config/microfrontends-config/isomorphic/host.ts
387
+ var Host = class {
1531
388
  constructor(hostConfig, options) {
1532
389
  const { protocol = "https", host, port } = hostConfig;
1533
390
  this.protocol = protocol;
1534
391
  this.host = host;
1535
- this.port = Host2.getPort({ port, protocol: this.protocol });
392
+ this.port = Host.getPort({ port, protocol: this.protocol });
1536
393
  this.local = options == null ? void 0 : options.isLocal;
1537
394
  }
1538
395
  isLocal() {
@@ -1551,7 +408,7 @@ var Host2 = class {
1551
408
  return port;
1552
409
  }
1553
410
  isDefaultPort() {
1554
- return this.port === Host2.getPort({ protocol: this.protocol });
411
+ return this.port === Host.getPort({ protocol: this.protocol });
1555
412
  }
1556
413
  toString(opts = {}) {
1557
414
  const url = this.toUrl(opts);
@@ -1563,7 +420,7 @@ var Host2 = class {
1563
420
  return new URL(url);
1564
421
  }
1565
422
  };
1566
- var LocalHost = class extends Host2 {
423
+ var LocalHost = class extends Host {
1567
424
  constructor({
1568
425
  appName,
1569
426
  ...hostConfig
@@ -1575,8 +432,8 @@ var LocalHost = class extends Host2 {
1575
432
  }
1576
433
  };
1577
434
 
1578
- // src/config-v2/microfrontends-config/isomorphic/application.ts
1579
- var Application2 = class {
435
+ // src/config/microfrontends-config/isomorphic/application.ts
436
+ var Application = class {
1580
437
  constructor(name, {
1581
438
  app,
1582
439
  overrides,
@@ -1589,12 +446,12 @@ var Application2 = class {
1589
446
  appName: name,
1590
447
  ...(_a = app.development) == null ? void 0 : _a.local
1591
448
  }),
1592
- fallback: ((_b = app.development) == null ? void 0 : _b.fallback) ? new Host2(app.development.fallback) : void 0
449
+ fallback: ((_b = app.development) == null ? void 0 : _b.fallback) ? new Host(app.development.fallback) : void 0
1593
450
  };
1594
- this.production = app.production ? new Host2(app.production) : void 0;
451
+ this.production = app.production ? new Host(app.production) : void 0;
1595
452
  this.vercel = app.vercel;
1596
453
  this.overrides = (overrides == null ? void 0 : overrides.environment) ? {
1597
- environment: new Host2(overrides.environment)
454
+ environment: new Host(overrides.environment)
1598
455
  } : void 0;
1599
456
  this.default = isDefault ?? false;
1600
457
  this.serialized = app;
@@ -1609,7 +466,7 @@ var Application2 = class {
1609
466
  return this.serialized;
1610
467
  }
1611
468
  };
1612
- var DefaultApplication = class extends Application2 {
469
+ var DefaultApplication = class extends Application {
1613
470
  constructor(name, {
1614
471
  app,
1615
472
  overrides
@@ -1620,13 +477,13 @@ var DefaultApplication = class extends Application2 {
1620
477
  isDefault: true
1621
478
  });
1622
479
  this.default = true;
1623
- this.production = new Host2(app.production);
480
+ this.production = new Host(app.production);
1624
481
  }
1625
482
  getAssetPrefix() {
1626
483
  return "";
1627
484
  }
1628
485
  };
1629
- var ChildApplication = class extends Application2 {
486
+ var ChildApplication = class extends Application {
1630
487
  constructor(name, {
1631
488
  app,
1632
489
  overrides
@@ -1645,10 +502,10 @@ var ChildApplication = class extends Application2 {
1645
502
  }
1646
503
  };
1647
504
 
1648
- // src/config-v2/microfrontends-config/isomorphic/constants.ts
1649
- var DEFAULT_LOCAL_PROXY_PORT2 = 3024;
505
+ // src/config/microfrontends-config/isomorphic/constants.ts
506
+ var DEFAULT_LOCAL_PROXY_PORT = 3024;
1650
507
 
1651
- // src/config-v2/microfrontends-config/isomorphic/index.ts
508
+ // src/config/microfrontends-config/isomorphic/index.ts
1652
509
  var MicrofrontendConfigIsomorphic = class {
1653
510
  constructor({
1654
511
  config,
@@ -1689,7 +546,7 @@ var MicrofrontendConfigIsomorphic = class {
1689
546
  );
1690
547
  }
1691
548
  if (isMainConfig(config) && !this.defaultApplication) {
1692
- throw new MicrofrontendError2(
549
+ throw new MicrofrontendError(
1693
550
  `Could not find default application in microfrontends configuration`,
1694
551
  {
1695
552
  type: "application",
@@ -1706,7 +563,7 @@ var MicrofrontendConfigIsomorphic = class {
1706
563
  };
1707
564
  }
1708
565
  static validate(config) {
1709
- const c = typeof config === "string" ? parse2(config) : config;
566
+ const c = typeof config === "string" ? parse(config) : config;
1710
567
  if (isMainConfig(c)) {
1711
568
  validateConfigVersion(c.version);
1712
569
  validateConfigPaths(c.applications);
@@ -1719,7 +576,7 @@ var MicrofrontendConfigIsomorphic = class {
1719
576
  cookies
1720
577
  }) {
1721
578
  return new MicrofrontendConfigIsomorphic({
1722
- config: parse2(getConfigStringFromEnv()),
579
+ config: parse(getConfigStringFromEnv()),
1723
580
  overrides: parseOverrides(cookies ?? []),
1724
581
  meta
1725
582
  });
@@ -1753,7 +610,7 @@ var MicrofrontendConfigIsomorphic = class {
1753
610
  }
1754
611
  const app = this.childApplications[name];
1755
612
  if (!app) {
1756
- throw new MicrofrontendError2(
613
+ throw new MicrofrontendError(
1757
614
  `Could not find microfrontends configuration for application "${name}"`,
1758
615
  {
1759
616
  type: "application",
@@ -1781,7 +638,7 @@ var MicrofrontendConfigIsomorphic = class {
1781
638
  */
1782
639
  getDefaultApplication() {
1783
640
  if (!this.defaultApplication) {
1784
- throw new MicrofrontendError2(
641
+ throw new MicrofrontendError(
1785
642
  `Could not find default application in microfrontends configuration`,
1786
643
  {
1787
644
  type: "application",
@@ -1796,7 +653,7 @@ var MicrofrontendConfigIsomorphic = class {
1796
653
  */
1797
654
  getLocalProxyPort() {
1798
655
  var _a, _b;
1799
- return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT2;
656
+ return ((_b = (_a = this.config.options) == null ? void 0 : _a.localProxy) == null ? void 0 : _b.port) ?? DEFAULT_LOCAL_PROXY_PORT;
1800
657
  }
1801
658
  /**
1802
659
  * Serializes the class back to the Schema type.
@@ -1830,7 +687,7 @@ var MicrofrontendConfigIsomorphic = class {
1830
687
  }
1831
688
  };
1832
689
 
1833
- // src/config-v2/microfrontends-config/isomorphic/child.ts
690
+ // src/config/microfrontends-config/isomorphic/child.ts
1834
691
  var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
1835
692
  constructor({
1836
693
  config,
@@ -1843,7 +700,7 @@ var MicrofrontendChildConfig = class extends MicrofrontendConfigIsomorphic {
1843
700
  }
1844
701
  };
1845
702
 
1846
- // src/config-v2/microfrontends-config/isomorphic/main.ts
703
+ // src/config/microfrontends-config/isomorphic/main.ts
1847
704
  var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1848
705
  constructor({
1849
706
  config,
@@ -1870,7 +727,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1870
727
  }
1871
728
  }
1872
729
  if (!defaultApplication) {
1873
- throw new MicrofrontendError2(
730
+ throw new MicrofrontendError(
1874
731
  `Could not find default application in microfrontends configuration`,
1875
732
  {
1876
733
  type: "application",
@@ -1882,7 +739,7 @@ var MicrofrontendMainConfig = class extends MicrofrontendConfigIsomorphic {
1882
739
  }
1883
740
  };
1884
741
 
1885
- // src/config-v2/microfrontends/isomorphic/index.ts
742
+ // src/config/microfrontends/isomorphic/index.ts
1886
743
  var Microfrontends = class {
1887
744
  constructor({
1888
745
  config,
@@ -1910,26 +767,26 @@ var Microfrontends = class {
1910
767
  }
1911
768
  };
1912
769
 
1913
- // src/config-v2/microfrontends/utils/find-repository-root.ts
1914
- import fs3 from "node:fs";
1915
- import path3 from "node:path";
770
+ // src/config/microfrontends/utils/find-repository-root.ts
771
+ import fs from "node:fs";
772
+ import path from "node:path";
1916
773
  var GIT_DIRECTORY = ".git";
1917
774
  function findRepositoryRoot(startDir) {
1918
775
  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()) {
776
+ while (currentDir !== path.parse(currentDir).root) {
777
+ const gitPath = path.join(currentDir, GIT_DIRECTORY);
778
+ if (fs.existsSync(gitPath) && fs.statSync(gitPath).isDirectory()) {
1922
779
  return currentDir;
1923
780
  }
1924
- currentDir = path3.dirname(currentDir);
781
+ currentDir = path.dirname(currentDir);
1925
782
  }
1926
783
  throw new Error(
1927
784
  "Repository root not found. Specify the root of the repository with the `repository.root` option."
1928
785
  );
1929
786
  }
1930
787
 
1931
- // src/config-v2/microfrontends/utils/find-package-path.ts
1932
- import { dirname as dirname2 } from "node:path";
788
+ // src/config/microfrontends/utils/find-package-path.ts
789
+ import { dirname } from "node:path";
1933
790
  import { readFileSync } from "node:fs";
1934
791
  import fg from "fast-glob";
1935
792
  var configCache = {};
@@ -1964,7 +821,7 @@ function findPackagePathWithGlob({
1964
821
  );
1965
822
  }
1966
823
  const [packageJsonPath] = matchingPaths;
1967
- return dirname2(packageJsonPath);
824
+ return dirname(packageJsonPath);
1968
825
  } catch (error) {
1969
826
  return null;
1970
827
  }
@@ -1984,19 +841,19 @@ function findPackagePath(opts) {
1984
841
  return result;
1985
842
  }
1986
843
 
1987
- // src/config-v2/microfrontends/utils/find-default-package.ts
1988
- import { dirname as dirname3 } from "node:path";
844
+ // src/config/microfrontends/utils/find-default-package.ts
845
+ import { dirname as dirname2 } from "node:path";
1989
846
  import { readFileSync as readFileSync2 } from "node:fs";
1990
- import { parse as parse3 } from "jsonc-parser";
847
+ import { parse as parse2 } from "jsonc-parser";
1991
848
  import fg2 from "fast-glob";
1992
849
 
1993
- // src/config-v2/constants.ts
850
+ // src/config/constants.ts
1994
851
  var CONFIGURATION_FILENAMES = [
1995
852
  "microfrontends.jsonc",
1996
853
  "microfrontends.json"
1997
854
  ];
1998
855
 
1999
- // src/config-v2/microfrontends/utils/find-default-package.ts
856
+ // src/config/microfrontends/utils/find-default-package.ts
2000
857
  var configCache2 = {};
2001
858
  function findDefaultMicrofrontendsPackages({
2002
859
  repositoryRoot,
@@ -2019,7 +876,7 @@ function findDefaultMicrofrontendsPackages({
2019
876
  microfrontendsJsonPath,
2020
877
  "utf-8"
2021
878
  );
2022
- const microfrontendsJson = parse3(microfrontendsJsonContent);
879
+ const microfrontendsJson = parse2(microfrontendsJsonContent);
2023
880
  if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
2024
881
  matchingPaths.push(microfrontendsJsonPath);
2025
882
  }
@@ -2036,7 +893,7 @@ ${matchingPaths.join("\n \u2022 ")}`
2036
893
  );
2037
894
  }
2038
895
  const [packageJsonPath] = matchingPaths;
2039
- return dirname3(packageJsonPath);
896
+ return dirname2(packageJsonPath);
2040
897
  } catch (error) {
2041
898
  return null;
2042
899
  }
@@ -2056,25 +913,25 @@ function findDefaultMicrofrontendsPackage(opts) {
2056
913
  return result;
2057
914
  }
2058
915
 
2059
- // src/config-v2/microfrontends/utils/is-monorepo.ts
2060
- import fs4 from "node:fs";
2061
- import path4 from "node:path";
916
+ // src/config/microfrontends/utils/is-monorepo.ts
917
+ import fs2 from "node:fs";
918
+ import path2 from "node:path";
2062
919
  function isMonorepo({
2063
920
  repositoryRoot
2064
921
  }) {
2065
922
  try {
2066
- if (fs4.existsSync(path4.join(repositoryRoot, "pnpm-workspace.yaml"))) {
923
+ if (fs2.existsSync(path2.join(repositoryRoot, "pnpm-workspace.yaml"))) {
2067
924
  return true;
2068
925
  }
2069
- if (fs4.existsSync(path4.join(repositoryRoot, "vlt-workspaces.json"))) {
926
+ if (fs2.existsSync(path2.join(repositoryRoot, "vlt-workspaces.json"))) {
2070
927
  return true;
2071
928
  }
2072
- const packageJsonPath = path4.join(repositoryRoot, "package.json");
2073
- if (!fs4.existsSync(packageJsonPath)) {
929
+ const packageJsonPath = path2.join(repositoryRoot, "package.json");
930
+ if (!fs2.existsSync(packageJsonPath)) {
2074
931
  return false;
2075
932
  }
2076
933
  const packageJson = JSON.parse(
2077
- fs4.readFileSync(packageJsonPath, "utf-8")
934
+ fs2.readFileSync(packageJsonPath, "utf-8")
2078
935
  );
2079
936
  return packageJson.workspaces !== void 0;
2080
937
  } catch (error) {
@@ -2083,43 +940,67 @@ function isMonorepo({
2083
940
  }
2084
941
  }
2085
942
 
2086
- // src/config-v2/microfrontends/utils/find-package-root.ts
2087
- import fs5 from "node:fs";
2088
- import path5 from "node:path";
943
+ // src/config/microfrontends/utils/find-package-root.ts
944
+ import fs3 from "node:fs";
945
+ import path3 from "node:path";
2089
946
  var PACKAGE_JSON = "package.json";
2090
947
  function findPackageRoot(startDir) {
2091
948
  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)) {
949
+ while (currentDir !== path3.parse(currentDir).root) {
950
+ const pkgJsonPath = path3.join(currentDir, PACKAGE_JSON);
951
+ if (fs3.existsSync(pkgJsonPath)) {
2095
952
  return currentDir;
2096
953
  }
2097
- currentDir = path5.dirname(currentDir);
954
+ currentDir = path3.dirname(currentDir);
2098
955
  }
2099
956
  throw new Error(
2100
957
  "Package root not found. Specify the root of the package with the `package.root` option."
2101
958
  );
2102
959
  }
2103
960
 
2104
- // src/config-v2/microfrontends/utils/find-config.ts
2105
- import fs6 from "node:fs";
961
+ // src/config/microfrontends/utils/find-config.ts
962
+ import fs4 from "node:fs";
2106
963
  import { join } from "node:path";
2107
964
  function findConfig({ dir }) {
2108
965
  for (const filename of CONFIGURATION_FILENAMES) {
2109
966
  const maybeConfig = join(dir, filename);
2110
- if (fs6.existsSync(maybeConfig)) {
967
+ if (fs4.existsSync(maybeConfig)) {
2111
968
  return maybeConfig;
2112
969
  }
2113
970
  }
2114
971
  return null;
2115
972
  }
2116
973
 
2117
- // src/config-v2/microfrontends/server/validation.ts
2118
- import { parse as parse4 } from "jsonc-parser";
2119
- import { Ajv as Ajv2 } from "ajv";
974
+ // src/config/microfrontends/server/utils/get-output-file-path.ts
975
+ import path4 from "node:path";
976
+
977
+ // src/config/microfrontends/server/constants.ts
978
+ var MFE_CONFIG_DEFAULT_FILE_PATH = "microfrontends";
979
+ var MFE_CONFIG_DEFAULT_FILE_NAME = "microfrontends.json";
980
+
981
+ // src/utils/is-vercel.ts
982
+ function isVercel() {
983
+ return process.env.VERCEL === "1";
984
+ }
985
+
986
+ // src/config/microfrontends/server/utils/get-output-file-path.ts
987
+ function getOutputFilePath() {
988
+ if (isVercel()) {
989
+ return path4.join(
990
+ ".vercel",
991
+ MFE_CONFIG_DEFAULT_FILE_PATH,
992
+ MFE_CONFIG_DEFAULT_FILE_NAME
993
+ );
994
+ }
995
+ return path4.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);
996
+ }
997
+
998
+ // src/config/microfrontends/server/validation.ts
999
+ import { parse as parse3 } from "jsonc-parser";
1000
+ import { Ajv } from "ajv";
2120
1001
 
2121
- // schema/schema-v2.json
2122
- var schema_v2_default = {
1002
+ // schema/schema.json
1003
+ var schema_default = {
2123
1004
  $schema: "http://json-schema.org/draft-07/schema#",
2124
1005
  $ref: "#/definitions/Config",
2125
1006
  definitions: {
@@ -2158,7 +1039,8 @@ var schema_v2_default = {
2158
1039
  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
1040
  }
2160
1041
  },
2161
- required: ["applications", "version"]
1042
+ required: ["applications", "version"],
1043
+ additionalProperties: false
2162
1044
  },
2163
1045
  Options: {
2164
1046
  type: "object",
@@ -2171,7 +1053,8 @@ var schema_v2_default = {
2171
1053
  $ref: "#/definitions/LocalProxyOptions",
2172
1054
  description: "Options for local proxy."
2173
1055
  }
2174
- }
1056
+ },
1057
+ additionalProperties: false
2175
1058
  },
2176
1059
  VercelOptions: {
2177
1060
  type: "object",
@@ -2184,7 +1067,8 @@ var schema_v2_default = {
2184
1067
  type: "boolean",
2185
1068
  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
1069
  }
2187
- }
1070
+ },
1071
+ additionalProperties: false
2188
1072
  },
2189
1073
  LocalProxyOptions: {
2190
1074
  type: "object",
@@ -2193,7 +1077,8 @@ var schema_v2_default = {
2193
1077
  type: "number",
2194
1078
  description: "The port number used by the local proxy server.\n\nThe default is `3024`."
2195
1079
  }
2196
- }
1080
+ },
1081
+ additionalProperties: false
2197
1082
  },
2198
1083
  Application: {
2199
1084
  anyOf: [
@@ -2218,7 +1103,8 @@ var schema_v2_default = {
2218
1103
  $ref: "#/definitions/HostConfig"
2219
1104
  }
2220
1105
  },
2221
- required: ["production"]
1106
+ required: ["production"],
1107
+ additionalProperties: false
2222
1108
  },
2223
1109
  Vercel: {
2224
1110
  type: "object",
@@ -2228,7 +1114,8 @@ var schema_v2_default = {
2228
1114
  description: "Vercel project ID"
2229
1115
  }
2230
1116
  },
2231
- required: ["projectId"]
1117
+ required: ["projectId"],
1118
+ additionalProperties: false
2232
1119
  },
2233
1120
  Development: {
2234
1121
  type: "object",
@@ -2244,10 +1131,12 @@ var schema_v2_default = {
2244
1131
  type: "string",
2245
1132
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
2246
1133
  }
2247
- }
1134
+ },
1135
+ additionalProperties: false
2248
1136
  },
2249
1137
  LocalHostConfig: {
2250
1138
  type: "object",
1139
+ additionalProperties: false,
2251
1140
  properties: {
2252
1141
  host: {
2253
1142
  type: "string",
@@ -2281,7 +1170,8 @@ var schema_v2_default = {
2281
1170
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
2282
1171
  }
2283
1172
  },
2284
- required: ["host"]
1173
+ required: ["host"],
1174
+ additionalProperties: false
2285
1175
  },
2286
1176
  ChildApplication: {
2287
1177
  type: "object",
@@ -2300,7 +1190,8 @@ var schema_v2_default = {
2300
1190
  $ref: "#/definitions/HostConfig"
2301
1191
  }
2302
1192
  },
2303
- required: ["routing"]
1193
+ required: ["routing"],
1194
+ additionalProperties: false
2304
1195
  },
2305
1196
  Routing: {
2306
1197
  type: "array",
@@ -2326,7 +1217,8 @@ var schema_v2_default = {
2326
1217
  }
2327
1218
  }
2328
1219
  },
2329
- required: ["paths"]
1220
+ required: ["paths"],
1221
+ additionalProperties: false
2330
1222
  },
2331
1223
  ApplicationRouting: {
2332
1224
  type: "object",
@@ -2359,19 +1251,20 @@ var schema_v2_default = {
2359
1251
  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
1252
  }
2361
1253
  },
2362
- required: ["partOf", "version"]
1254
+ required: ["partOf", "version"],
1255
+ additionalProperties: false
2363
1256
  }
2364
1257
  }
2365
1258
  };
2366
1259
 
2367
- // src/config-v2/schema/utils/load.ts
2368
- var SCHEMA2 = schema_v2_default;
1260
+ // src/config/schema/utils/load.ts
1261
+ var SCHEMA = schema_default;
2369
1262
 
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);
1263
+ // src/config/microfrontends/server/validation.ts
1264
+ function validateSchema(configString) {
1265
+ const parsedConfig = parse3(configString);
1266
+ const ajv = new Ajv();
1267
+ const validate = ajv.compile(SCHEMA);
2375
1268
  const isValid = validate(parsedConfig);
2376
1269
  if (!isValid) {
2377
1270
  throw new MicrofrontendError(
@@ -2382,7 +1275,7 @@ function validateSchema2(configString) {
2382
1275
  return parsedConfig;
2383
1276
  }
2384
1277
 
2385
- // src/config-v2/microfrontends/server/index.ts
1278
+ // src/config/microfrontends/server/index.ts
2386
1279
  var MicrofrontendsServer = class extends Microfrontends {
2387
1280
  /**
2388
1281
  * Writes the configuration to a file.
@@ -2391,8 +1284,8 @@ var MicrofrontendsServer = class extends Microfrontends {
2391
1284
  pretty: true
2392
1285
  }) {
2393
1286
  const outputPath = getOutputFilePath();
2394
- fs7.mkdirSync(dirname4(outputPath), { recursive: true });
2395
- fs7.writeFileSync(
1287
+ fs5.mkdirSync(dirname3(outputPath), { recursive: true });
1288
+ fs5.writeFileSync(
2396
1289
  outputPath,
2397
1290
  JSON.stringify(
2398
1291
  this.config.toSchemaJson(),
@@ -2425,7 +1318,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2425
1318
  meta
2426
1319
  });
2427
1320
  }
2428
- throw new MicrofrontendError2(
1321
+ throw new MicrofrontendError(
2429
1322
  "Invalid config: must be a string or an object",
2430
1323
  { type: "config", subtype: "does_not_match_schema" }
2431
1324
  );
@@ -2449,7 +1342,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2449
1342
  */
2450
1343
  static validate(config) {
2451
1344
  if (typeof config === "string") {
2452
- const c = validateSchema2(config);
1345
+ const c = validateSchema(config);
2453
1346
  return c;
2454
1347
  }
2455
1348
  return config;
@@ -2480,7 +1373,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2480
1373
  const packageRoot = findPackageRoot(directory);
2481
1374
  const packageJsonPath = join2(packageRoot, "package.json");
2482
1375
  const packageJson = JSON.parse(
2483
- fs7.readFileSync(packageJsonPath, "utf-8")
1376
+ fs5.readFileSync(packageJsonPath, "utf-8")
2484
1377
  );
2485
1378
  if (!packageJson.name) {
2486
1379
  throw new Error(`No name found in package.json at ${packageJsonPath}`);
@@ -2514,7 +1407,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2514
1407
  }
2515
1408
  throw new Error("Unable to infer");
2516
1409
  } catch (e) {
2517
- throw new MicrofrontendError2(
1410
+ throw new MicrofrontendError(
2518
1411
  "Unable to infer microfrontends configuration",
2519
1412
  { type: "config", subtype: "inference_failed" }
2520
1413
  );
@@ -2530,7 +1423,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2530
1423
  options
2531
1424
  }) {
2532
1425
  try {
2533
- const configJson = fs7.readFileSync(filePath, "utf-8");
1426
+ const configJson = fs5.readFileSync(filePath, "utf-8");
2534
1427
  const config = MicrofrontendsServer.validate(configJson);
2535
1428
  if (!isMainConfig(config) && (options == null ? void 0 : options.resolveMainConfig)) {
2536
1429
  const repositoryRoot = findRepositoryRoot();
@@ -2541,14 +1434,14 @@ var MicrofrontendsServer = class extends Microfrontends {
2541
1434
  name: config.partOf
2542
1435
  });
2543
1436
  if (!packagePath) {
2544
- throw new MicrofrontendError2(
1437
+ throw new MicrofrontendError(
2545
1438
  `Could not find default application "${config.partOf}" in the repository`,
2546
1439
  { type: "config", subtype: "not_found" }
2547
1440
  );
2548
1441
  }
2549
1442
  const maybeConfig = findConfig({ dir: packagePath });
2550
1443
  if (!maybeConfig) {
2551
- throw new MicrofrontendError2(
1444
+ throw new MicrofrontendError(
2552
1445
  `Could not find microfrontends configuration in ${packagePath}`,
2553
1446
  { type: "config", subtype: "not_found" }
2554
1447
  );
@@ -2565,7 +1458,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2565
1458
  meta
2566
1459
  });
2567
1460
  } catch (e) {
2568
- throw MicrofrontendError2.handle(e, {
1461
+ throw MicrofrontendError.handle(e, {
2569
1462
  fileName: filePath
2570
1463
  });
2571
1464
  }
@@ -2578,10 +1471,10 @@ var MicrofrontendsServer = class extends Microfrontends {
2578
1471
  overrides
2579
1472
  }) {
2580
1473
  try {
2581
- const config = fs7.readFileSync(filePath, "utf-8");
1474
+ const config = fs5.readFileSync(filePath, "utf-8");
2582
1475
  const validatedConfig = MicrofrontendsServer.validate(config);
2583
1476
  if (!isMainConfig(validatedConfig)) {
2584
- throw new MicrofrontendError2(
1477
+ throw new MicrofrontendError(
2585
1478
  `${filePath} is not a main microfrontend config`,
2586
1479
  {
2587
1480
  type: "config",
@@ -2591,7 +1484,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2591
1484
  }
2592
1485
  const [defaultApplication] = Object.entries(validatedConfig.applications).filter(([, app]) => isDefaultApp(app)).map(([name]) => name);
2593
1486
  if (!defaultApplication) {
2594
- throw new MicrofrontendError2(
1487
+ throw new MicrofrontendError(
2595
1488
  `No default application found. At least one application needs to be the default by omitting routing.`,
2596
1489
  { type: "config", subtype: "no_default_application" }
2597
1490
  );
@@ -2602,7 +1495,7 @@ var MicrofrontendsServer = class extends Microfrontends {
2602
1495
  meta: { fromApp: defaultApplication }
2603
1496
  });
2604
1497
  } catch (e) {
2605
- throw MicrofrontendError2.handle(e, {
1498
+ throw MicrofrontendError.handle(e, {
2606
1499
  fileName: filePath
2607
1500
  });
2608
1501
  }
@@ -2612,9 +1505,9 @@ var MicrofrontendsServer = class extends Microfrontends {
2612
1505
  // src/utils/mfe-port.ts
2613
1506
  function mfePort(packageDir) {
2614
1507
  const { name: appName, version } = getPackageJson(packageDir);
2615
- const result = loadV2({ packageDir, appName }) || loadV1({ packageDir, appName });
1508
+ const result = loadConfig({ packageDir, appName });
2616
1509
  if (!result) {
2617
- throw new MicrofrontendError2(
1510
+ throw new MicrofrontendError(
2618
1511
  `Unable to determine configured port for ${appName}`,
2619
1512
  { type: "config", subtype: "not_found" }
2620
1513
  );
@@ -2627,10 +1520,10 @@ function mfePort(packageDir) {
2627
1520
  };
2628
1521
  }
2629
1522
  function getPackageJson(packageDir) {
2630
- const filePath = path6.join(packageDir, "package.json");
2631
- return JSON.parse(fs8.readFileSync(filePath, "utf-8"));
1523
+ const filePath = path5.join(packageDir, "package.json");
1524
+ return JSON.parse(fs6.readFileSync(filePath, "utf-8"));
2632
1525
  }
2633
- function loadV2({
1526
+ function loadConfig({
2634
1527
  packageDir,
2635
1528
  appName
2636
1529
  }) {
@@ -2648,21 +1541,6 @@ function loadV2({
2648
1541
  const port = app.development.local.port;
2649
1542
  return { port };
2650
1543
  }
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
1544
  export {
2667
1545
  mfePort
2668
1546
  };