@vercel/microfrontends 1.3.0 → 1.4.0-canary.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/CHANGELOG.md +67 -0
- package/dist/bin/cli.cjs +8 -5
- package/dist/next/config.cjs +42 -2
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +49 -2
- package/dist/next/config.js.map +1 -1
- package/package.json +8 -5
package/dist/next/config.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
1
9
|
// src/bin/check-proxy.ts
|
|
2
10
|
function displayLocalProxyInfo(port) {
|
|
3
11
|
const { MFE_PROXY_MESSAGE_PRINTED, TURBO_TASK_HAS_MFE_PROXY } = process.env;
|
|
@@ -1639,6 +1647,11 @@ function transform5(args) {
|
|
|
1639
1647
|
};
|
|
1640
1648
|
}
|
|
1641
1649
|
|
|
1650
|
+
// src/next/config/transforms/webpack.ts
|
|
1651
|
+
import fs7 from "node:fs";
|
|
1652
|
+
import { createRequire } from "node:module";
|
|
1653
|
+
import * as semver from "semver";
|
|
1654
|
+
|
|
1642
1655
|
// src/next/config/plugins/sort-chunks.ts
|
|
1643
1656
|
var SortChunksPlugin = class {
|
|
1644
1657
|
apply(compiler) {
|
|
@@ -1662,17 +1675,30 @@ var SortChunksPlugin = class {
|
|
|
1662
1675
|
};
|
|
1663
1676
|
|
|
1664
1677
|
// src/next/config/transforms/webpack.ts
|
|
1678
|
+
var nextVersion = getNextJsVersion();
|
|
1665
1679
|
function transform6(args) {
|
|
1680
|
+
const useDefineServer = args.opts?.preferWebpackEnvironmentPlugin ? false : semver.gte(nextVersion, "15.4.0-canary.41");
|
|
1666
1681
|
const { next, microfrontend, opts } = args;
|
|
1667
1682
|
const configWithWebpack = {
|
|
1668
1683
|
...next,
|
|
1684
|
+
...useDefineServer ? {
|
|
1685
|
+
compiler: {
|
|
1686
|
+
...next.compiler,
|
|
1687
|
+
defineServer: {
|
|
1688
|
+
...next.compiler?.defineServer,
|
|
1689
|
+
"process.env.MFE_CONFIG": JSON.stringify(
|
|
1690
|
+
microfrontend.serialize().config
|
|
1691
|
+
)
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
} : {},
|
|
1669
1695
|
webpack(cfg, context) {
|
|
1670
1696
|
const config = typeof next.webpack === "function" ? next.webpack(cfg, context) : cfg;
|
|
1671
1697
|
const { isServer, nextRuntime, webpack: wpFromNext } = context;
|
|
1672
|
-
if (isServer || nextRuntime === "edge") {
|
|
1698
|
+
if (!useDefineServer && (isServer || nextRuntime === "edge")) {
|
|
1673
1699
|
config.plugins.push(
|
|
1674
1700
|
new wpFromNext.EnvironmentPlugin({
|
|
1675
|
-
MFE_CONFIG: JSON.stringify(microfrontend.serialize())
|
|
1701
|
+
MFE_CONFIG: JSON.stringify(microfrontend.serialize().config)
|
|
1676
1702
|
})
|
|
1677
1703
|
);
|
|
1678
1704
|
}
|
|
@@ -1706,6 +1732,27 @@ function transform6(args) {
|
|
|
1706
1732
|
next: configWithWebpack
|
|
1707
1733
|
};
|
|
1708
1734
|
}
|
|
1735
|
+
function getNextJsVersion() {
|
|
1736
|
+
const cjsRequire = (
|
|
1737
|
+
// This is used so we can use `require.resolve` to find the Next.js package:
|
|
1738
|
+
// - `import.meta.resolve` is not available in CJS or early Node.js versions.
|
|
1739
|
+
// - tsup/esbuild don't generate import meta urls for CJS modules, so use this as
|
|
1740
|
+
// a test to see if we're running in ESM. Referencing `import.meta.url` is
|
|
1741
|
+
// still grammatically valid in CJS because esbuild transforms it.
|
|
1742
|
+
typeof import.meta.url === "string" ? createRequire(import.meta.url) : __require
|
|
1743
|
+
);
|
|
1744
|
+
const parsedNextPackageJson = JSON.parse(
|
|
1745
|
+
fs7.readFileSync(cjsRequire.resolve("next/package.json"), "utf8")
|
|
1746
|
+
);
|
|
1747
|
+
if (typeof parsedNextPackageJson !== "object" || parsedNextPackageJson === null) {
|
|
1748
|
+
throw new Error("Could not read 'next/package.json'.");
|
|
1749
|
+
}
|
|
1750
|
+
const parsedNextVersion = "version" in parsedNextPackageJson && parsedNextPackageJson.version;
|
|
1751
|
+
if (typeof parsedNextVersion !== "string") {
|
|
1752
|
+
throw new Error("Could not read version from 'next/package.json'.");
|
|
1753
|
+
}
|
|
1754
|
+
return parsedNextVersion;
|
|
1755
|
+
}
|
|
1709
1756
|
|
|
1710
1757
|
// src/next/config/transforms/index.ts
|
|
1711
1758
|
var transforms = {
|