@vercel/microfrontends 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +3 -3
  2. package/dist/bin/cli.cjs +403 -1627
  3. package/dist/config.cjs +460 -1004
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +4 -25
  6. package/dist/config.js +456 -983
  7. package/dist/config.js.map +1 -1
  8. package/dist/{index-83133f2d.d.ts → index-bf67a461.d.ts} +3 -10
  9. package/dist/{v2/microfrontends → microfrontends}/server.cjs +128 -194
  10. package/dist/microfrontends/server.cjs.map +1 -0
  11. package/dist/{v2/microfrontends → microfrontends}/server.d.ts +6 -5
  12. package/dist/{v2/microfrontends → microfrontends}/server.js +125 -191
  13. package/dist/microfrontends/server.js.map +1 -0
  14. package/dist/{v2/microfrontends.cjs → microfrontends.cjs} +21 -35
  15. package/dist/microfrontends.cjs.map +1 -0
  16. package/dist/{v2/microfrontends.d.ts → microfrontends.d.ts} +4 -3
  17. package/dist/{v2/microfrontends.js → microfrontends.js} +20 -34
  18. package/dist/microfrontends.js.map +1 -0
  19. package/dist/next/client.cjs +1 -1
  20. package/dist/next/client.cjs.map +1 -1
  21. package/dist/next/client.js +1 -1
  22. package/dist/next/client.js.map +1 -1
  23. package/dist/next/config.cjs +1323 -1024
  24. package/dist/next/config.cjs.map +1 -1
  25. package/dist/next/config.d.ts +1 -1
  26. package/dist/next/config.js +1327 -1028
  27. package/dist/next/config.js.map +1 -1
  28. package/dist/next/endpoints.cjs +77 -18
  29. package/dist/next/endpoints.cjs.map +1 -1
  30. package/dist/next/endpoints.d.ts +14 -3
  31. package/dist/next/endpoints.js +77 -18
  32. package/dist/next/endpoints.js.map +1 -1
  33. package/dist/next/middleware.cjs +745 -425
  34. package/dist/next/middleware.cjs.map +1 -1
  35. package/dist/next/middleware.d.ts +10 -5
  36. package/dist/next/middleware.js +745 -425
  37. package/dist/next/middleware.js.map +1 -1
  38. package/dist/next/testing.cjs +595 -1032
  39. package/dist/next/testing.cjs.map +1 -1
  40. package/dist/next/testing.d.ts +14 -12
  41. package/dist/next/testing.js +589 -1016
  42. package/dist/next/testing.js.map +1 -1
  43. package/dist/overrides.cjs +40 -108
  44. package/dist/overrides.cjs.map +1 -1
  45. package/dist/overrides.d.ts +24 -2
  46. package/dist/overrides.js +36 -106
  47. package/dist/overrides.js.map +1 -1
  48. package/dist/routing.cjs +19 -0
  49. package/dist/routing.cjs.map +1 -0
  50. package/dist/routing.d.ts +26 -0
  51. package/dist/routing.js +1 -0
  52. package/dist/{v2/schema.cjs → schema.cjs} +1 -1
  53. package/dist/schema.cjs.map +1 -0
  54. package/dist/schema.d.ts +1 -0
  55. package/dist/schema.js.map +1 -0
  56. package/dist/{types-a995174e.d.ts → types-a29d224a.d.ts} +1 -7
  57. package/dist/{types-15b7f215.d.ts → types-cfe3308b.d.ts} +1 -1
  58. package/dist/types-fc30696d.d.ts +11 -0
  59. package/dist/utils/mfe-port.cjs +254 -1362
  60. package/dist/utils/mfe-port.cjs.map +1 -1
  61. package/dist/utils/mfe-port.js +250 -1358
  62. package/dist/utils/mfe-port.js.map +1 -1
  63. package/dist/validation.cjs +31 -365
  64. package/dist/validation.cjs.map +1 -1
  65. package/dist/validation.d.ts +3 -152
  66. package/dist/validation.js +30 -363
  67. package/dist/validation.js.map +1 -1
  68. package/package.json +32 -80
  69. package/schema/schema.json +174 -244
  70. package/dist/config/client.cjs +0 -54
  71. package/dist/config/client.cjs.map +0 -1
  72. package/dist/config/client.d.ts +0 -23
  73. package/dist/config/client.js +0 -28
  74. package/dist/config/client.js.map +0 -1
  75. package/dist/config/edge.cjs +0 -508
  76. package/dist/config/edge.cjs.map +0 -1
  77. package/dist/config/edge.d.ts +0 -20
  78. package/dist/config/edge.js +0 -481
  79. package/dist/config/edge.js.map +0 -1
  80. package/dist/microfrontend-config-983a5139.d.ts +0 -154
  81. package/dist/schema-2922d49e.d.ts +0 -182
  82. package/dist/v2/config.cjs +0 -723
  83. package/dist/v2/config.cjs.map +0 -1
  84. package/dist/v2/config.d.ts +0 -3
  85. package/dist/v2/config.js +0 -698
  86. package/dist/v2/config.js.map +0 -1
  87. package/dist/v2/microfrontends/server.cjs.map +0 -1
  88. package/dist/v2/microfrontends/server.js.map +0 -1
  89. package/dist/v2/microfrontends.cjs.map +0 -1
  90. package/dist/v2/microfrontends.js.map +0 -1
  91. package/dist/v2/next/client.cjs +0 -3
  92. package/dist/v2/next/client.cjs.map +0 -1
  93. package/dist/v2/next/client.d.ts +0 -45
  94. package/dist/v2/next/client.js +0 -3
  95. package/dist/v2/next/client.js.map +0 -1
  96. package/dist/v2/next/config.cjs +0 -2132
  97. package/dist/v2/next/config.cjs.map +0 -1
  98. package/dist/v2/next/config.d.ts +0 -22
  99. package/dist/v2/next/config.js +0 -2097
  100. package/dist/v2/next/config.js.map +0 -1
  101. package/dist/v2/next/endpoints.cjs +0 -141
  102. package/dist/v2/next/endpoints.cjs.map +0 -1
  103. package/dist/v2/next/endpoints.d.ts +0 -15
  104. package/dist/v2/next/endpoints.js +0 -116
  105. package/dist/v2/next/endpoints.js.map +0 -1
  106. package/dist/v2/next/middleware.cjs +0 -1143
  107. package/dist/v2/next/middleware.cjs.map +0 -1
  108. package/dist/v2/next/middleware.d.ts +0 -29
  109. package/dist/v2/next/middleware.js +0 -1115
  110. package/dist/v2/next/middleware.js.map +0 -1
  111. package/dist/v2/overrides.cjs +0 -75
  112. package/dist/v2/overrides.cjs.map +0 -1
  113. package/dist/v2/overrides.d.ts +0 -24
  114. package/dist/v2/overrides.js +0 -45
  115. package/dist/v2/overrides.js.map +0 -1
  116. package/dist/v2/schema.cjs.map +0 -1
  117. package/dist/v2/schema.d.ts +0 -1
  118. package/schema/schema-v2.json +0 -270
  119. /package/dist/{v2/schema.js.map → routing.js.map} +0 -0
  120. /package/dist/{v2/schema.js → schema.js} +0 -0
@@ -1,4 +1,4 @@
1
- // src/config-v2/microfrontends/server/validation.ts
1
+ // src/config/microfrontends/server/validation.ts
2
2
  import { parse } from "jsonc-parser";
3
3
  import { Ajv } from "ajv";
4
4
 
@@ -94,8 +94,8 @@ var MicrofrontendError = class extends Error {
94
94
  }
95
95
  };
96
96
 
97
- // schema/schema-v2.json
98
- var schema_v2_default = {
97
+ // schema/schema.json
98
+ var schema_default = {
99
99
  $schema: "http://json-schema.org/draft-07/schema#",
100
100
  $ref: "#/definitions/Config",
101
101
  definitions: {
@@ -134,7 +134,8 @@ var schema_v2_default = {
134
134
  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"
135
135
  }
136
136
  },
137
- required: ["applications", "version"]
137
+ required: ["applications", "version"],
138
+ additionalProperties: false
138
139
  },
139
140
  Options: {
140
141
  type: "object",
@@ -147,15 +148,12 @@ var schema_v2_default = {
147
148
  $ref: "#/definitions/LocalProxyOptions",
148
149
  description: "Options for local proxy."
149
150
  }
150
- }
151
+ },
152
+ additionalProperties: false
151
153
  },
152
154
  VercelOptions: {
153
155
  type: "object",
154
156
  properties: {
155
- previewDeploymentSuffix: {
156
- type: "string",
157
- 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`."
158
- },
159
157
  teamSlug: {
160
158
  type: "string",
161
159
  description: "Team slug for the Vercel team"
@@ -164,7 +162,8 @@ var schema_v2_default = {
164
162
  type: "boolean",
165
163
  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."
166
164
  }
167
- }
165
+ },
166
+ additionalProperties: false
168
167
  },
169
168
  LocalProxyOptions: {
170
169
  type: "object",
@@ -173,7 +172,8 @@ var schema_v2_default = {
173
172
  type: "number",
174
173
  description: "The port number used by the local proxy server.\n\nThe default is `3024`."
175
174
  }
176
- }
175
+ },
176
+ additionalProperties: false
177
177
  },
178
178
  Application: {
179
179
  anyOf: [
@@ -198,7 +198,8 @@ var schema_v2_default = {
198
198
  $ref: "#/definitions/HostConfig"
199
199
  }
200
200
  },
201
- required: ["production"]
201
+ required: ["production"],
202
+ additionalProperties: false
202
203
  },
203
204
  Vercel: {
204
205
  type: "object",
@@ -208,7 +209,8 @@ var schema_v2_default = {
208
209
  description: "Vercel project ID"
209
210
  }
210
211
  },
211
- required: ["projectId"]
212
+ required: ["projectId"],
213
+ additionalProperties: false
212
214
  },
213
215
  Development: {
214
216
  type: "object",
@@ -224,10 +226,12 @@ var schema_v2_default = {
224
226
  type: "string",
225
227
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
226
228
  }
227
- }
229
+ },
230
+ additionalProperties: false
228
231
  },
229
232
  LocalHostConfig: {
230
233
  type: "object",
234
+ additionalProperties: false,
231
235
  properties: {
232
236
  host: {
233
237
  type: "string",
@@ -261,7 +265,8 @@ var schema_v2_default = {
261
265
  description: "The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS."
262
266
  }
263
267
  },
264
- required: ["host"]
268
+ required: ["host"],
269
+ additionalProperties: false
265
270
  },
266
271
  ChildApplication: {
267
272
  type: "object",
@@ -280,7 +285,8 @@ var schema_v2_default = {
280
285
  $ref: "#/definitions/HostConfig"
281
286
  }
282
287
  },
283
- required: ["routing"]
288
+ required: ["routing"],
289
+ additionalProperties: false
284
290
  },
285
291
  Routing: {
286
292
  type: "array",
@@ -306,7 +312,8 @@ var schema_v2_default = {
306
312
  }
307
313
  }
308
314
  },
309
- required: ["paths"]
315
+ required: ["paths"],
316
+ additionalProperties: false
310
317
  },
311
318
  ApplicationRouting: {
312
319
  type: "object",
@@ -339,15 +346,16 @@ var schema_v2_default = {
339
346
  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."
340
347
  }
341
348
  },
342
- required: ["partOf", "version"]
349
+ required: ["partOf", "version"],
350
+ additionalProperties: false
343
351
  }
344
352
  }
345
353
  };
346
354
 
347
- // src/config-v2/schema/utils/load.ts
348
- var SCHEMA = schema_v2_default;
355
+ // src/config/schema/utils/load.ts
356
+ var SCHEMA = schema_default;
349
357
 
350
- // src/config-v2/microfrontends/server/validation.ts
358
+ // src/config/microfrontends/server/validation.ts
351
359
  function validateSchema(configString) {
352
360
  const parsedConfig = parse(configString);
353
361
  const ajv = new Ajv();
@@ -361,348 +369,7 @@ function validateSchema(configString) {
361
369
  }
362
370
  return parsedConfig;
363
371
  }
364
-
365
- // src/config/validation.ts
366
- import { parse as parse2 } from "jsonc-parser";
367
- import { pathToRegexp, parse as parsePathRegexp } from "path-to-regexp";
368
- import { Ajv as Ajv2 } from "ajv";
369
-
370
- // schema/schema.json
371
- var schema_default = {
372
- $schema: "http://json-schema.org/draft-07/schema#",
373
- $ref: "#/definitions/Config",
374
- definitions: {
375
- Config: {
376
- type: "object",
377
- properties: {
378
- version: {
379
- type: "string"
380
- },
381
- $schema: {
382
- type: "string"
383
- },
384
- name: {
385
- type: "string",
386
- description: 'Name for the micro-frontend site (eg. "vercel.com", "vercel-site" etc.).'
387
- },
388
- applications: {
389
- $ref: "#/definitions/ApplicationConfigsById"
390
- },
391
- options: {
392
- $ref: "#/definitions/Options",
393
- description: "Optional configuration for the entire micro-frontends setup."
394
- }
395
- },
396
- required: ["version", "applications"],
397
- description: "Configuration for micro-frontend applications\n\nTODO: Add proxy configuration"
398
- },
399
- ApplicationConfigsById: {
400
- type: "object",
401
- additionalProperties: {
402
- $ref: "#/definitions/ApplicationConfig"
403
- }
404
- },
405
- ApplicationConfig: {
406
- anyOf: [
407
- {
408
- $ref: "#/definitions/DefaultApplicationConfig"
409
- },
410
- {
411
- $ref: "#/definitions/CommonApplicationConfig"
412
- }
413
- ],
414
- description: "A Micro-Frontend Deployment Target"
415
- },
416
- DefaultApplicationConfig: {
417
- type: "object",
418
- properties: {
419
- default: {
420
- type: "boolean",
421
- const: true,
422
- description: "The default application is used no other application is matched via the routing config"
423
- },
424
- routing: {
425
- $ref: "#/definitions/Routing"
426
- },
427
- development: {
428
- type: "object",
429
- properties: {
430
- local: {
431
- $ref: "#/definitions/HostConfig"
432
- },
433
- fallback: {
434
- $ref: "#/definitions/HostConfig",
435
- 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."
436
- },
437
- task: {
438
- type: "string",
439
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
440
- }
441
- },
442
- required: ["local"]
443
- },
444
- production: {
445
- $ref: "#/definitions/HostConfig"
446
- },
447
- metadata: {
448
- type: "object",
449
- additionalProperties: {
450
- type: "string"
451
- }
452
- },
453
- federation: {
454
- type: "object",
455
- properties: {
456
- exposes: {
457
- type: "array",
458
- items: {
459
- type: "object",
460
- properties: {
461
- name: {
462
- type: "string",
463
- description: "The name of the module - should be used when importing the module from another application"
464
- },
465
- path: {
466
- type: "string",
467
- description: "Relative path to the module within its `application`"
468
- }
469
- },
470
- required: ["name", "path"]
471
- },
472
- description: "Modules that are exposed by this application"
473
- },
474
- uses: {
475
- type: "array",
476
- items: {
477
- type: "string"
478
- },
479
- description: "Modules that are used by this application. Only the name of the module is required."
480
- }
481
- }
482
- },
483
- vercel: {
484
- $ref: "#/definitions/Vercel"
485
- }
486
- },
487
- required: ["default", "development", "production"]
488
- },
489
- Routing: {
490
- type: "object",
491
- properties: {
492
- assetPrefix: {
493
- type: "string",
494
- description: "[assetPrefix] for the application"
495
- },
496
- matches: {
497
- type: "array",
498
- items: {
499
- $ref: "#/definitions/PathGroup"
500
- },
501
- description: "Path expressions that are routed to this application."
502
- }
503
- },
504
- required: ["matches"]
505
- },
506
- PathGroup: {
507
- type: "object",
508
- properties: {
509
- group: {
510
- type: "string",
511
- description: "Optional group name for the paths"
512
- },
513
- options: {
514
- type: "object",
515
- properties: {
516
- flag: {
517
- type: "string",
518
- description: "flag name that can be used to enable/disable all paths in the group"
519
- }
520
- }
521
- },
522
- paths: {
523
- type: "array",
524
- items: {
525
- type: "string"
526
- }
527
- }
528
- },
529
- required: ["paths"]
530
- },
531
- HostConfig: {
532
- type: "object",
533
- properties: {
534
- protocol: {
535
- type: "string",
536
- enum: ["http", "https"],
537
- 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"'
538
- },
539
- host: {
540
- type: "string",
541
- 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`)."
542
- },
543
- port: {
544
- type: "number",
545
- 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"
546
- }
547
- },
548
- required: ["host"]
549
- },
550
- Vercel: {
551
- type: "object",
552
- properties: {
553
- projectId: {
554
- type: "string",
555
- description: "Vercel project ID"
556
- },
557
- projectName: {
558
- type: "string",
559
- description: "Vercel project name (temporary until we can use project ID)"
560
- },
561
- defaultRoute: {
562
- type: "string",
563
- description: "The default route for the application. Used to render screenshots, favicons, and provide direct zone links"
564
- },
565
- routeSpeedInsightsToDefaultZone: {
566
- type: "boolean",
567
- description: "Whether to route Speed Insights to the default zone or each individual microfrontend."
568
- }
569
- },
570
- required: ["projectId"]
571
- },
572
- CommonApplicationConfig: {
573
- type: "object",
574
- properties: {
575
- default: {
576
- type: "boolean",
577
- const: false,
578
- description: "The default application is used no other application is matched via the routing config"
579
- },
580
- routing: {
581
- $ref: "#/definitions/Routing"
582
- },
583
- development: {
584
- type: "object",
585
- properties: {
586
- local: {
587
- $ref: "#/definitions/HostConfig"
588
- },
589
- fallback: {
590
- $ref: "#/definitions/HostConfig",
591
- 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."
592
- },
593
- task: {
594
- type: "string",
595
- description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
596
- }
597
- },
598
- required: ["local"]
599
- },
600
- production: {
601
- $ref: "#/definitions/HostConfig"
602
- },
603
- metadata: {
604
- type: "object",
605
- additionalProperties: {
606
- type: "string"
607
- }
608
- },
609
- federation: {
610
- type: "object",
611
- properties: {
612
- exposes: {
613
- type: "array",
614
- items: {
615
- type: "object",
616
- properties: {
617
- name: {
618
- type: "string",
619
- description: "The name of the module - should be used when importing the module from another application"
620
- },
621
- path: {
622
- type: "string",
623
- description: "Relative path to the module within its `application`"
624
- }
625
- },
626
- required: ["name", "path"]
627
- },
628
- description: "Modules that are exposed by this application"
629
- },
630
- uses: {
631
- type: "array",
632
- items: {
633
- type: "string"
634
- },
635
- description: "Modules that are used by this application. Only the name of the module is required."
636
- }
637
- }
638
- },
639
- vercel: {
640
- $ref: "#/definitions/Vercel"
641
- }
642
- },
643
- required: ["default", "development", "production", "routing"]
644
- },
645
- Options: {
646
- type: "object",
647
- properties: {
648
- vercel: {
649
- $ref: "#/definitions/VercelOptions",
650
- description: "Micro-Frontends wide options for Vercel."
651
- },
652
- localProxy: {
653
- $ref: "#/definitions/LocalProxyOptions",
654
- description: "Options for local proxy."
655
- }
656
- }
657
- },
658
- VercelOptions: {
659
- type: "object",
660
- properties: {
661
- previewDeploymentSuffix: {
662
- type: "string",
663
- 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`."
664
- },
665
- teamSlug: {
666
- type: "string",
667
- description: "Team slug for the Vercel team"
668
- },
669
- disableOverrides: {
670
- type: "boolean",
671
- 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."
672
- }
673
- }
674
- },
675
- LocalProxyOptions: {
676
- type: "object",
677
- properties: {
678
- port: {
679
- type: "number",
680
- description: "The port number used by the local proxy server.\n\nThe default is `3024`."
681
- }
682
- }
683
- }
684
- }
685
- };
686
-
687
- // src/config/utils/load-schema.ts
688
- var SCHEMA2 = schema_default;
689
-
690
- // src/config/validation.ts
691
- var validateSchema2 = (configString) => {
692
- const parsedConfig = parse2(configString);
693
- const ajv = new Ajv2();
694
- const validate = ajv.compile(SCHEMA2);
695
- const isValid = validate(parsedConfig);
696
- if (!isValid) {
697
- throw new MicrofrontendError(
698
- `Invalid config: ${ajv.errorsText(validate.errors)}`,
699
- { type: "config", subtype: "does_not_match_schema" }
700
- );
701
- }
702
- return parsedConfig;
703
- };
704
372
  export {
705
- validateSchema2 as validateV1Schema,
706
- validateSchema as validateV2Schema
373
+ validateSchema
707
374
  };
708
375
  //# sourceMappingURL=validation.js.map