@vercel/microfrontends 1.1.1-canary.7 → 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.
- package/dist/bin/cli.cjs +50 -17
- package/dist/config.cjs +3 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +18 -14
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +18 -14
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +18 -14
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.d.ts +3 -2
- package/dist/experimental/vite.js +18 -14
- package/dist/experimental/vite.js.map +1 -1
- package/dist/microfrontends/server.cjs +18 -14
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.js +18 -14
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends/utils.cjs +71 -2
- package/dist/microfrontends/utils.cjs.map +1 -1
- package/dist/microfrontends/utils.d.ts +11 -1
- package/dist/microfrontends/utils.js +69 -1
- package/dist/microfrontends/utils.js.map +1 -1
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +18 -14
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +16 -2
- package/dist/next/config.js +18 -14
- package/dist/next/config.js.map +1 -1
- package/dist/next/endpoints.cjs +3 -1
- package/dist/next/endpoints.cjs.map +1 -1
- package/dist/next/endpoints.js +3 -1
- package/dist/next/endpoints.js.map +1 -1
- package/dist/next/middleware.cjs +7 -3
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +7 -3
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +4 -2
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +28 -0
- package/dist/next/testing.js +4 -2
- package/dist/next/testing.js.map +1 -1
- package/dist/utils/mfe-port.cjs +18 -14
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +18 -14
- package/dist/utils/mfe-port.js.map +1 -1
- package/package.json +3 -3
package/dist/next/config.cjs
CHANGED
|
@@ -212,11 +212,11 @@ function findRepositoryRoot(startDir) {
|
|
|
212
212
|
currentDir = import_node_path.default.dirname(currentDir);
|
|
213
213
|
}
|
|
214
214
|
throw new Error(
|
|
215
|
-
|
|
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/
|
|
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/
|
|
231
|
+
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
232
232
|
var configCache = {};
|
|
233
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
284
|
+
const result = findPackageWithMicrofrontendsConfig(opts);
|
|
285
285
|
if (!result) {
|
|
286
286
|
throw new Error(
|
|
287
|
-
|
|
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
|
-
|
|
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(
|
|
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 =
|
|
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(
|
|
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
|
}
|