@vercel/microfrontends 0.19.4 → 0.19.5
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 +13 -6
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.ts +9 -2
- package/dist/next/client.js +1 -1
- package/dist/next/client.js.map +1 -1
- package/dist/next/config.cjs +40 -13
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +40 -13
- package/dist/next/config.js.map +1 -1
- package/dist/next/middleware.cjs +31 -223
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.js +31 -223
- package/dist/next/middleware.js.map +1 -1
- package/package.json +1 -1
package/dist/next/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextConfig } from 'next';
|
|
2
2
|
|
|
3
|
-
type TransformKeys = 'assetPrefix' | 'draftMode' | 'headers' | 'rewrites' | 'serverActions' | 'webpack';
|
|
3
|
+
type TransformKeys = 'assetPrefix' | 'draftMode' | 'headers' | 'redirects' | 'rewrites' | 'serverActions' | 'webpack';
|
|
4
4
|
|
|
5
5
|
interface WithMicrofrontendsOptions {
|
|
6
6
|
/**
|
package/dist/next/config.js
CHANGED
|
@@ -1588,13 +1588,13 @@ function transform(args) {
|
|
|
1588
1588
|
next
|
|
1589
1589
|
};
|
|
1590
1590
|
}
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1591
|
+
const assetPrefix = `/${app.getAssetPrefix()}`;
|
|
1592
|
+
if (next.assetPrefix !== void 0 && next.assetPrefix !== assetPrefix) {
|
|
1593
|
+
throw new Error(
|
|
1594
|
+
`"assetPrefix" already set and does not equal "${assetPrefix}". Either omit the assetPrefix in your next config, or set it to "${assetPrefix}".`
|
|
1594
1595
|
);
|
|
1595
|
-
} else {
|
|
1596
|
-
next.assetPrefix = `/${app.getAssetPrefix()}`;
|
|
1597
1596
|
}
|
|
1597
|
+
next.assetPrefix = assetPrefix;
|
|
1598
1598
|
return {
|
|
1599
1599
|
next
|
|
1600
1600
|
};
|
|
@@ -1672,6 +1672,32 @@ function transform3(args) {
|
|
|
1672
1672
|
};
|
|
1673
1673
|
}
|
|
1674
1674
|
|
|
1675
|
+
// src/next/config/transforms/redirects.ts
|
|
1676
|
+
function transform4(args) {
|
|
1677
|
+
const { next, microfrontend, opts } = args;
|
|
1678
|
+
const isProduction2 = opts?.isProduction ?? false;
|
|
1679
|
+
const isDevEnv = (process.env.VERCEL_ENV ?? "development") === "development";
|
|
1680
|
+
const requireLocalProxyHeader = !isProduction2 && isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY) && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
|
|
1681
|
+
if (requireLocalProxyHeader) {
|
|
1682
|
+
const proxyRedirect = {
|
|
1683
|
+
source: "/:path*",
|
|
1684
|
+
destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
|
|
1685
|
+
permanent: false,
|
|
1686
|
+
missing: [{ type: "header", key: "x-vercel-mfe-local-proxy-origin" }]
|
|
1687
|
+
};
|
|
1688
|
+
if (next.redirects && typeof next.redirects === "function") {
|
|
1689
|
+
const originalRedirectsFn = next.redirects;
|
|
1690
|
+
next.redirects = async () => {
|
|
1691
|
+
const originalRedirects = await originalRedirectsFn();
|
|
1692
|
+
return [proxyRedirect, ...originalRedirects];
|
|
1693
|
+
};
|
|
1694
|
+
} else {
|
|
1695
|
+
next.redirects = async () => [proxyRedirect];
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
return { next };
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1675
1701
|
// src/routing/get-domain-from-environment.ts
|
|
1676
1702
|
function getDomainFromEnvironment({
|
|
1677
1703
|
app,
|
|
@@ -1805,7 +1831,7 @@ function rewritesMapToArr(rewrites) {
|
|
|
1805
1831
|
];
|
|
1806
1832
|
});
|
|
1807
1833
|
}
|
|
1808
|
-
function
|
|
1834
|
+
function transform5(args) {
|
|
1809
1835
|
const { next, microfrontend, app } = args;
|
|
1810
1836
|
const buildBeforeFiles = () => {
|
|
1811
1837
|
const rewrites = /* @__PURE__ */ new Map();
|
|
@@ -1907,7 +1933,7 @@ ${table}
|
|
|
1907
1933
|
}
|
|
1908
1934
|
}
|
|
1909
1935
|
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1910
|
-
function
|
|
1936
|
+
function transform6(args) {
|
|
1911
1937
|
const { next, app, microfrontend } = args;
|
|
1912
1938
|
if (microfrontend instanceof MicrofrontendChildConfig) {
|
|
1913
1939
|
console.warn(
|
|
@@ -1964,7 +1990,7 @@ function transform5(args) {
|
|
|
1964
1990
|
}
|
|
1965
1991
|
|
|
1966
1992
|
// src/next/config/transforms/webpack.ts
|
|
1967
|
-
function
|
|
1993
|
+
function transform7(args) {
|
|
1968
1994
|
const { next, microfrontend } = args;
|
|
1969
1995
|
const configWithWebpack = {
|
|
1970
1996
|
...next,
|
|
@@ -2009,9 +2035,10 @@ var transforms = {
|
|
|
2009
2035
|
assetPrefix: transform,
|
|
2010
2036
|
draftMode: transform2,
|
|
2011
2037
|
headers: transform3,
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2038
|
+
redirects: transform4,
|
|
2039
|
+
rewrites: transform5,
|
|
2040
|
+
serverActions: transform6,
|
|
2041
|
+
webpack: transform7
|
|
2015
2042
|
};
|
|
2016
2043
|
|
|
2017
2044
|
// src/next/config/env.ts
|
|
@@ -2103,13 +2130,13 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2103
2130
|
const app = microfrontends.config.getApplication(fromApp);
|
|
2104
2131
|
setEnvironment({ app, microfrontends });
|
|
2105
2132
|
let next = { ...nextConfig };
|
|
2106
|
-
for (const [key,
|
|
2133
|
+
for (const [key, transform8] of typedEntries(transforms)) {
|
|
2107
2134
|
if (opts?.skipTransforms?.includes(key)) {
|
|
2108
2135
|
console.log(`Skipping ${key} transform`);
|
|
2109
2136
|
continue;
|
|
2110
2137
|
}
|
|
2111
2138
|
try {
|
|
2112
|
-
const transformedConfig =
|
|
2139
|
+
const transformedConfig = transform8({
|
|
2113
2140
|
app,
|
|
2114
2141
|
next,
|
|
2115
2142
|
microfrontend: microfrontends.config,
|