【问题标题】:Getting unexpected error with flow in shared module of monorepo using next js使用 next js 在monorepo的共享模块中出现意外错误
【发布时间】:2020-05-15 11:21:43
【问题描述】:

我有一个带有 monorepo 设置的简单项目。当我尝试在 web next js project 中使用/导入shared module 时,出现以下错误

【问题讨论】:

    标签: reactjs react-native next.js monorepo yarn-workspaces


    【解决方案1】:

    默认情况下,Next.js 不会在 node_modules / 主文件夹外部编译/转换模块,因此在运行时会出现流语法异常。

    我使用next-transpile-modules 来转译特定模块。

    // next.config.js
    
    const withTM = require('next-transpile-modules')(['shared-ui', 'other-shared-lib']);
    
    modules.exports = withTM({
      ...regular next config
    });
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-17
      • 2020-02-01
      • 2020-04-22
      • 2021-08-11
      • 1970-01-01
      • 2021-06-25
      • 2021-12-24
      • 2011-05-29
      相关资源
      最近更新 更多