在monorepo的共享模块中使用next js的flow出现意外错误。

问题描述 投票:0回答:1

我有一个简单的项目,设置了monorepo。当我尝试使用import一个 共享模块 内网 计划 我得到以下错误信息

image

reactjs react-native next.js monorepo yarn-workspaces
1个回答
0
投票

Next.js默认不会编译主文件夹外的node_modules内的transpile模块,因此在运行时你会在flow语法上出现异常。

我使用的是 下一个分册模块 以便移植特定的模块。

// next.config.js

const withTM = require('next-transpile-modules')(['shared-ui', 'other-shared-lib']);

modules.exports = withTM({
  ...regular next config
});

© www.soinside.com 2019 - 2024. All rights reserved.