@vercel/microfrontends 1.0.1-canary.1 → 1.0.1-canary.3

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 (45) hide show
  1. package/dist/bin/cli.cjs +43 -33
  2. package/dist/config.cjs +41 -32
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +1 -1
  5. package/dist/config.js +41 -32
  6. package/dist/config.js.map +1 -1
  7. package/dist/experimental/sveltekit.cjs +41 -32
  8. package/dist/experimental/sveltekit.cjs.map +1 -1
  9. package/dist/experimental/sveltekit.js +41 -32
  10. package/dist/experimental/sveltekit.js.map +1 -1
  11. package/dist/experimental/vite.cjs +88 -46
  12. package/dist/experimental/vite.cjs.map +1 -1
  13. package/dist/experimental/vite.d.ts +1 -1
  14. package/dist/experimental/vite.js +88 -48
  15. package/dist/experimental/vite.js.map +1 -1
  16. package/dist/{index-d5994ac5.d.ts → index-2b59c627.d.ts} +1 -1
  17. package/dist/microfrontends/server.cjs +41 -32
  18. package/dist/microfrontends/server.cjs.map +1 -1
  19. package/dist/microfrontends/server.d.ts +1 -1
  20. package/dist/microfrontends/server.js +41 -32
  21. package/dist/microfrontends/server.js.map +1 -1
  22. package/dist/microfrontends.cjs +41 -32
  23. package/dist/microfrontends.cjs.map +1 -1
  24. package/dist/microfrontends.d.ts +1 -1
  25. package/dist/microfrontends.js +41 -32
  26. package/dist/microfrontends.js.map +1 -1
  27. package/dist/next/config.cjs +205 -131
  28. package/dist/next/config.cjs.map +1 -1
  29. package/dist/next/config.d.ts +7 -1
  30. package/dist/next/config.js +205 -131
  31. package/dist/next/config.js.map +1 -1
  32. package/dist/next/middleware.cjs +41 -32
  33. package/dist/next/middleware.cjs.map +1 -1
  34. package/dist/next/middleware.js +41 -32
  35. package/dist/next/middleware.js.map +1 -1
  36. package/dist/next/testing.cjs +41 -32
  37. package/dist/next/testing.cjs.map +1 -1
  38. package/dist/next/testing.d.ts +2 -2
  39. package/dist/next/testing.js +42 -33
  40. package/dist/next/testing.js.map +1 -1
  41. package/dist/utils/mfe-port.cjs +41 -32
  42. package/dist/utils/mfe-port.cjs.map +1 -1
  43. package/dist/utils/mfe-port.js +41 -32
  44. package/dist/utils/mfe-port.js.map +1 -1
  45. package/package.json +2 -1
@@ -240,16 +240,17 @@ var validateConfigPaths = (applicationConfigsById) => {
240
240
  const maybeError = validatePathExpression(path6);
241
241
  if (maybeError) {
242
242
  errors.push(maybeError);
243
- }
244
- const existing = pathsByApplicationId.get(path6);
245
- if (existing) {
246
- existing.applications.push(id);
247
243
  } else {
248
- pathsByApplicationId.set(path6, {
249
- applications: [id],
250
- matcher: pathToRegexp2(path6),
251
- applicationId: id
252
- });
244
+ const existing = pathsByApplicationId.get(path6);
245
+ if (existing) {
246
+ existing.applications.push(id);
247
+ } else {
248
+ pathsByApplicationId.set(path6, {
249
+ applications: [id],
250
+ matcher: pathToRegexp2(path6),
251
+ applicationId: id
252
+ });
253
+ }
253
254
  }
254
255
  }
255
256
  }
@@ -289,26 +290,38 @@ var validateConfigPaths = (applicationConfigsById) => {
289
290
  };
290
291
  var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
291
292
  function validatePathExpression(path6) {
292
- const tokens = parsePathRegexp(path6);
293
- for (let i = 0; i < tokens.length; i++) {
294
- const token = tokens[i];
295
- if (token === void 0) {
296
- return `token ${i} in ${path6} is undefined, this shouldn't happen`;
297
- }
298
- if (typeof token !== "string") {
299
- if (token.pattern !== PATH_DEFAULT_PATTERN) {
300
- return `Path ${path6} cannot use a regular expression wildcard`;
301
- }
302
- if (token.prefix !== "/") {
303
- return `Wildcard :${token.name} must be immediately after a / in ${path6}`;
304
- }
305
- if (token.suffix) {
306
- return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;
293
+ try {
294
+ const tokens = parsePathRegexp(path6);
295
+ if (/(?<!\\)\{/.test(path6)) {
296
+ return `Optional paths are not supported: ${path6}`;
297
+ }
298
+ if (/(?<!\\|\()\?/.test(path6)) {
299
+ return `Optional paths are not supported: ${path6}`;
300
+ }
301
+ if (/\/[^/]*(?<!\\):[^/]*(?<!\\):[^/]*/.test(path6)) {
302
+ return `Only one wildcard is allowed per path segment: ${path6}`;
303
+ }
304
+ for (let i = 0; i < tokens.length; i++) {
305
+ const token = tokens[i];
306
+ if (token === void 0) {
307
+ return `token ${i} in ${path6} is undefined, this shouldn't happen`;
307
308
  }
308
- if (token.modifier && i !== tokens.length - 1) {
309
- return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path6}. Modifiers are only allowed in the last path component`;
309
+ if (typeof token !== "string") {
310
+ if (token.pattern !== PATH_DEFAULT_PATTERN && // Allows (a|b|c) and ((?!a|b|c).*) regex
311
+ // Only limited regex is supported for now, due to performance considerations
312
+ !/^(?<allowed>[\w]+(?:\|[^|()]+)+)$|^\(\?!(?<disallowed>[\w]+(?:\|[^|()]+)+)\)\.\*$/.test(
313
+ token.pattern
314
+ )) {
315
+ return `Path ${path6} cannot use unsupported regular expression wildcard`;
316
+ }
317
+ if (token.modifier && i !== tokens.length - 1) {
318
+ return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path6}. Modifiers are only allowed in the last path component`;
319
+ }
310
320
  }
311
321
  }
322
+ } catch (e) {
323
+ const message = e instanceof Error ? e.message : String(e);
324
+ return `Path ${path6} could not be parsed into regexp: ${message}`;
312
325
  }
313
326
  return void 0;
314
327
  }
@@ -662,12 +675,8 @@ var MicrofrontendConfigIsomorphic = class {
662
675
  const skipValidation = opts?.skipValidation ?? [];
663
676
  const c = typeof config === "string" ? parse(config) : config;
664
677
  if (isMainConfig(c)) {
665
- if (!skipValidation.includes("paths")) {
666
- validateConfigPaths(c.applications);
667
- }
668
- if (!skipValidation.includes("defaultApplication")) {
669
- validateConfigDefaultApplication(c.applications);
670
- }
678
+ validateConfigPaths(c.applications);
679
+ validateConfigDefaultApplication(c.applications);
671
680
  if (!skipValidation.includes("deprecatedFields")) {
672
681
  validateDeprecatedFields(c);
673
682
  }