@vercel/microfrontends 0.19.3 → 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 +23 -13
- package/dist/microfrontends/server.cjs +10 -7
- package/dist/microfrontends/server.cjs.map +1 -1
- package/dist/microfrontends/server.js +10 -7
- package/dist/microfrontends/server.js.map +1 -1
- 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 +50 -20
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.d.ts +1 -1
- package/dist/next/config.js +50 -20
- 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/dist/utils/mfe-port.cjs +10 -7
- package/dist/utils/mfe-port.cjs.map +1 -1
- package/dist/utils/mfe-port.js +10 -7
- package/dist/utils/mfe-port.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
|
@@ -921,13 +921,16 @@ function findDefaultMicrofrontendsPackages({
|
|
|
921
921
|
);
|
|
922
922
|
const matchingPaths = [];
|
|
923
923
|
for (const microfrontendsJsonPath of microfrontendsJsonPaths) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
924
|
+
try {
|
|
925
|
+
const microfrontendsJsonContent = readFileSync2(
|
|
926
|
+
microfrontendsJsonPath,
|
|
927
|
+
"utf-8"
|
|
928
|
+
);
|
|
929
|
+
const microfrontendsJson = parse2(microfrontendsJsonContent);
|
|
930
|
+
if (isMainConfig(microfrontendsJson) && microfrontendsJson.applications[applicationName]) {
|
|
931
|
+
matchingPaths.push(microfrontendsJsonPath);
|
|
932
|
+
}
|
|
933
|
+
} catch (error) {
|
|
931
934
|
}
|
|
932
935
|
}
|
|
933
936
|
if (matchingPaths.length > 1) {
|
|
@@ -1585,13 +1588,13 @@ function transform(args) {
|
|
|
1585
1588
|
next
|
|
1586
1589
|
};
|
|
1587
1590
|
}
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
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}".`
|
|
1591
1595
|
);
|
|
1592
|
-
} else {
|
|
1593
|
-
next.assetPrefix = `/${app.getAssetPrefix()}`;
|
|
1594
1596
|
}
|
|
1597
|
+
next.assetPrefix = assetPrefix;
|
|
1595
1598
|
return {
|
|
1596
1599
|
next
|
|
1597
1600
|
};
|
|
@@ -1669,6 +1672,32 @@ function transform3(args) {
|
|
|
1669
1672
|
};
|
|
1670
1673
|
}
|
|
1671
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
|
+
|
|
1672
1701
|
// src/routing/get-domain-from-environment.ts
|
|
1673
1702
|
function getDomainFromEnvironment({
|
|
1674
1703
|
app,
|
|
@@ -1802,7 +1831,7 @@ function rewritesMapToArr(rewrites) {
|
|
|
1802
1831
|
];
|
|
1803
1832
|
});
|
|
1804
1833
|
}
|
|
1805
|
-
function
|
|
1834
|
+
function transform5(args) {
|
|
1806
1835
|
const { next, microfrontend, app } = args;
|
|
1807
1836
|
const buildBeforeFiles = () => {
|
|
1808
1837
|
const rewrites = /* @__PURE__ */ new Map();
|
|
@@ -1904,7 +1933,7 @@ ${table}
|
|
|
1904
1933
|
}
|
|
1905
1934
|
}
|
|
1906
1935
|
var formatDomainForServerAction = (domain) => domain.replace(/https?:\/\//, "");
|
|
1907
|
-
function
|
|
1936
|
+
function transform6(args) {
|
|
1908
1937
|
const { next, app, microfrontend } = args;
|
|
1909
1938
|
if (microfrontend instanceof MicrofrontendChildConfig) {
|
|
1910
1939
|
console.warn(
|
|
@@ -1961,7 +1990,7 @@ function transform5(args) {
|
|
|
1961
1990
|
}
|
|
1962
1991
|
|
|
1963
1992
|
// src/next/config/transforms/webpack.ts
|
|
1964
|
-
function
|
|
1993
|
+
function transform7(args) {
|
|
1965
1994
|
const { next, microfrontend } = args;
|
|
1966
1995
|
const configWithWebpack = {
|
|
1967
1996
|
...next,
|
|
@@ -2006,9 +2035,10 @@ var transforms = {
|
|
|
2006
2035
|
assetPrefix: transform,
|
|
2007
2036
|
draftMode: transform2,
|
|
2008
2037
|
headers: transform3,
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2038
|
+
redirects: transform4,
|
|
2039
|
+
rewrites: transform5,
|
|
2040
|
+
serverActions: transform6,
|
|
2041
|
+
webpack: transform7
|
|
2012
2042
|
};
|
|
2013
2043
|
|
|
2014
2044
|
// src/next/config/env.ts
|
|
@@ -2100,13 +2130,13 @@ function withMicrofrontends(nextConfig, opts) {
|
|
|
2100
2130
|
const app = microfrontends.config.getApplication(fromApp);
|
|
2101
2131
|
setEnvironment({ app, microfrontends });
|
|
2102
2132
|
let next = { ...nextConfig };
|
|
2103
|
-
for (const [key,
|
|
2133
|
+
for (const [key, transform8] of typedEntries(transforms)) {
|
|
2104
2134
|
if (opts?.skipTransforms?.includes(key)) {
|
|
2105
2135
|
console.log(`Skipping ${key} transform`);
|
|
2106
2136
|
continue;
|
|
2107
2137
|
}
|
|
2108
2138
|
try {
|
|
2109
|
-
const transformedConfig =
|
|
2139
|
+
const transformedConfig = transform8({
|
|
2110
2140
|
app,
|
|
2111
2141
|
next,
|
|
2112
2142
|
microfrontend: microfrontends.config,
|