@vercel/microfrontends 1.1.0 → 1.1.1-canary.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.
- package/dist/bin/cli.cjs +120 -27
- package/dist/config.cjs +80 -16
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +80 -16
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +108 -23
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +108 -23
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +108 -23
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.js +108 -23
- package/dist/experimental/vite.js.map +1 -1
- package/dist/{index-2b59c627.d.ts → index-7e69650e.d.ts} +11 -5
- package/dist/microfrontends/server.cjs +108 -23
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +4 -4
- package/dist/microfrontends/server.js +108 -23
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends.cjs +80 -16
- package/dist/microfrontends.cjs.map +1 -1
- package/dist/microfrontends.d.ts +4 -4
- package/dist/microfrontends.js +80 -16
- package/dist/microfrontends.js.map +1 -1
- package/dist/next/config.cjs +125 -30
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +125 -30
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.cjs +9 -0
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.d.ts +36 -4
- package/dist/next/endpoints.js +8 -0
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +90 -16
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +90 -16
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +84 -21
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +4 -4
- package/dist/next/testing.js +84 -21
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.d.ts +3 -3
- package/dist/schema.cjs +23 -0
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.ts +7 -1
- package/dist/schema.js +13 -0
- package/dist/schema.js.map +1 -1
- package/dist/{index-2f78c0ca.d.ts → types-6ee19ccc.d.ts} +40 -9
- package/dist/{types-b6d38aea.d.ts → types-73527280.d.ts} +1 -1
- package/dist/{types-4ef2bddb.d.ts → types-74e3336c.d.ts} +1 -1
- package/dist/utils/mfe-port.cjs +108 -23
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +108 -23
- package/dist/utils/mfe-port.js.map +1 -1
- package/dist/validation.cjs +28 -7
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.js +28 -7
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/schema/schema.json +28 -7
|
@@ -278,10 +278,13 @@ var validateConfigPaths = (applicationConfigsById) => {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
if (errors.length) {
|
|
281
|
-
throw new MicrofrontendError(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
throw new MicrofrontendError(
|
|
282
|
+
`Invalid paths: ${errors.join(", ")}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,
|
|
283
|
+
{
|
|
284
|
+
type: "config",
|
|
285
|
+
subtype: "conflicting_paths"
|
|
286
|
+
}
|
|
287
|
+
);
|
|
285
288
|
}
|
|
286
289
|
};
|
|
287
290
|
var PATH_DEFAULT_PATTERN = "[^\\/#\\?]+?";
|
|
@@ -396,9 +399,40 @@ var validateDeprecatedFields = (config) => {
|
|
|
396
399
|
`Application '${applicationId}' cannot contain deprecated field 'production'. Use 'development.fallback' instead.`
|
|
397
400
|
);
|
|
398
401
|
}
|
|
399
|
-
if (application.development?.
|
|
402
|
+
if (application.development?.localPort) {
|
|
400
403
|
errors.push(
|
|
401
|
-
`Application '${applicationId}' cannot contain deprecated field 'development.
|
|
404
|
+
`Application '${applicationId}' cannot contain deprecated field 'development.localPort'. Use 'developement.local' instead.`
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
if (application.development?.fallback && typeof application.development.fallback !== "string") {
|
|
408
|
+
const fallback = application.development.fallback;
|
|
409
|
+
let asString = fallback.host;
|
|
410
|
+
if (fallback.protocol) {
|
|
411
|
+
asString = `${fallback.protocol}://${asString}`;
|
|
412
|
+
}
|
|
413
|
+
if (fallback.port) {
|
|
414
|
+
asString = `${asString}:${fallback.port}`;
|
|
415
|
+
}
|
|
416
|
+
errors.push(
|
|
417
|
+
`Application '${applicationId}' requires a string (not an object) for the 'development.fallback' field. Please set 'development.fallback' to '${asString}'.`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (application.development?.local && typeof application.development.local !== "string" && typeof application.development.local !== "number") {
|
|
421
|
+
const local = application.development.local;
|
|
422
|
+
let asString;
|
|
423
|
+
if (local.port && !local.protocol && !local.host) {
|
|
424
|
+
asString = String(local.port);
|
|
425
|
+
} else {
|
|
426
|
+
asString = local.host ?? "localhost";
|
|
427
|
+
if (local.protocol) {
|
|
428
|
+
asString = `${local.protocol}://${asString}`;
|
|
429
|
+
}
|
|
430
|
+
if (local.port) {
|
|
431
|
+
asString = `${asString}:${local.port}`;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
errors.push(
|
|
435
|
+
`Application '${applicationId}' requires a string or number (not an object) for the 'development.local' field. Please set 'development.local' to '${asString}'.`
|
|
402
436
|
);
|
|
403
437
|
}
|
|
404
438
|
}
|
|
@@ -462,10 +496,10 @@ var Host = class {
|
|
|
462
496
|
}
|
|
463
497
|
this.local = options?.isLocal;
|
|
464
498
|
}
|
|
465
|
-
static parseUrl(url) {
|
|
499
|
+
static parseUrl(url, defaultProtocol = "https") {
|
|
466
500
|
let hostToParse = url;
|
|
467
501
|
if (!/^https?:\/\//.exec(hostToParse)) {
|
|
468
|
-
hostToParse =
|
|
502
|
+
hostToParse = `${defaultProtocol}://${hostToParse}`;
|
|
469
503
|
}
|
|
470
504
|
const parsed = new URL(hostToParse);
|
|
471
505
|
if (!parsed.hostname) {
|
|
@@ -518,12 +552,39 @@ var LocalHost = class extends Host {
|
|
|
518
552
|
constructor({
|
|
519
553
|
appName,
|
|
520
554
|
localPort,
|
|
521
|
-
|
|
555
|
+
local
|
|
522
556
|
}) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
557
|
+
if (localPort && local) {
|
|
558
|
+
throw new Error(
|
|
559
|
+
`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.`
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
let protocol;
|
|
563
|
+
let host;
|
|
564
|
+
let port;
|
|
565
|
+
if (localPort) {
|
|
566
|
+
port = localPort;
|
|
567
|
+
} else if (typeof local === "number") {
|
|
568
|
+
port = local;
|
|
569
|
+
} else if (typeof local === "string") {
|
|
570
|
+
if (/^\d+$/.test(local)) {
|
|
571
|
+
port = Number.parseInt(local);
|
|
572
|
+
} else {
|
|
573
|
+
const parsed = Host.parseUrl(local, "http");
|
|
574
|
+
protocol = parsed.protocol;
|
|
575
|
+
host = parsed.host;
|
|
576
|
+
port = parsed.port;
|
|
577
|
+
}
|
|
578
|
+
} else if (local) {
|
|
579
|
+
protocol = local.protocol;
|
|
580
|
+
host = local.host;
|
|
581
|
+
port = local.port;
|
|
582
|
+
}
|
|
583
|
+
super({
|
|
584
|
+
protocol: protocol ?? "http",
|
|
585
|
+
host: host ?? "localhost",
|
|
586
|
+
port: port ?? generatePortFromName({ name: appName })
|
|
587
|
+
});
|
|
527
588
|
}
|
|
528
589
|
};
|
|
529
590
|
|
|
@@ -539,7 +600,7 @@ var Application = class {
|
|
|
539
600
|
local: new LocalHost({
|
|
540
601
|
appName: name,
|
|
541
602
|
localPort: app.development?.localPort,
|
|
542
|
-
|
|
603
|
+
local: app.development?.local
|
|
543
604
|
}),
|
|
544
605
|
fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
|
|
545
606
|
};
|
|
@@ -549,6 +610,7 @@ var Application = class {
|
|
|
549
610
|
this.fallback = new Host(app.production);
|
|
550
611
|
}
|
|
551
612
|
this.projectId = app.projectId ?? app.vercel?.projectId;
|
|
613
|
+
this.packageName = app.packageName;
|
|
552
614
|
this.overrides = overrides?.environment ? {
|
|
553
615
|
environment: new Host(overrides.environment)
|
|
554
616
|
} : void 0;
|
|
@@ -714,10 +776,12 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
714
776
|
].filter(Boolean);
|
|
715
777
|
}
|
|
716
778
|
getApplication(name) {
|
|
717
|
-
if (this.defaultApplication?.name === name) {
|
|
779
|
+
if (this.defaultApplication?.name === name || this.defaultApplication?.packageName === name) {
|
|
718
780
|
return this.defaultApplication;
|
|
719
781
|
}
|
|
720
|
-
const app = this.childApplications[name]
|
|
782
|
+
const app = this.childApplications[name] || Object.values(this.childApplications).find(
|
|
783
|
+
(child) => child.packageName === name
|
|
784
|
+
);
|
|
721
785
|
if (!app) {
|
|
722
786
|
throw new MicrofrontendError(
|
|
723
787
|
`Could not find microfrontends configuration for application "${name}"`,
|
|
@@ -1219,7 +1283,7 @@ var schema_default = {
|
|
|
1219
1283
|
$ref: "#/definitions/Application"
|
|
1220
1284
|
},
|
|
1221
1285
|
propertyNames: {
|
|
1222
|
-
description: "The unique identifier for a Microfrontend Application
|
|
1286
|
+
description: "The unique identifier for a Microfrontend Application.\n\nMust match the Vercel project name.\n\nNote: If this name does not also match the name used to run the application, (e.g. the `name` from the `package.json`), then the `packageName` field should be set."
|
|
1223
1287
|
}
|
|
1224
1288
|
},
|
|
1225
1289
|
Application: {
|
|
@@ -1241,7 +1305,12 @@ var schema_default = {
|
|
|
1241
1305
|
},
|
|
1242
1306
|
projectId: {
|
|
1243
1307
|
type: "string",
|
|
1244
|
-
description: "Vercel project ID"
|
|
1308
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1309
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1310
|
+
},
|
|
1311
|
+
packageName: {
|
|
1312
|
+
type: "string",
|
|
1313
|
+
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`."
|
|
1245
1314
|
},
|
|
1246
1315
|
production: {
|
|
1247
1316
|
$ref: "#/definitions/HostConfig",
|
|
@@ -1288,12 +1357,23 @@ var schema_default = {
|
|
|
1288
1357
|
type: "object",
|
|
1289
1358
|
properties: {
|
|
1290
1359
|
local: {
|
|
1291
|
-
|
|
1292
|
-
|
|
1360
|
+
anyOf: [
|
|
1361
|
+
{
|
|
1362
|
+
type: "number"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
type: "string"
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
$ref: "#/definitions/LocalHostConfig"
|
|
1369
|
+
}
|
|
1370
|
+
],
|
|
1371
|
+
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\n\nPassing a LocalHostConfig is deprecated and will go away soon, please pass a number or string."
|
|
1293
1372
|
},
|
|
1294
1373
|
localPort: {
|
|
1295
1374
|
type: "number",
|
|
1296
|
-
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."
|
|
1375
|
+
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.",
|
|
1376
|
+
deprecated: "Please set the port with the 'local' field instead."
|
|
1297
1377
|
},
|
|
1298
1378
|
fallback: {
|
|
1299
1379
|
anyOf: [
|
|
@@ -1304,7 +1384,7 @@ var schema_default = {
|
|
|
1304
1384
|
type: "string"
|
|
1305
1385
|
}
|
|
1306
1386
|
],
|
|
1307
|
-
description: "Fallback for local development, could
|
|
1387
|
+
description: "Fallback for local development, could point to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\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.\n\nPassing a HostConfig is deprecated and will go away soon, please pass a string."
|
|
1308
1388
|
},
|
|
1309
1389
|
task: {
|
|
1310
1390
|
type: "string",
|
|
@@ -1341,7 +1421,12 @@ var schema_default = {
|
|
|
1341
1421
|
},
|
|
1342
1422
|
projectId: {
|
|
1343
1423
|
type: "string",
|
|
1344
|
-
description: "Vercel project ID"
|
|
1424
|
+
description: "Vercel project ID, only required if the application name / id is different to the Vercel project name.",
|
|
1425
|
+
deprecated: "Instead, the application id should match the Vercel project name."
|
|
1426
|
+
},
|
|
1427
|
+
packageName: {
|
|
1428
|
+
type: "string",
|
|
1429
|
+
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`."
|
|
1345
1430
|
},
|
|
1346
1431
|
production: {
|
|
1347
1432
|
$ref: "#/definitions/HostConfig",
|