megahertz / electron-log

Simple logging module Electron/Node.js/NW.js application. No dependencies. No complicated configuration.
MIT License
1.27k stars 124 forks source link

webpack error with 5.0 #371

Closed qyh214 closed 7 months ago

qyh214 commented 7 months ago

webpack5 electron v27 use npm run electron:serve get errors:

ERROR  Failed to compile with 1 errors                                                                                                                                                                                                                  22:58:26

 error  in ./node_modules/electron-log/src/main/index.js

Module parse failed: Unexpected token (69:30)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| function processMessage(message) {
>   Logger.getInstance(message)?.processMessage(message);
| }
|

 @ ./node_modules/electron-log/main.js 3:13-34
 @ ./src/background.js
 @ multi ./src/background.js

 ERROR  Build failed with errors.
qyh214 commented 7 months ago

maybe ts,my project is js……

megahertz commented 7 months ago

webpack 5 supports optional chainging out-of-box without loaders. Make sure it's configured properly, here is an example from e2e tests for this lib: https://github.com/megahertz/electron-log/blob/master/e2e/webpack-error-handler/webpack.config.js

qyh214 commented 7 months ago

I use electron-log@4 ,works well