@vercel/microfrontends 1.4.1 → 1.5.0-canary.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 (48) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bin/cli.cjs +38 -74
  3. package/dist/config.cjs +4 -46
  4. package/dist/config.cjs.map +1 -1
  5. package/dist/config.d.ts +5 -11
  6. package/dist/config.js +4 -46
  7. package/dist/config.js.map +1 -1
  8. package/dist/experimental/sveltekit.cjs +37 -73
  9. package/dist/experimental/sveltekit.cjs.map +1 -1
  10. package/dist/experimental/sveltekit.js +37 -73
  11. package/dist/experimental/sveltekit.js.map +1 -1
  12. package/dist/experimental/vite.cjs +37 -73
  13. package/dist/experimental/vite.cjs.map +1 -1
  14. package/dist/experimental/vite.js +37 -73
  15. package/dist/experimental/vite.js.map +1 -1
  16. package/dist/microfrontends/server.cjs +37 -73
  17. package/dist/microfrontends/server.cjs.map +1 -1
  18. package/dist/microfrontends/server.d.ts +2 -2
  19. package/dist/microfrontends/server.js +37 -73
  20. package/dist/microfrontends/server.js.map +1 -1
  21. package/dist/next/config.cjs +41 -73
  22. package/dist/next/config.cjs.map +1 -1
  23. package/dist/next/config.js +41 -73
  24. package/dist/next/config.js.map +1 -1
  25. package/dist/next/middleware.cjs +4 -46
  26. package/dist/next/middleware.cjs.map +1 -1
  27. package/dist/next/middleware.js +4 -46
  28. package/dist/next/middleware.js.map +1 -1
  29. package/dist/next/testing.cjs +4 -46
  30. package/dist/next/testing.cjs.map +1 -1
  31. package/dist/next/testing.d.ts +2 -2
  32. package/dist/next/testing.js +4 -46
  33. package/dist/next/testing.js.map +1 -1
  34. package/dist/overrides.d.ts +3 -3
  35. package/dist/schema.d.ts +2 -2
  36. package/dist/{types-ab31c948.d.ts → types-1cec43e6.d.ts} +0 -15
  37. package/dist/{types-d3cb74a6.d.ts → types-1fb60496.d.ts} +1 -1
  38. package/dist/utils/mfe-port.cjs +37 -73
  39. package/dist/utils/mfe-port.cjs.map +1 -1
  40. package/dist/utils/mfe-port.js +37 -73
  41. package/dist/utils/mfe-port.js.map +1 -1
  42. package/dist/validation.cjs +23 -27
  43. package/dist/validation.cjs.map +1 -1
  44. package/dist/validation.d.ts +1 -1
  45. package/dist/validation.js +23 -27
  46. package/dist/validation.js.map +1 -1
  47. package/package.json +1 -1
  48. package/schema/schema.json +0 -20
@@ -200,17 +200,27 @@ function hasGitDirectory(dir) {
200
200
  function hasPnpmWorkspaces(dir) {
201
201
  return import_node_fs.default.existsSync(import_node_path.default.join(dir, "pnpm-workspace.yaml"));
202
202
  }
203
+ function hasPackageJson(dir) {
204
+ return import_node_fs.default.existsSync(import_node_path.default.join(dir, "package.json"));
205
+ }
203
206
  function findRepositoryRoot(startDir) {
204
207
  if (process.env.NX_WORKSPACE_ROOT) {
205
208
  return process.env.NX_WORKSPACE_ROOT;
206
209
  }
207
210
  let currentDir = startDir || process.cwd();
211
+ let lastPackageJsonDir = null;
208
212
  while (currentDir !== import_node_path.default.parse(currentDir).root) {
209
213
  if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {
210
214
  return currentDir;
211
215
  }
216
+ if (hasPackageJson(currentDir)) {
217
+ lastPackageJsonDir = currentDir;
218
+ }
212
219
  currentDir = import_node_path.default.dirname(currentDir);
213
220
  }
221
+ if (lastPackageJsonDir) {
222
+ return lastPackageJsonDir;
223
+ }
214
224
  throw new Error(
215
225
  `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
226
  );
@@ -606,33 +616,6 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
606
616
  );
607
617
  }
608
618
  };
609
- var validateDeprecatedFields = (config) => {
610
- const errors = [];
611
- for (const [applicationId, application] of Object.entries(
612
- config.applications
613
- )) {
614
- if (application.development?.localPort) {
615
- errors.push(
616
- `Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
617
- );
618
- }
619
- if (application.projectId) {
620
- errors.push(
621
- `Application '${applicationId}' cannot contain deprecated field 'projectId'. If the application ID matches the Vercel project name, then please remove the 'projectId' field. Otherwise, either update the application ID / Vercel project name to match, or set the 'packageName' field to the name of the package.json name.`
622
- );
623
- }
624
- }
625
- if (errors.length) {
626
- throw new MicrofrontendError(
627
- `Microfrontends configuration file errors:
628
- - ${errors.join("\n- ")}`,
629
- {
630
- type: "config",
631
- subtype: "depcrecated_field"
632
- }
633
- );
634
- }
635
- };
636
619
 
637
620
  // src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts
638
621
  var PREFIX = "vc-ap";
@@ -737,20 +720,12 @@ var Host = class {
737
720
  var LocalHost = class extends Host {
738
721
  constructor({
739
722
  appName,
740
- localPort,
741
723
  local
742
724
  }) {
743
- if (localPort && local) {
744
- throw new Error(
745
- `Microfrontends configuration error: '${appName}' has both the 'development.local' and 'development.localPort' fields set. Please remove the 'development.localPort' field and ensure the 'development.local' field has the correct port.`
746
- );
747
- }
748
725
  let protocol;
749
726
  let host;
750
727
  let port;
751
- if (localPort) {
752
- port = localPort;
753
- } else if (typeof local === "number") {
728
+ if (typeof local === "number") {
754
729
  port = local;
755
730
  } else if (typeof local === "string") {
756
731
  if (/^\d+$/.test(local)) {
@@ -792,7 +767,6 @@ var Application = class {
792
767
  this.development = {
793
768
  local: new LocalHost({
794
769
  appName: name,
795
- localPort: app.development?.localPort,
796
770
  local: app.development?.local
797
771
  }),
798
772
  fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
@@ -800,7 +774,6 @@ var Application = class {
800
774
  if (app.development?.fallback) {
801
775
  this.fallback = new Host(app.development.fallback);
802
776
  }
803
- this.projectId = app.projectId;
804
777
  this.packageName = app.packageName;
805
778
  this.overrides = overrides?.environment ? {
806
779
  environment: new Host(overrides.environment)
@@ -864,11 +837,10 @@ var DEFAULT_LOCAL_PROXY_PORT = 3024;
864
837
  var MicrofrontendConfigIsomorphic = class {
865
838
  constructor({
866
839
  config,
867
- overrides,
868
- opts
840
+ overrides
869
841
  }) {
870
842
  this.childApplications = {};
871
- MicrofrontendConfigIsomorphic.validate(config, opts);
843
+ MicrofrontendConfigIsomorphic.validate(config);
872
844
  const disableOverrides = config.options?.disableOverrides ?? false;
873
845
  this.overrides = overrides && !disableOverrides ? overrides : void 0;
874
846
  let defaultApplication;
@@ -903,14 +875,10 @@ var MicrofrontendConfigIsomorphic = class {
903
875
  overrides
904
876
  };
905
877
  }
906
- static validate(config, opts) {
907
- const skipValidation = opts?.skipValidation ?? [];
878
+ static validate(config) {
908
879
  const c = typeof config === "string" ? (0, import_jsonc_parser2.parse)(config) : config;
909
880
  validateConfigPaths(c.applications);
910
881
  validateConfigDefaultApplication(c.applications);
911
- if (!skipValidation.includes("deprecatedFields")) {
912
- validateDeprecatedFields(c);
913
- }
914
882
  return c;
915
883
  }
916
884
  static fromEnv({
@@ -1091,7 +1059,9 @@ var schema_default = {
1091
1059
  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"
1092
1060
  }
1093
1061
  },
1094
- required: ["applications"],
1062
+ required: [
1063
+ "applications"
1064
+ ],
1095
1065
  additionalProperties: false
1096
1066
  },
1097
1067
  Options: {
@@ -1130,11 +1100,6 @@ var schema_default = {
1130
1100
  DefaultApplication: {
1131
1101
  type: "object",
1132
1102
  properties: {
1133
- projectId: {
1134
- type: "string",
1135
- description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
1136
- deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
1137
- },
1138
1103
  packageName: {
1139
1104
  type: "string",
1140
1105
  description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
@@ -1144,21 +1109,21 @@ var schema_default = {
1144
1109
  description: "Development configuration for the default application."
1145
1110
  }
1146
1111
  },
1147
- required: ["development"],
1112
+ required: [
1113
+ "development"
1114
+ ],
1148
1115
  additionalProperties: false
1149
1116
  },
1150
1117
  DefaultDevelopment: {
1151
1118
  type: "object",
1152
1119
  properties: {
1153
1120
  local: {
1154
- type: ["number", "string"],
1121
+ type: [
1122
+ "number",
1123
+ "string"
1124
+ ],
1155
1125
  description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1156
1126
  },
1157
- localPort: {
1158
- type: "number",
1159
- description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
1160
- deprecated: "Please set the port with the 'local' field instead."
1161
- },
1162
1127
  task: {
1163
1128
  type: "string",
1164
1129
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
@@ -1168,17 +1133,14 @@ var schema_default = {
1168
1133
  description: "Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\n\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS."
1169
1134
  }
1170
1135
  },
1171
- required: ["fallback"],
1136
+ required: [
1137
+ "fallback"
1138
+ ],
1172
1139
  additionalProperties: false
1173
1140
  },
1174
1141
  ChildApplication: {
1175
1142
  type: "object",
1176
1143
  properties: {
1177
- projectId: {
1178
- type: "string",
1179
- description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
1180
- deprecated: "Instead, the application id should match the Vercel project name. `packageName` can optionally\nbe set to the name of the package.json (if it is different from the project name)."
1181
- },
1182
1144
  packageName: {
1183
1145
  type: "string",
1184
1146
  description: "The name used to run the application, e.g. the `name` field in the `package.json`.\n\nThis is used by the local proxy to map the application config to the locally running app.\n\nThis is only necessary when the application name does not match the `name` used in `package.json`."
@@ -1192,21 +1154,21 @@ var schema_default = {
1192
1154
  description: "Groups of path expressions that are routed to this application."
1193
1155
  }
1194
1156
  },
1195
- required: ["routing"],
1157
+ required: [
1158
+ "routing"
1159
+ ],
1196
1160
  additionalProperties: false
1197
1161
  },
1198
1162
  ChildDevelopment: {
1199
1163
  type: "object",
1200
1164
  properties: {
1201
1165
  local: {
1202
- type: ["number", "string"],
1166
+ type: [
1167
+ "number",
1168
+ "string"
1169
+ ],
1203
1170
  description: "A local port number or host string that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTP. If omitted, the port defaults to a unique, but stable (based on the application name) number.\n\nExamples of valid values:\n- 8080\n- my.localhost.me\n- my.localhost.me:8080\n- https://my.localhost.me\n- https://my.localhost.me:8080"
1204
1171
  },
1205
- localPort: {
1206
- type: "number",
1207
- description: "The local port number that this application runs on when it is running locally. Common values include `80` for HTTP and `443` for HTTPS. If omitted, the port defaults to a unique, but stable (based on the application name) number.",
1208
- deprecated: "Please set the port with the 'local' field instead."
1209
- },
1210
1172
  task: {
1211
1173
  type: "string",
1212
1174
  description: "Optional task to run when starting the development server. Should reference a script in the package.json of the application."
@@ -1242,7 +1204,9 @@ var schema_default = {
1242
1204
  }
1243
1205
  }
1244
1206
  },
1245
- required: ["paths"],
1207
+ required: [
1208
+ "paths"
1209
+ ],
1246
1210
  additionalProperties: false
1247
1211
  }
1248
1212
  }
@@ -1537,6 +1501,10 @@ function transform(args) {
1537
1501
  );
1538
1502
  }
1539
1503
  next.assetPrefix = assetPrefix;
1504
+ next.images = {
1505
+ ...next.images,
1506
+ path: `${assetPrefix}/_next/image`
1507
+ };
1540
1508
  return {
1541
1509
  next
1542
1510
  };