Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 配置webpack5,启动报错 #7087

Closed
Joyeuxman opened this issue Jul 29, 2021 · 7 comments
Closed

[Bug] 配置webpack5,启动报错 #7087

Joyeuxman opened this issue Jul 29, 2021 · 7 comments

Comments

@Joyeuxman
Copy link

What happens?

背景:项目是用umi脚手架进行搭建的,刚开始umi版本号是3.4.25,在此版本上添加webpack5:{},启动报错

后来升级umi版本号3.5.14,配置文件中添加 webpack5:{},然后启动项目依旧报错
报错如下:

Cannot read property 'toIdentifier' of undefined
TypeError: Cannot read property 'toIdentifier' of undefined
    at ReactRefreshPlugin.apply (/Users/work/cloud-classroom/node_modules/umi/node_modules/@umijs/preset-built-in/bundled/@pmmmwh/react-refresh-webpack-plugin/lib/index.js:158:18)
    at WrappedPlugin.apply (/Users/work/cloud-classroom/node_modules/@umijs/deps/compiled/speed-measure-webpack-plugin/index.js:1:3333)
    at createCompiler (/Users/work/cloud-classroom/node_modules/@umijs/deps/compiled/webpack/5/bundle5.js:191641:12)
    at /Users/work/cloud-classroom/node_modules/@umijs/deps/compiled/webpack/5/bundle5.js:191611:48
    at Array.map (<anonymous>)
    at createMultiCompiler (/Users/work/cloud-classroom/node_modules/@umijs/deps/compiled/webpack/5/bundle5.js:191611:33)
    at create (/Users/work/cloud-classroom/node_modules/@umijs/deps/compiled/webpack/5/bundle5.js:191685:16)
    at Object.webpack (/Users/work/cloud-classroom/node_modules/@umijs/deps/compiled/webpack/5/bundle5.js:191718:32)
    at Bundler.setupDevServerOpts (/Users/work/cloud-classroom/node_modules/@umijs/bundler-webpack/lib/index.js:197:40)
    at /Users/work/cloud-classroom/node_modules/umi/node_modules/@umijs/preset-built-in/lib/plugins/commands/dev/dev.js:300:30
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/work/cloud-classroom/node_modules/umi/node_modules/@umijs/preset-built-in/lib/plugins/commands/dev/dev.js:74:103)
    at _next (/Users/work/cloud-classroom/node_modules/umi/node_modules/@umijs/preset-built-in/lib/plugins/commands/dev/dev.js:76:194)

期望能够使用webpack5功能

@sorrycc
Copy link
Member

sorrycc commented Jul 29, 2021

还是给个复现仓库吧,试了下不能复现。

@github-actions
Copy link

Hello @Joyeuxman. In order to facilitate location and troubleshooting, we need you to provide a realistic example. Please forking these link codesandbox umi or using yarn create @umijs/umi-app to create and upload it to your GitHub repository.

你好 @Joyeuxman, 为了方便定位和排查问题,我们需要你提供一个重现实例,请提供一个尽可能精简的链接 codesandbox umi 或使用 yarn create @umijs/umi-app 创建,并上传到你的 GitHub 仓库。

@furylee
Copy link

furylee commented Jul 31, 2021

还是给个复现仓库吧,试了下不能复现。

今天clone 了ant pro simple JS版本,build时报warn

(node:11428) [DEP_WEBPACK_CONFIGURATION_OPTIMIZATION_NO_EMIT_ON_ERRORS] DeprecationWarning: optimization.noEmitOnErrors is deprecated in favo
r of optimization.emitOnErrors
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:11428) [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: optimizeChunkAssets is deprecated (use Compilation.hooks.pro
cessAssets instead and use one of Compilation.PROCESS_ASSETS_STAGE_* as stage option)
(node:11428) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to Normal
Module.getCompilationHooks(compilation).loader

关闭 webpack5和mfsu才不报

@Joyeuxman
Copy link
Author

我找到原因了,我在.env文件中,添加了SPEED_MEASURE=CONSOLE,就会出现那个报错信息。我去掉之后就不会报错了。

@byan
Copy link

byan commented Aug 29, 2021

我找到原因了,我在.env文件中,添加了SPEED_MEASURE=CONSOLE,就会出现那个报错信息。我去掉之后就不会报错了。

我没添加这也出现在这个报错了~ 就是简单的 yarn create umi antd-pro 采用 TS以及simple

@tvrcgo
Copy link

tvrcgo commented Apr 22, 2022

还是给个复现仓库吧,试了下不能复现。

今天clone 了ant pro simple JS版本,build时报warn

(node:11428) [DEP_WEBPACK_CONFIGURATION_OPTIMIZATION_NO_EMIT_ON_ERRORS] DeprecationWarning: optimization.noEmitOnErrors is deprecated in favo
r of optimization.emitOnErrors
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:11428) [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: optimizeChunkAssets is deprecated (use Compilation.hooks.pro
cessAssets instead and use one of Compilation.PROCESS_ASSETS_STAGE_* as stage option)
(node:11428) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to Normal
Module.getCompilationHooks(compilation).loader

关闭 webpack5和mfsu才不报

打开 webpack5 也遇到这个 warning,在 chainWebpack 里面看 config.toConfig(),还是 webpack4 的写法。

image

production mode 有,development mode 没有

@buquan
Copy link

buquan commented May 31, 2022

我找到原因了,我在.env文件中,添加了SPEED_MEASURE=CONSOLE,就会出现那个报错信息。我去掉之后就不会报错了。

应该不是umi问题,请问不去 SPEED_MEASURE=CONSOLE 有办法解决吗,这个issue好像还是没找到答案

@sorrycc sorrycc closed this as completed Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants