@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
@@ -270,16 +270,17 @@ var validateConfigPaths = (applicationConfigsById) => {
270
270
  const maybeError = validatePathExpression(path5);
271
271
  if (maybeError) {
272
272
  errors.push(maybeError);
273
- }
274
- const existing = pathsByApplicationId.get(path5);
275
- if (existing) {
276
- existing.applications.push(id);
277
273
  } else {
278
- pathsByApplicationId.set(path5, {
279
- applications: [id],
280
- matcher: (0, import_path_to_regexp2.pathToRegexp)(path5),
281
- applicationId: id
282
- });
274
+ const existing = pathsByApplicationId.get(path5);
275
+ if (existing) {
276
+ existing.applications.push(id);
277
+ } else {
278
+ pathsByApplicationId.set(path5, {
279
+ applications: [id],
280
+ matcher: (0, import_path_to_regexp2.pathToRegexp)(path5),
281
+ applicationId: id
282
+ });
283
+ }
283
284
  }
284
285
  }
285
286
  }
@@ -319,26 +320,38 @@ var validateConfigPaths = (applicationConfigsById) => {
319
320
  };
320
321
  var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
321
322
  function validatePathExpression(path5) {
322
- const tokens = (0, import_path_to_regexp2.parse)(path5);
323
- for (let i = 0; i < tokens.length; i++) {
324
- const token = tokens[i];
325
- if (token === void 0) {
326
- return `token ${i} in ${path5} is undefined, this shouldn't happen`;
327
- }
328
- if (typeof token !== "string") {
329
- if (token.pattern !== PATH_DEFAULT_PATTERN) {
330
- return `Path ${path5} cannot use a regular expression wildcard`;
331
- }
332
- if (token.prefix !== "/") {
333
- return `Wildcard :${token.name} must be immediately after a / in ${path5}`;
334
- }
335
- if (token.suffix) {
336
- return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;
323
+ try {
324
+ const tokens = (0, import_path_to_regexp2.parse)(path5);
325
+ if (/(?<!\\)\{/.test(path5)) {
326
+ return `Optional paths are not supported: ${path5}`;
327
+ }
328
+ if (/(?<!\\|\()\?/.test(path5)) {
329
+ return `Optional paths are not supported: ${path5}`;
330
+ }
331
+ if (/\/[^/]*(?<!\\):[^/]*(?<!\\):[^/]*/.test(path5)) {
332
+ return `Only one wildcard is allowed per path segment: ${path5}`;
333
+ }
334
+ for (let i = 0; i < tokens.length; i++) {
335
+ const token = tokens[i];
336
+ if (token === void 0) {
337
+ return `token ${i} in ${path5} is undefined, this shouldn't happen`;
337
338
  }
338
- if (token.modifier && i !== tokens.length - 1) {
339
- return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path5}. Modifiers are only allowed in the last path component`;
339
+ if (typeof token !== "string") {
340
+ if (token.pattern !== PATH_DEFAULT_PATTERN && // Allows (a|b|c) and ((?!a|b|c).*) regex
341
+ // Only limited regex is supported for now, due to performance considerations
342
+ !/^(?<allowed>[\w]+(?:\|[^|()]+)+)$|^\(\?!(?<disallowed>[\w]+(?:\|[^|()]+)+)\)\.\*$/.test(
343
+ token.pattern
344
+ )) {
345
+ return `Path ${path5} cannot use unsupported regular expression wildcard`;
346
+ }
347
+ if (token.modifier && i !== tokens.length - 1) {
348
+ return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path5}. Modifiers are only allowed in the last path component`;
349
+ }
340
350
  }
341
351
  }
352
+ } catch (e) {
353
+ const message = e instanceof Error ? e.message : String(e);
354
+ return `Path ${path5} could not be parsed into regexp: ${message}`;
342
355
  }
343
356
  return void 0;
344
357
  }
@@ -692,12 +705,8 @@ var MicrofrontendConfigIsomorphic = class {
692
705
  const skipValidation = opts?.skipValidation ?? [];
693
706
  const c = typeof config === "string" ? (0, import_jsonc_parser.parse)(config) : config;
694
707
  if (isMainConfig(c)) {
695
- if (!skipValidation.includes("paths")) {
696
- validateConfigPaths(c.applications);
697
- }
698
- if (!skipValidation.includes("defaultApplication")) {
699
- validateConfigDefaultApplication(c.applications);
700
- }
708
+ validateConfigPaths(c.applications);
709
+ validateConfigDefaultApplication(c.applications);
701
710
  if (!skipValidation.includes("deprecatedFields")) {
702
711
  validateDeprecatedFields(c);
703
712
  }