@vercel/microfrontends 1.2.0 → 1.2.1

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 (50) hide show
  1. package/dist/bin/cli.cjs +50 -17
  2. package/dist/config.cjs +3 -1
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.js +3 -1
  5. package/dist/config.js.map +1 -1
  6. package/dist/experimental/sveltekit.cjs +18 -14
  7. package/dist/experimental/sveltekit.cjs.map +1 -1
  8. package/dist/experimental/sveltekit.js +18 -14
  9. package/dist/experimental/sveltekit.js.map +1 -1
  10. package/dist/experimental/vite.cjs +18 -14
  11. package/dist/experimental/vite.cjs.map +1 -1
  12. package/dist/experimental/vite.d.ts +3 -2
  13. package/dist/experimental/vite.js +18 -14
  14. package/dist/experimental/vite.js.map +1 -1
  15. package/dist/microfrontends/server.cjs +18 -14
  16. package/dist/microfrontends/server.cjs.map +1 -1
  17. package/dist/microfrontends/server.js +18 -14
  18. package/dist/microfrontends/server.js.map +1 -1
  19. package/dist/microfrontends/utils.cjs +71 -2
  20. package/dist/microfrontends/utils.cjs.map +1 -1
  21. package/dist/microfrontends/utils.d.ts +11 -1
  22. package/dist/microfrontends/utils.js +69 -1
  23. package/dist/microfrontends/utils.js.map +1 -1
  24. package/dist/next/client.cjs +1 -1
  25. package/dist/next/client.cjs.map +1 -1
  26. package/dist/next/client.js +1 -1
  27. package/dist/next/client.js.map +1 -1
  28. package/dist/next/config.cjs +18 -14
  29. package/dist/next/config.cjs.map +1 -1
  30. package/dist/next/config.d.ts +16 -2
  31. package/dist/next/config.js +18 -14
  32. package/dist/next/config.js.map +1 -1
  33. package/dist/next/endpoints.cjs +3 -1
  34. package/dist/next/endpoints.cjs.map +1 -1
  35. package/dist/next/endpoints.js +3 -1
  36. package/dist/next/endpoints.js.map +1 -1
  37. package/dist/next/middleware.cjs +7 -3
  38. package/dist/next/middleware.cjs.map +1 -1
  39. package/dist/next/middleware.js +7 -3
  40. package/dist/next/middleware.js.map +1 -1
  41. package/dist/next/testing.cjs +3 -1
  42. package/dist/next/testing.cjs.map +1 -1
  43. package/dist/next/testing.d.ts +28 -0
  44. package/dist/next/testing.js +3 -1
  45. package/dist/next/testing.js.map +1 -1
  46. package/dist/utils/mfe-port.cjs +18 -14
  47. package/dist/utils/mfe-port.cjs.map +1 -1
  48. package/dist/utils/mfe-port.js +18 -14
  49. package/dist/utils/mfe-port.js.map +1 -1
  50. package/package.json +1 -1
@@ -212,11 +212,11 @@ function findRepositoryRoot(startDir) {
212
212
  currentDir = import_node_path.default.dirname(currentDir);
213
213
  }
214
214
  throw new Error(
215
- "Repository root not found. Specify the root of the repository with the `repository.root` option."
215
+ `Could not find the root of the repository for ${startDir}. Please ensure that the directory is part of a Git repository. If you suspect that this should work, please file an issue to the Vercel team.`
216
216
  );
217
217
  }
218
218
 
219
- // src/config/microfrontends/utils/find-default-package.ts
219
+ // src/config/microfrontends/utils/infer-microfrontends-location.ts
220
220
  var import_node_path2 = require("path");
221
221
  var import_node_fs2 = require("fs");
222
222
  var import_jsonc_parser = require("jsonc-parser");
@@ -228,9 +228,9 @@ var CONFIGURATION_FILENAMES = [
228
228
  "microfrontends.json"
229
229
  ];
230
230
 
231
- // src/config/microfrontends/utils/find-default-package.ts
231
+ // src/config/microfrontends/utils/infer-microfrontends-location.ts
232
232
  var configCache = {};
233
- function findDefaultMicrofrontendsPackages({
233
+ function findPackageWithMicrofrontendsConfig({
234
234
  repositoryRoot,
235
235
  applicationName
236
236
  }) {
@@ -261,13 +261,13 @@ function findDefaultMicrofrontendsPackages({
261
261
  }
262
262
  if (matchingPaths.length > 1) {
263
263
  throw new Error(
264
- `Found multiple default applications referencing "${applicationName}" in the repository, but only one is allowed.
264
+ `Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
265
265
  ${matchingPaths.join("\n \u2022 ")}`
266
266
  );
267
267
  }
268
268
  if (matchingPaths.length === 0) {
269
269
  throw new Error(
270
- `Could not find default application with "applications.${applicationName}"`
270
+ `Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`
271
271
  );
272
272
  }
273
273
  const [packageJsonPath] = matchingPaths;
@@ -276,15 +276,15 @@ ${matchingPaths.join("\n \u2022 ")}`
276
276
  return null;
277
277
  }
278
278
  }
279
- function findDefaultMicrofrontendsPackage(opts) {
279
+ function inferMicrofrontendsLocation(opts) {
280
280
  const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
281
281
  if (configCache[cacheKey]) {
282
282
  return configCache[cacheKey];
283
283
  }
284
- const result = findDefaultMicrofrontendsPackages(opts);
284
+ const result = findPackageWithMicrofrontendsConfig(opts);
285
285
  if (!result) {
286
286
  throw new Error(
287
- "Error trying to resolve the main microfrontends configuration"
287
+ `Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`
288
288
  );
289
289
  }
290
290
  configCache[cacheKey] = result;
@@ -335,7 +335,7 @@ function findPackageRoot(startDir) {
335
335
  currentDir = import_node_path4.default.dirname(currentDir);
336
336
  }
337
337
  throw new Error(
338
- "Package root not found. Specify the root of the package with the `package.root` option."
338
+ `The root of the package that contains the \`package.json\` file for the \`${startDir}\` directory could not be found.`
339
339
  );
340
340
  }
341
341
 
@@ -376,7 +376,9 @@ var MicrofrontendConfigClient = class {
376
376
  */
377
377
  static fromEnv(config, opts) {
378
378
  if (!config) {
379
- throw new Error("No microfrontends configuration found");
379
+ throw new Error(
380
+ "Could not construct MicrofrontendConfigClient: configuration is empty or undefined. Did you set up your application with `withMicrofrontends`?"
381
+ );
380
382
  }
381
383
  return new MicrofrontendConfigClient(
382
384
  JSON.parse(config),
@@ -1398,7 +1400,7 @@ var MicrofrontendsServer = class {
1398
1400
  const repositoryRoot = findRepositoryRoot();
1399
1401
  const isMonorepo2 = isMonorepo({ repositoryRoot });
1400
1402
  if (isMonorepo2) {
1401
- const defaultPackage = findDefaultMicrofrontendsPackage({
1403
+ const defaultPackage = inferMicrofrontendsLocation({
1402
1404
  repositoryRoot,
1403
1405
  applicationName: appName
1404
1406
  });
@@ -1410,13 +1412,15 @@ var MicrofrontendsServer = class {
1410
1412
  });
1411
1413
  }
1412
1414
  }
1413
- throw new Error("Unable to infer");
1415
+ throw new Error(
1416
+ "Unable to automatically infer the location of the `microfrontends.json` file. Microfrontends defined in separate repositories are not supported yet. If you suspect this is thrown in error, please reach out to the Vercel team."
1417
+ );
1414
1418
  } catch (e) {
1415
1419
  if (e instanceof MicrofrontendError) {
1416
1420
  throw e;
1417
1421
  }
1418
1422
  throw new MicrofrontendError(
1419
- "Unable to locate and parse microfrontends configuration",
1423
+ "Unable to locate and parse the `microfrontends.json` configuration file.",
1420
1424
  { cause: e, type: "config", subtype: "inference_failed" }
1421
1425
  );
1422
1426
  }