首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError: withModuleFederation不是函数- nextjs moduleFederation

TypeError: withModuleFederation不是函数- nextjs moduleFederation
EN

Stack Overflow用户
提问于 2022-06-06 12:43:56
回答 1查看 445关注 0票数 0

我在nextjs中使用微前端。我启动服务器,在next.config.js中获取TypeError: withModuleFederation is not a function

我尝试了@模块-联邦/nextjs的最新版本,但是在这个版本中,我得到了版本错配错误。

有什么建议或解决办法吗?

next.config.js含量

代码语言:javascript
复制
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含量

代码语言:javascript
复制
{
  "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"
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-10 05:53:31

@module-federation/nextjs-mf不再免费,如果它需要从

模块-联邦/nextjs

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72517896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档