我在nextjs中使用微前端。我启动服务器,在next.config.js中获取TypeError: withModuleFederation is not a function
我尝试了@模块-联邦/nextjs的最新版本,但是在这个版本中,我得到了版本错配错误。
有什么建议或解决办法吗?
next.config.js含量
const {
withModuleFederation,
MergeRuntime,
} = require("@module-federation/nextjs-mf");
const path = require("path");
module.exports = {
webpack: (config, options) => {
const { buildId, dev, isServer, defaultLoaders, webpack } = options;
const mfConf = {
name: "test1",
library: { type: config.output.libraryTarget, name: "test1" },
filename: "static/runtime/remoteEntry.js",
remotes: {},
exposes: {
"./nav": "./components/nav",
},
shared: [],
};
withModuleFederation(config, options, mfConf);
config.plugins.push(new MergeRuntime());
if (!isServer) {
config.output.publicPath = "http://localhost:3000/_next/";
}
return config;
},
};package.json含量
{
"name": "charts",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"resolutions": {
"webpack": "5.1.3"
},
"dependencies": {
"@module-federation/nextjs-mf": "^2.3.1",
"next": "12.1.6",
"react": "18.1.0",
"react-dom": "18.1.0"
},
"devDependencies": {
"@types/node": "^17.0.40",
"@types/react": "^18.0.12",
"eslint": "8.17.0",
"eslint-config-next": "12.1.6",
"typescript": "^4.7.3"
}
}发布于 2022-06-10 05:53:31
@module-federation/nextjs-mf不再免费,如果它需要从
https://stackoverflow.com/questions/72517896
复制相似问题