【问题标题】:When I update react-dev-utils to the @next version. I can't find typescriptFormatter and WatchMissingNodeModulesPlugin当我将 react-dev-utils 更新到 @next 版本时。我找不到 typescriptFormatter 和 WatchMissingNodeModulesPlugin
【发布时间】:2021-08-18 07:10:37
【问题描述】:

将 webpack 从 4 更新到 5 时,出现错误:

TypeError: message.split is not a function

这是在react-dev-utils/formatWebpackMessages.js中抛出的。

然后我将 react-dev-utils 更新为 @next 版本,以解决此问题。

但是在@next 版本中,react-dev-utils 中没有WatchMissingNodeModulesPlugintypescriptFormatter,它们在与webpack4 一起使用的我的webpack.config.js 文件中使用。

我该如何解决这个问题,或者我的 typescript 项目中是否需要这两个工具?

谁能给我一个webpack.config.js 的模板,用于使用 webpack5 的打字稿项目?

【问题讨论】:

    标签: webpack create-react-app


    【解决方案1】:

    我也有这个问题。

    他们最终删除了 Webpack 5 的 WatchMissingNodeModulesPlugin,所以你也必须删除它的使用。这将是与此 PR 类似的更改: https://github.com/facebook/create-react-app/pull/11170/files

    同样,typescriptFormatter 在此更改中被删除: https://github.com/facebook/create-react-app/pull/10004
    为此,您需要对 webpack.config.js 文件进行相同的更改。

    【讨论】:

    • 很好的答案,谢谢
    • 有什么可以代替打字稿格式化程序的吗?如果我删除它,构建会在其他地方中断
    猜你喜欢
    • 2022-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-22
    • 1970-01-01
    • 2019-04-05
    • 2021-07-12
    • 1970-01-01
    相关资源
    最近更新 更多