@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.
- 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 +3 -1
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +28 -0
- package/dist/next/testing.js +3 -1
- 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 +1 -1
package/dist/next/config.d.ts
CHANGED
|
@@ -20,8 +20,22 @@ interface WithMicrofrontendsOptions {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Automatically configures your Next.js application to work with microfrontends.
|
|
24
|
+
*
|
|
25
|
+
* This function should wrap your Next.js config object before it is exported. It
|
|
26
|
+
* will automatically set up the necessary fields and environment variables for
|
|
27
|
+
* microfrontends to work.
|
|
28
|
+
*
|
|
29
|
+
* See the [Getting Started](https://vercel.com/docs/microfrontends/quickstart) guide for more information.
|
|
30
|
+
*
|
|
31
|
+
* @example Wrapping your Next.js config
|
|
32
|
+
* ```js
|
|
33
|
+
* import { withMicrofrontends } from '@vercel/microfrontends/next/config';
|
|
34
|
+
*
|
|
35
|
+
* const nextConfig = { ... };
|
|
36
|
+
*
|
|
37
|
+
* export default withMicrofrontends(nextConfig);
|
|
38
|
+
* ```
|
|
25
39
|
*/
|
|
26
40
|
declare function withMicrofrontends(nextConfig: NextConfig, opts?: WithMicrofrontendsOptions): NextConfig;
|
|
27
41
|
|
package/dist/next/config.js
CHANGED
|
@@ -176,11 +176,11 @@ function findRepositoryRoot(startDir) {
|
|
|
176
176
|
currentDir = path.dirname(currentDir);
|
|
177
177
|
}
|
|
178
178
|
throw new Error(
|
|
179
|
-
|
|
179
|
+
`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.`
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
// src/config/microfrontends/utils/
|
|
183
|
+
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
184
184
|
import { dirname } from "node:path";
|
|
185
185
|
import { readFileSync } from "node:fs";
|
|
186
186
|
import { parse } from "jsonc-parser";
|
|
@@ -192,9 +192,9 @@ var CONFIGURATION_FILENAMES = [
|
|
|
192
192
|
"microfrontends.json"
|
|
193
193
|
];
|
|
194
194
|
|
|
195
|
-
// src/config/microfrontends/utils/
|
|
195
|
+
// src/config/microfrontends/utils/infer-microfrontends-location.ts
|
|
196
196
|
var configCache = {};
|
|
197
|
-
function
|
|
197
|
+
function findPackageWithMicrofrontendsConfig({
|
|
198
198
|
repositoryRoot,
|
|
199
199
|
applicationName
|
|
200
200
|
}) {
|
|
@@ -225,13 +225,13 @@ function findDefaultMicrofrontendsPackages({
|
|
|
225
225
|
}
|
|
226
226
|
if (matchingPaths.length > 1) {
|
|
227
227
|
throw new Error(
|
|
228
|
-
`Found multiple
|
|
228
|
+
`Found multiple \`microfrontends.json\` files in the repository referencing the application "${applicationName}", but only one is allowed.
|
|
229
229
|
${matchingPaths.join("\n \u2022 ")}`
|
|
230
230
|
);
|
|
231
231
|
}
|
|
232
232
|
if (matchingPaths.length === 0) {
|
|
233
233
|
throw new Error(
|
|
234
|
-
`Could not find
|
|
234
|
+
`Could not find a \`microfrontends.json\` file in the repository that contains "applications.${applicationName}". Microfrontends defined in separate repositories are not supported yet.`
|
|
235
235
|
);
|
|
236
236
|
}
|
|
237
237
|
const [packageJsonPath] = matchingPaths;
|
|
@@ -240,15 +240,15 @@ ${matchingPaths.join("\n \u2022 ")}`
|
|
|
240
240
|
return null;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function inferMicrofrontendsLocation(opts) {
|
|
244
244
|
const cacheKey = `${opts.repositoryRoot}-${opts.applicationName}`;
|
|
245
245
|
if (configCache[cacheKey]) {
|
|
246
246
|
return configCache[cacheKey];
|
|
247
247
|
}
|
|
248
|
-
const result =
|
|
248
|
+
const result = findPackageWithMicrofrontendsConfig(opts);
|
|
249
249
|
if (!result) {
|
|
250
250
|
throw new Error(
|
|
251
|
-
|
|
251
|
+
`Could not infer the location of the \`microfrontends.json\` file for application "${opts.applicationName}" starting in directory "${opts.repositoryRoot}".`
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
254
|
configCache[cacheKey] = result;
|
|
@@ -299,7 +299,7 @@ function findPackageRoot(startDir) {
|
|
|
299
299
|
currentDir = path3.dirname(currentDir);
|
|
300
300
|
}
|
|
301
301
|
throw new Error(
|
|
302
|
-
|
|
302
|
+
`The root of the package that contains the \`package.json\` file for the \`${startDir}\` directory could not be found.`
|
|
303
303
|
);
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -340,7 +340,9 @@ var MicrofrontendConfigClient = class {
|
|
|
340
340
|
*/
|
|
341
341
|
static fromEnv(config, opts) {
|
|
342
342
|
if (!config) {
|
|
343
|
-
throw new Error(
|
|
343
|
+
throw new Error(
|
|
344
|
+
"Could not construct MicrofrontendConfigClient: configuration is empty or undefined. Did you set up your application with `withMicrofrontends`?"
|
|
345
|
+
);
|
|
344
346
|
}
|
|
345
347
|
return new MicrofrontendConfigClient(
|
|
346
348
|
JSON.parse(config),
|
|
@@ -1362,7 +1364,7 @@ var MicrofrontendsServer = class {
|
|
|
1362
1364
|
const repositoryRoot = findRepositoryRoot();
|
|
1363
1365
|
const isMonorepo2 = isMonorepo({ repositoryRoot });
|
|
1364
1366
|
if (isMonorepo2) {
|
|
1365
|
-
const defaultPackage =
|
|
1367
|
+
const defaultPackage = inferMicrofrontendsLocation({
|
|
1366
1368
|
repositoryRoot,
|
|
1367
1369
|
applicationName: appName
|
|
1368
1370
|
});
|
|
@@ -1374,13 +1376,15 @@ var MicrofrontendsServer = class {
|
|
|
1374
1376
|
});
|
|
1375
1377
|
}
|
|
1376
1378
|
}
|
|
1377
|
-
throw new Error(
|
|
1379
|
+
throw new Error(
|
|
1380
|
+
"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."
|
|
1381
|
+
);
|
|
1378
1382
|
} catch (e) {
|
|
1379
1383
|
if (e instanceof MicrofrontendError) {
|
|
1380
1384
|
throw e;
|
|
1381
1385
|
}
|
|
1382
1386
|
throw new MicrofrontendError(
|
|
1383
|
-
"Unable to locate and parse microfrontends configuration",
|
|
1387
|
+
"Unable to locate and parse the `microfrontends.json` configuration file.",
|
|
1384
1388
|
{ cause: e, type: "config", subtype: "inference_failed" }
|
|
1385
1389
|
);
|
|
1386
1390
|
}
|