@vercel/microfrontends 0.9.0 → 0.10.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.
- package/README.md +2 -2
- package/dist/bin/cli.cjs +1483 -186
- package/dist/config/edge.cjs +47 -47
- package/dist/config/edge.cjs.map +1 -1
- package/dist/config/edge.d.ts +6 -6
- package/dist/config/edge.js +46 -46
- package/dist/config/edge.js.map +1 -1
- package/dist/config.cjs +66 -60
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +65 -59
- package/dist/config.js.map +1 -1
- package/dist/{index-eff254d8.d.ts → index-05742bef.d.ts} +11 -22
- package/dist/{micro-frontend-config-42886104.d.ts → microfrontend-config-2425db74.d.ts} +12 -12
- package/dist/next/config.cjs +83 -77
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +3 -3
- package/dist/next/config.js +82 -76
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +55 -55
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.ts +11 -11
- package/dist/next/middleware.js +53 -53
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +79 -73
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +9 -9
- package/dist/next/testing.js +79 -73
- package/dist/next/testing.js.map +1 -1
- package/dist/overrides.cjs +9 -9
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.d.ts +1 -1
- package/dist/overrides.js +9 -9
- package/dist/overrides.js.map +1 -1
- package/dist/types-13f3e535.d.ts +15 -0
- package/dist/v2/config.cjs +39 -39
- package/dist/v2/config.cjs.map +1 -1
- package/dist/v2/config.d.ts +2 -1
- package/dist/v2/config.js +38 -38
- package/dist/v2/config.js.map +1 -1
- package/dist/v2/microfrontends/server.cjs +102 -65
- package/dist/v2/microfrontends/server.cjs.map +1 -1
- package/dist/v2/microfrontends/server.d.ts +6 -1
- package/dist/v2/microfrontends/server.js +102 -65
- package/dist/v2/microfrontends/server.js.map +1 -1
- package/dist/v2/microfrontends.cjs +44 -44
- package/dist/v2/microfrontends.cjs.map +1 -1
- package/dist/v2/microfrontends.d.ts +5 -4
- package/dist/v2/microfrontends.js +44 -44
- package/dist/v2/microfrontends.js.map +1 -1
- package/dist/v2/next/client.cjs +1 -1
- package/dist/v2/next/client.cjs.map +1 -1
- package/dist/v2/next/client.js +1 -1
- package/dist/v2/next/client.js.map +1 -1
- package/dist/v2/next/config.cjs +120 -83
- package/dist/v2/next/config.cjs.map +1 -1
- package/dist/v2/next/config.d.ts +4 -4
- package/dist/v2/next/config.js +119 -82
- package/dist/v2/next/config.js.map +1 -1
- package/dist/v2/next/endpoints.cjs +5 -5
- package/dist/v2/next/endpoints.cjs.map +1 -1
- package/dist/v2/next/endpoints.js +5 -5
- package/dist/v2/next/endpoints.js.map +1 -1
- package/dist/v2/next/middleware.cjs +54 -54
- package/dist/v2/next/middleware.cjs.map +1 -1
- package/dist/v2/next/middleware.d.ts +8 -8
- package/dist/v2/next/middleware.js +52 -52
- package/dist/v2/next/middleware.js.map +1 -1
- package/dist/v2/overrides.cjs +75 -0
- package/dist/v2/overrides.cjs.map +1 -0
- package/dist/v2/overrides.d.ts +24 -0
- package/dist/v2/overrides.js +45 -0
- package/dist/v2/overrides.js.map +1 -0
- package/dist/validation.cjs +20 -20
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.js +20 -20
- package/dist/validation.js.map +1 -1
- package/package.json +10 -3
package/dist/next/config.cjs
CHANGED
|
@@ -30,12 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/next/config/index.ts
|
|
31
31
|
var config_exports = {};
|
|
32
32
|
__export(config_exports, {
|
|
33
|
-
|
|
33
|
+
withMicrofrontends: () => withMicrofrontends
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(config_exports);
|
|
36
36
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
37
37
|
|
|
38
|
-
// src/config/
|
|
38
|
+
// src/config/microfrontend-config.ts
|
|
39
39
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
40
40
|
|
|
41
41
|
// src/config-v2/microfrontends/server/utils/get-output-file-path.ts
|
|
@@ -63,14 +63,14 @@ function getOutputFilePath() {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// src/config/errors.ts
|
|
66
|
-
var
|
|
66
|
+
var MicrofrontendError = class extends Error {
|
|
67
67
|
constructor(message, opts) {
|
|
68
68
|
super(message);
|
|
69
|
-
this.name = "
|
|
70
|
-
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/
|
|
69
|
+
this.name = "MicrofrontendsError";
|
|
70
|
+
this.source = (opts == null ? void 0 : opts.source) ?? "@vercel/microfrontends";
|
|
71
71
|
this.type = (opts == null ? void 0 : opts.type) ?? "unknown";
|
|
72
72
|
this.subtype = opts == null ? void 0 : opts.subtype;
|
|
73
|
-
Error.captureStackTrace(this,
|
|
73
|
+
Error.captureStackTrace(this, MicrofrontendError);
|
|
74
74
|
}
|
|
75
75
|
isKnown() {
|
|
76
76
|
return this.type !== "unknown";
|
|
@@ -79,13 +79,13 @@ var MicroFrontendError = class extends Error {
|
|
|
79
79
|
return !this.isKnown();
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Converts an error to a
|
|
82
|
+
* Converts an error to a MicrofrontendsError.
|
|
83
83
|
* @param original - The original error to convert.
|
|
84
|
-
* @returns The converted
|
|
84
|
+
* @returns The converted MicrofrontendsError.
|
|
85
85
|
*/
|
|
86
86
|
static convert(original, opts) {
|
|
87
87
|
if (opts == null ? void 0 : opts.fileName) {
|
|
88
|
-
const err =
|
|
88
|
+
const err = MicrofrontendError.convertFSError(original, opts.fileName);
|
|
89
89
|
if (err) {
|
|
90
90
|
return err;
|
|
91
91
|
}
|
|
@@ -93,25 +93,25 @@ var MicroFrontendError = class extends Error {
|
|
|
93
93
|
if (original.message.includes(
|
|
94
94
|
"Code generation from strings disallowed for this context"
|
|
95
95
|
)) {
|
|
96
|
-
return new
|
|
96
|
+
return new MicrofrontendError(original.message, {
|
|
97
97
|
type: "config",
|
|
98
98
|
subtype: "unsupported_validation_env",
|
|
99
99
|
source: "ajv"
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
return new
|
|
102
|
+
return new MicrofrontendError(original.message);
|
|
103
103
|
}
|
|
104
104
|
static convertFSError(original, fileName) {
|
|
105
105
|
if (original instanceof Error && "code" in original) {
|
|
106
106
|
if (original.code === "ENOENT") {
|
|
107
|
-
return new
|
|
107
|
+
return new MicrofrontendError(`Could not find "${fileName}"`, {
|
|
108
108
|
type: "config",
|
|
109
109
|
subtype: "unable_to_read_file",
|
|
110
110
|
source: "fs"
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
if (original.code === "EACCES") {
|
|
114
|
-
return new
|
|
114
|
+
return new MicrofrontendError(
|
|
115
115
|
`Permission denied while accessing "${fileName}"`,
|
|
116
116
|
{
|
|
117
117
|
type: "config",
|
|
@@ -122,7 +122,7 @@ var MicroFrontendError = class extends Error {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
if (original instanceof SyntaxError) {
|
|
125
|
-
return new
|
|
125
|
+
return new MicrofrontendError(
|
|
126
126
|
`Failed to parse "${fileName}": Invalid JSON format.`,
|
|
127
127
|
{
|
|
128
128
|
type: "config",
|
|
@@ -134,23 +134,23 @@ var MicroFrontendError = class extends Error {
|
|
|
134
134
|
return null;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* Handles an unknown error and returns a
|
|
137
|
+
* Handles an unknown error and returns a MicrofrontendsError instance.
|
|
138
138
|
* @param err - The error to handle.
|
|
139
|
-
* @returns A
|
|
139
|
+
* @returns A MicrofrontendsError instance.
|
|
140
140
|
*/
|
|
141
141
|
static handle(err, opts) {
|
|
142
|
-
if (err instanceof
|
|
142
|
+
if (err instanceof MicrofrontendError) {
|
|
143
143
|
return err;
|
|
144
144
|
}
|
|
145
145
|
if (err instanceof Error) {
|
|
146
|
-
return
|
|
146
|
+
return MicrofrontendError.convert(err, opts);
|
|
147
147
|
}
|
|
148
148
|
if (typeof err === "object" && err !== null) {
|
|
149
149
|
if ("message" in err && typeof err.message === "string") {
|
|
150
|
-
return
|
|
150
|
+
return MicrofrontendError.convert(new Error(err.message), opts);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
return new
|
|
153
|
+
return new MicrofrontendError("An unknown error occurred");
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
|
|
@@ -233,27 +233,27 @@ var _Overrides = class {
|
|
|
233
233
|
});
|
|
234
234
|
return overridesConfig;
|
|
235
235
|
}
|
|
236
|
-
static validOverrideDomainsForZone(
|
|
236
|
+
static validOverrideDomainsForZone(microfrontendConfig, zone) {
|
|
237
237
|
var _a, _b, _c, _d, _e;
|
|
238
|
-
const projectName = (_a =
|
|
238
|
+
const projectName = (_a = microfrontendConfig.getZone(zone).vercel) == null ? void 0 : _a.projectName;
|
|
239
239
|
if (!projectName) {
|
|
240
|
-
return [
|
|
240
|
+
return [microfrontendConfig.getZone(zone).production.host];
|
|
241
241
|
}
|
|
242
242
|
const parsedProjectName = makeUrlSafe(projectName);
|
|
243
|
-
const previewDeploymentSuffix = (_c = (_b =
|
|
244
|
-
const teamSlug = (_e = (_d =
|
|
243
|
+
const previewDeploymentSuffix = (_c = (_b = microfrontendConfig.options) == null ? void 0 : _b.vercel) == null ? void 0 : _c.previewDeploymentSuffix;
|
|
244
|
+
const teamSlug = (_e = (_d = microfrontendConfig.options) == null ? void 0 : _d.vercel) == null ? void 0 : _e.teamSlug;
|
|
245
245
|
if (!teamSlug && !previewDeploymentSuffix) {
|
|
246
|
-
return [
|
|
246
|
+
return [microfrontendConfig.getZone(zone).production.host];
|
|
247
247
|
}
|
|
248
248
|
const suffix = previewDeploymentSuffix ? `.${previewDeploymentSuffix}` : `-${teamSlug}.vercel.app`;
|
|
249
249
|
return [
|
|
250
250
|
`${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,
|
|
251
|
-
|
|
251
|
+
microfrontendConfig.getZone(zone).production.host
|
|
252
252
|
];
|
|
253
253
|
}
|
|
254
|
-
static validateOverrideDomain(
|
|
254
|
+
static validateOverrideDomain(microfrontendConfig, zone, domain) {
|
|
255
255
|
return new RegExp(
|
|
256
|
-
`^${_Overrides.validOverrideDomainsForZone(
|
|
256
|
+
`^${_Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(
|
|
257
257
|
"|"
|
|
258
258
|
)}$`
|
|
259
259
|
).test(domain);
|
|
@@ -335,7 +335,7 @@ var Application = class {
|
|
|
335
335
|
static validate(name, app) {
|
|
336
336
|
var _a, _b, _c, _d, _e;
|
|
337
337
|
if (((_b = (_a = app.routing) == null ? void 0 : _a.assetPrefix) == null ? void 0 : _b.startsWith("/")) || ((_d = (_c = app.routing) == null ? void 0 : _c.assetPrefix) == null ? void 0 : _d.endsWith("/"))) {
|
|
338
|
-
throw new
|
|
338
|
+
throw new MicrofrontendError(
|
|
339
339
|
`Invalid assetPrefix for application "${name}". Must not start or end with a slash.`,
|
|
340
340
|
{ type: "zone", subtype: "invalid_asset_prefix" }
|
|
341
341
|
);
|
|
@@ -346,13 +346,13 @@ var Application = class {
|
|
|
346
346
|
continue;
|
|
347
347
|
}
|
|
348
348
|
if (p.endsWith("/")) {
|
|
349
|
-
throw new
|
|
349
|
+
throw new MicrofrontendError(
|
|
350
350
|
`Invalid path for application "${name}". ${p} must not end with a slash.`,
|
|
351
351
|
{ type: "zone", subtype: "invalid_path" }
|
|
352
352
|
);
|
|
353
353
|
}
|
|
354
354
|
if (!p.startsWith("/")) {
|
|
355
|
-
throw new
|
|
355
|
+
throw new MicrofrontendError(
|
|
356
356
|
`Invalid path for application "${name}". ${p} must start with a slash.`,
|
|
357
357
|
{ type: "zone", subtype: "invalid_path" }
|
|
358
358
|
);
|
|
@@ -386,10 +386,10 @@ var Application = class {
|
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
|
|
389
|
-
// src/config/common/
|
|
389
|
+
// src/config/common/microfrontend-config.ts
|
|
390
390
|
var SUPPORTED_VERSIONS = ["1"];
|
|
391
391
|
var DEFAULT_LOCAL_PROXY_PORT = 3024;
|
|
392
|
-
var
|
|
392
|
+
var MicrofrontendConfigCommon = class {
|
|
393
393
|
constructor({
|
|
394
394
|
config,
|
|
395
395
|
overrides
|
|
@@ -397,7 +397,7 @@ var MicroFrontendConfigCommon = class {
|
|
|
397
397
|
this.zones = {};
|
|
398
398
|
var _a, _b, _c;
|
|
399
399
|
if (!SUPPORTED_VERSIONS.includes(config.version)) {
|
|
400
|
-
throw new
|
|
400
|
+
throw new MicrofrontendError(
|
|
401
401
|
`Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(
|
|
402
402
|
", "
|
|
403
403
|
)}`,
|
|
@@ -425,7 +425,7 @@ var MicroFrontendConfigCommon = class {
|
|
|
425
425
|
static getConfigFromEnv() {
|
|
426
426
|
const config = process.env.MFE_CONFIG;
|
|
427
427
|
if (!config) {
|
|
428
|
-
throw new
|
|
428
|
+
throw new MicrofrontendError(`Missing "MFE_CONFIG" in environment.`, {
|
|
429
429
|
type: "config",
|
|
430
430
|
subtype: "not_found_in_env"
|
|
431
431
|
});
|
|
@@ -444,8 +444,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
444
444
|
getZone(name) {
|
|
445
445
|
const zone = this.zones[name];
|
|
446
446
|
if (!zone) {
|
|
447
|
-
throw new
|
|
448
|
-
`Could not find
|
|
447
|
+
throw new MicrofrontendError(
|
|
448
|
+
`Could not find microfrontends configuration for application "${name}"`,
|
|
449
449
|
{
|
|
450
450
|
type: "zone",
|
|
451
451
|
subtype: "not_found"
|
|
@@ -465,8 +465,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
465
465
|
getDefaultZone() {
|
|
466
466
|
const zone = Object.values(this.zones).find((z) => z.default);
|
|
467
467
|
if (!zone) {
|
|
468
|
-
throw new
|
|
469
|
-
`Could not find default zone in
|
|
468
|
+
throw new MicrofrontendError(
|
|
469
|
+
`Could not find default zone in microfrontends configuration`,
|
|
470
470
|
{
|
|
471
471
|
type: "zone",
|
|
472
472
|
subtype: "not_found"
|
|
@@ -518,8 +518,8 @@ var MicroFrontendConfigCommon = class {
|
|
|
518
518
|
};
|
|
519
519
|
}
|
|
520
520
|
write(_) {
|
|
521
|
-
throw new
|
|
522
|
-
`Writing to file to disk requires using an instance of "
|
|
521
|
+
throw new MicrofrontendError(
|
|
522
|
+
`Writing to file to disk requires using an instance of "MicrofrontendConfig".`,
|
|
523
523
|
{ type: "config", subtype: "unsupported_operation" }
|
|
524
524
|
);
|
|
525
525
|
}
|
|
@@ -883,7 +883,7 @@ var validateSchema = (configString) => {
|
|
|
883
883
|
const validate = ajv.compile(SCHEMA);
|
|
884
884
|
const isValid = validate(parsedConfig);
|
|
885
885
|
if (!isValid) {
|
|
886
|
-
throw new
|
|
886
|
+
throw new MicrofrontendError(
|
|
887
887
|
`Invalid config: ${ajv.errorsText(validate.errors)}`,
|
|
888
888
|
{ type: "config", subtype: "does_not_match_schema" }
|
|
889
889
|
);
|
|
@@ -893,7 +893,7 @@ var validateSchema = (configString) => {
|
|
|
893
893
|
var SUPPORTED_VERSIONS2 = ["1"];
|
|
894
894
|
var validateVersion = (version) => {
|
|
895
895
|
if (!SUPPORTED_VERSIONS2.includes(version)) {
|
|
896
|
-
throw new
|
|
896
|
+
throw new MicrofrontendError(
|
|
897
897
|
`Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS2.join(
|
|
898
898
|
", "
|
|
899
899
|
)}`,
|
|
@@ -926,7 +926,7 @@ function validateMainPath(applicationConfigsById) {
|
|
|
926
926
|
return !matcher.test(defaultRoute);
|
|
927
927
|
});
|
|
928
928
|
if (!isValid) {
|
|
929
|
-
throw new
|
|
929
|
+
throw new MicrofrontendError(
|
|
930
930
|
`default route "${defaultRoute}" cannot be used for "${id}" because it is matched by "${otherId}"`,
|
|
931
931
|
{ type: "config", subtype: "invalid_main_path" }
|
|
932
932
|
);
|
|
@@ -939,7 +939,7 @@ function validateMainPath(applicationConfigsById) {
|
|
|
939
939
|
return matcher.test(defaultRoute);
|
|
940
940
|
});
|
|
941
941
|
if (!isValid) {
|
|
942
|
-
throw new
|
|
942
|
+
throw new MicrofrontendError(
|
|
943
943
|
`default route "${defaultRoute}" is not included by the routing config for application "${id}"`,
|
|
944
944
|
{ type: "config", subtype: "invalid_main_path" }
|
|
945
945
|
);
|
|
@@ -1002,7 +1002,7 @@ var validatePaths = (applicationConfigsById) => {
|
|
|
1002
1002
|
);
|
|
1003
1003
|
});
|
|
1004
1004
|
if (errors.length) {
|
|
1005
|
-
throw new
|
|
1005
|
+
throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
|
|
1006
1006
|
type: "config",
|
|
1007
1007
|
subtype: "conflicting_paths"
|
|
1008
1008
|
});
|
|
@@ -1036,13 +1036,13 @@ function validatePathExpression(path3) {
|
|
|
1036
1036
|
var validateDefaults = (applicationConfigsById) => {
|
|
1037
1037
|
const defaultApplicationIds = Object.entries(applicationConfigsById).reduce((acc, [id, app]) => app.default ? [...acc, id] : acc, []);
|
|
1038
1038
|
if (defaultApplicationIds.length === 0) {
|
|
1039
|
-
throw new
|
|
1039
|
+
throw new MicrofrontendError(
|
|
1040
1040
|
`No default application found. At least one application must be marked as default.`,
|
|
1041
1041
|
{ type: "config", subtype: "no_default_application" }
|
|
1042
1042
|
);
|
|
1043
1043
|
}
|
|
1044
1044
|
if (defaultApplicationIds.length > 1) {
|
|
1045
|
-
throw new
|
|
1045
|
+
throw new MicrofrontendError(
|
|
1046
1046
|
`Only one default application is allowed. Found ${defaultApplicationIds.join(", ")}.`,
|
|
1047
1047
|
{ type: "config", subtype: "multiple_default_applications" }
|
|
1048
1048
|
);
|
|
@@ -1054,7 +1054,7 @@ var validateOptions = (options) => {
|
|
|
1054
1054
|
if (!/^[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(
|
|
1055
1055
|
options.vercel.previewDeploymentSuffix
|
|
1056
1056
|
)) {
|
|
1057
|
-
throw new
|
|
1057
|
+
throw new MicrofrontendError(
|
|
1058
1058
|
`Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like "vercel.app".`,
|
|
1059
1059
|
{ type: "config", subtype: "invalid_preview_deployment_suffix" }
|
|
1060
1060
|
);
|
|
@@ -1109,9 +1109,15 @@ function convertV1ConfigToV2Config(config, fromApp) {
|
|
|
1109
1109
|
)
|
|
1110
1110
|
};
|
|
1111
1111
|
}
|
|
1112
|
+
const defaultApplication = Object.entries(config.applications).find(
|
|
1113
|
+
([, application]) => application.default
|
|
1114
|
+
);
|
|
1115
|
+
if (!defaultApplication) {
|
|
1116
|
+
throw new Error("No default application found in the config");
|
|
1117
|
+
}
|
|
1112
1118
|
return {
|
|
1113
1119
|
...common,
|
|
1114
|
-
partOf:
|
|
1120
|
+
partOf: defaultApplication[0]
|
|
1115
1121
|
};
|
|
1116
1122
|
}
|
|
1117
1123
|
|
|
@@ -1126,8 +1132,8 @@ function writeFile(outputPath, config, prettify) {
|
|
|
1126
1132
|
);
|
|
1127
1133
|
}
|
|
1128
1134
|
|
|
1129
|
-
// src/config/
|
|
1130
|
-
var
|
|
1135
|
+
// src/config/microfrontend-config.ts
|
|
1136
|
+
var MicrofrontendConfig = class extends MicrofrontendConfigCommon {
|
|
1131
1137
|
static validate(configString) {
|
|
1132
1138
|
const config = validateSchema(configString);
|
|
1133
1139
|
validateVersion(config.version);
|
|
@@ -1140,9 +1146,9 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1140
1146
|
static fromEnv({
|
|
1141
1147
|
cookies
|
|
1142
1148
|
}) {
|
|
1143
|
-
return new
|
|
1144
|
-
config:
|
|
1145
|
-
|
|
1149
|
+
return new MicrofrontendConfigCommon({
|
|
1150
|
+
config: MicrofrontendConfig.validate(
|
|
1151
|
+
MicrofrontendConfigCommon.getConfigFromEnv()
|
|
1146
1152
|
),
|
|
1147
1153
|
overrides: Overrides.parseOverrides(cookies)
|
|
1148
1154
|
});
|
|
@@ -1152,11 +1158,11 @@ var MicroFrontendConfig = class extends MicroFrontendConfigCommon {
|
|
|
1152
1158
|
}) {
|
|
1153
1159
|
try {
|
|
1154
1160
|
const config = import_node_fs2.default.readFileSync(filePath, "utf-8");
|
|
1155
|
-
return new
|
|
1156
|
-
config:
|
|
1161
|
+
return new MicrofrontendConfig({
|
|
1162
|
+
config: MicrofrontendConfig.validate(config)
|
|
1157
1163
|
});
|
|
1158
1164
|
} catch (e) {
|
|
1159
|
-
throw
|
|
1165
|
+
throw MicrofrontendError.handle(e, {
|
|
1160
1166
|
fileName: filePath
|
|
1161
1167
|
});
|
|
1162
1168
|
}
|
|
@@ -1441,7 +1447,7 @@ function rewritesMapToArr(rewrites) {
|
|
|
1441
1447
|
});
|
|
1442
1448
|
}
|
|
1443
1449
|
function transform4(args) {
|
|
1444
|
-
const { next,
|
|
1450
|
+
const { next, microfrontend, zone } = args;
|
|
1445
1451
|
const buildBeforeFiles = () => {
|
|
1446
1452
|
var _a, _b, _c, _d, _e;
|
|
1447
1453
|
const rewrites = /* @__PURE__ */ new Map();
|
|
@@ -1458,7 +1464,7 @@ function transform4(args) {
|
|
|
1458
1464
|
}
|
|
1459
1465
|
}
|
|
1460
1466
|
if (zone.isDefault()) {
|
|
1461
|
-
for (const [_, z] of Object.entries(
|
|
1467
|
+
for (const [_, z] of Object.entries(microfrontend.zones)) {
|
|
1462
1468
|
if (zone.name === z.name) {
|
|
1463
1469
|
continue;
|
|
1464
1470
|
}
|
|
@@ -1532,14 +1538,14 @@ function transform4(args) {
|
|
|
1532
1538
|
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1533
1539
|
function transform5(args) {
|
|
1534
1540
|
var _a;
|
|
1535
|
-
const { next, zone,
|
|
1541
|
+
const { next, zone, microfrontend } = args;
|
|
1536
1542
|
const zonesToAllow = [
|
|
1537
1543
|
// this zone - this is included by default unless allowedOrigins is overridden (which we are)
|
|
1538
1544
|
// so we re-add it here.
|
|
1539
1545
|
zone,
|
|
1540
|
-
// this is the default zone for the
|
|
1546
|
+
// this is the default zone for the microfrontend. Allow child zones to call server actions
|
|
1541
1547
|
// that are in the default zone.
|
|
1542
|
-
|
|
1548
|
+
microfrontend.getDefaultZone()
|
|
1543
1549
|
];
|
|
1544
1550
|
const existingServerActionConfig = (_a = next.experimental) == null ? void 0 : _a.serverActions;
|
|
1545
1551
|
next.experimental = {
|
|
@@ -1564,8 +1570,8 @@ function transform5(args) {
|
|
|
1564
1570
|
|
|
1565
1571
|
// src/next/config/transforms/webpack.ts
|
|
1566
1572
|
function transform6(args) {
|
|
1567
|
-
const { next,
|
|
1568
|
-
const previewDomains = process.env.VERCEL_ENV === "preview" ?
|
|
1573
|
+
const { next, microfrontend } = args;
|
|
1574
|
+
const previewDomains = process.env.VERCEL_ENV === "preview" ? microfrontend.getAllApplications().reduce(
|
|
1569
1575
|
(obj, app) => {
|
|
1570
1576
|
obj[app.name] = getPreviewDomain(app);
|
|
1571
1577
|
return obj;
|
|
@@ -1581,7 +1587,7 @@ function transform6(args) {
|
|
|
1581
1587
|
if (isServer || nextRuntime === "edge") {
|
|
1582
1588
|
config.plugins.push(
|
|
1583
1589
|
new wpFromNext.EnvironmentPlugin({
|
|
1584
|
-
MFE_CONFIG: JSON.stringify(
|
|
1590
|
+
MFE_CONFIG: JSON.stringify(microfrontend.serialize()),
|
|
1585
1591
|
MFE_PREVIEW_DOMAINS: JSON.stringify(previewDomains)
|
|
1586
1592
|
})
|
|
1587
1593
|
);
|
|
@@ -1708,18 +1714,18 @@ function getConfigPath(opts) {
|
|
|
1708
1714
|
const vercelJsonString = import_node_fs3.default.readFileSync("./vercel.json", "utf-8");
|
|
1709
1715
|
const vercelJson = JSON.parse(vercelJsonString);
|
|
1710
1716
|
if (!((_a = vercelJson.microFrontends) == null ? void 0 : _a.config)) {
|
|
1711
|
-
throw new
|
|
1717
|
+
throw new MicrofrontendError(
|
|
1712
1718
|
`vercel.json file missing required field "microFrontends.config"`,
|
|
1713
1719
|
{
|
|
1714
1720
|
type: "vercelJson",
|
|
1715
1721
|
subtype: "missing_field_microFrontend_config_path",
|
|
1716
|
-
source: "@vercel/
|
|
1722
|
+
source: "@vercel/microfrontends/next"
|
|
1717
1723
|
}
|
|
1718
1724
|
);
|
|
1719
1725
|
}
|
|
1720
1726
|
return { configPath: vercelJson.microFrontends.config };
|
|
1721
1727
|
} catch (err) {
|
|
1722
|
-
throw
|
|
1728
|
+
throw MicrofrontendError.handle(err, {
|
|
1723
1729
|
fileName: "vercel.json"
|
|
1724
1730
|
});
|
|
1725
1731
|
}
|
|
@@ -1732,30 +1738,30 @@ function getApplicationContext(opts) {
|
|
|
1732
1738
|
const packageJsonString = import_node_fs3.default.readFileSync("./package.json", "utf-8");
|
|
1733
1739
|
const packageJson = JSON.parse(packageJsonString);
|
|
1734
1740
|
if (!packageJson.name) {
|
|
1735
|
-
throw new
|
|
1741
|
+
throw new MicrofrontendError(
|
|
1736
1742
|
`package.json file missing required field "name"`,
|
|
1737
1743
|
{
|
|
1738
1744
|
type: "packageJson",
|
|
1739
1745
|
subtype: "missing_field_name",
|
|
1740
|
-
source: "@vercel/
|
|
1746
|
+
source: "@vercel/microfrontends/next"
|
|
1741
1747
|
}
|
|
1742
1748
|
);
|
|
1743
1749
|
}
|
|
1744
1750
|
return { name: packageJson.name };
|
|
1745
1751
|
} catch (err) {
|
|
1746
|
-
throw
|
|
1752
|
+
throw MicrofrontendError.handle(err, {
|
|
1747
1753
|
fileName: "package.json"
|
|
1748
1754
|
});
|
|
1749
1755
|
}
|
|
1750
1756
|
}
|
|
1751
|
-
function
|
|
1757
|
+
function withMicrofrontends(nextConfig, opts) {
|
|
1752
1758
|
var _a;
|
|
1753
1759
|
if (opts == null ? void 0 : opts.debug) {
|
|
1754
1760
|
process.env.MFE_DEBUG = "true";
|
|
1755
1761
|
}
|
|
1756
1762
|
const { name } = getApplicationContext(opts);
|
|
1757
1763
|
const { configPath } = getConfigPath(opts);
|
|
1758
|
-
const mfConfig =
|
|
1764
|
+
const mfConfig = MicrofrontendConfig.fromFile({
|
|
1759
1765
|
filePath: configPath
|
|
1760
1766
|
});
|
|
1761
1767
|
const zone = mfConfig.getZone(name);
|
|
@@ -1770,7 +1776,7 @@ function withMicroFrontends(nextConfig, opts) {
|
|
|
1770
1776
|
const transformedConfig = transform7({
|
|
1771
1777
|
zone,
|
|
1772
1778
|
next,
|
|
1773
|
-
|
|
1779
|
+
microfrontend: mfConfig,
|
|
1774
1780
|
opts: {
|
|
1775
1781
|
isProduction: isProduction(opts)
|
|
1776
1782
|
}
|
|
@@ -1788,6 +1794,6 @@ function withMicroFrontends(nextConfig, opts) {
|
|
|
1788
1794
|
}
|
|
1789
1795
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1790
1796
|
0 && (module.exports = {
|
|
1791
|
-
|
|
1797
|
+
withMicrofrontends
|
|
1792
1798
|
});
|
|
1793
1799
|
//# sourceMappingURL=config.cjs.map
|