@vercel/microfrontends 1.0.1-canary.2 → 1.0.1-canary.3
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 +3 -7
- package/dist/config.cjs +2 -6
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -6
- package/dist/config.js.map +1 -1
- package/dist/experimental/sveltekit.cjs +2 -6
- package/dist/experimental/sveltekit.cjs.map +1 -1
- package/dist/experimental/sveltekit.js +2 -6
- package/dist/experimental/sveltekit.js.map +1 -1
- package/dist/experimental/vite.cjs +49 -20
- package/dist/experimental/vite.cjs.map +1 -1
- package/dist/experimental/vite.d.ts +1 -1
- package/dist/experimental/vite.js +49 -22
- package/dist/experimental/vite.js.map +1 -1
- package/dist/{index-d5994ac5.d.ts → index-2b59c627.d.ts} +1 -1
- package/dist/microfrontends/server.cjs +2 -6
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.d.ts +1 -1
- package/dist/microfrontends/server.js +2 -6
- package/dist/microfrontends/server.js.map +1 -1
- package/dist/microfrontends.cjs +2 -6
- package/dist/microfrontends.cjs.map +1 -1
- package/dist/microfrontends.d.ts +1 -1
- package/dist/microfrontends.js +2 -6
- package/dist/microfrontends.js.map +1 -1
- package/dist/next/config.cjs +2 -6
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +2 -6
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +2 -6
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +2 -6
- package/dist/next/middleware.js.map +1 -1
- package/dist/next/testing.cjs +2 -6
- package/dist/next/testing.cjs.map +1 -1
- package/dist/next/testing.d.ts +1 -1
- package/dist/next/testing.js +2 -6
- package/dist/next/testing.js.map +1 -1
- package/dist/utils/mfe-port.cjs +2 -6
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +2 -6
- package/dist/utils/mfe-port.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// src/vite/index.ts
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { join as join3 } from "node:path";
|
|
4
|
-
import { cwd } from "node:process";
|
|
5
|
-
|
|
6
1
|
// src/config/microfrontends/server/index.ts
|
|
7
2
|
import fs5 from "node:fs";
|
|
8
3
|
import { dirname as dirname3, join as join2 } from "node:path";
|
|
@@ -676,12 +671,8 @@ var MicrofrontendConfigIsomorphic = class {
|
|
|
676
671
|
const skipValidation = opts?.skipValidation ?? [];
|
|
677
672
|
const c = typeof config === "string" ? parse(config) : config;
|
|
678
673
|
if (isMainConfig(c)) {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
if (!skipValidation.includes("defaultApplication")) {
|
|
683
|
-
validateConfigDefaultApplication(c.applications);
|
|
684
|
-
}
|
|
674
|
+
validateConfigPaths(c.applications);
|
|
675
|
+
validateConfigDefaultApplication(c.applications);
|
|
685
676
|
if (!skipValidation.includes("deprecatedFields")) {
|
|
686
677
|
validateDeprecatedFields(c);
|
|
687
678
|
}
|
|
@@ -1676,6 +1667,20 @@ function getApplicationContext(opts) {
|
|
|
1676
1667
|
}
|
|
1677
1668
|
}
|
|
1678
1669
|
|
|
1670
|
+
// src/vite/detect-framework.ts
|
|
1671
|
+
import { existsSync } from "node:fs";
|
|
1672
|
+
import { join as join3 } from "node:path";
|
|
1673
|
+
import { cwd } from "node:process";
|
|
1674
|
+
function detectFramework() {
|
|
1675
|
+
if (existsSync(join3(cwd(), "svelte.config.js"))) {
|
|
1676
|
+
return "sveltekit";
|
|
1677
|
+
}
|
|
1678
|
+
if (existsSync(join3(cwd(), "react-router.config.js")) || existsSync(join3(cwd(), "react-router.config.ts"))) {
|
|
1679
|
+
return "react-router";
|
|
1680
|
+
}
|
|
1681
|
+
return "unknown";
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1679
1684
|
// src/vite/index.ts
|
|
1680
1685
|
function microfrontends(opts) {
|
|
1681
1686
|
const { name: fromApp } = getApplicationContext();
|
|
@@ -1685,22 +1690,44 @@ function microfrontends(opts) {
|
|
|
1685
1690
|
}
|
|
1686
1691
|
});
|
|
1687
1692
|
const app = microfrontendsObj.config.getApplication(fromApp);
|
|
1693
|
+
if (app.isDefault() && opts?.basePath) {
|
|
1694
|
+
throw new Error(
|
|
1695
|
+
"`basePath` can not be set for the default microfrontends application."
|
|
1696
|
+
);
|
|
1697
|
+
}
|
|
1698
|
+
if (opts?.basePath && !opts.basePath.startsWith("/")) {
|
|
1699
|
+
throw new Error("`basePath` must start with a `/`");
|
|
1700
|
+
}
|
|
1688
1701
|
const additionalConfigOptions = {};
|
|
1702
|
+
const framework = detectFramework();
|
|
1689
1703
|
if (!app.isDefault()) {
|
|
1690
1704
|
if (opts?.basePath) {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
if (type === "asset") {
|
|
1698
|
-
return `/${app.getAssetPrefix()}/${filename}`;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
};
|
|
1705
|
+
if (framework !== "react-router" || !process.env.VERCEL_ENV) {
|
|
1706
|
+
let basePath = opts.basePath;
|
|
1707
|
+
if (process.env.NODE_ENV === "production" && !basePath.endsWith("/")) {
|
|
1708
|
+
basePath = `${basePath}/`;
|
|
1709
|
+
}
|
|
1710
|
+
additionalConfigOptions.base = basePath;
|
|
1702
1711
|
}
|
|
1712
|
+
} else if (framework !== "sveltekit") {
|
|
1713
|
+
additionalConfigOptions.experimental = {
|
|
1714
|
+
renderBuiltUrl(filename, { type }) {
|
|
1715
|
+
if (type === "asset") {
|
|
1716
|
+
return `/${app.getAssetPrefix()}/${filename}`;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1703
1720
|
}
|
|
1721
|
+
if (framework === "react-router") {
|
|
1722
|
+
additionalConfigOptions.build = {
|
|
1723
|
+
assetsDir: `./${opts?.basePath ?? app.getAssetPrefix()}`
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (app.development.local.port) {
|
|
1728
|
+
additionalConfigOptions.server = {
|
|
1729
|
+
port: app.development.local.port
|
|
1730
|
+
};
|
|
1704
1731
|
}
|
|
1705
1732
|
return {
|
|
1706
1733
|
name: "vite-plugin-vercel-microfrontends",
|