Open cpoopc opened 5 years ago
It's weird that it takes so long, haven't experienced it myself.
Currently, source-map-support
is hard-coded.
We could and probably should make that optional, e.g. keep the current behaviour unless the user specified an env variable like ELECTRON_WEBPACK_DISABLE_SOURCE_MAP_SUPPORT
.
However, I think the call taking so long is is not the root of your problem. Making source map support optional on this side would allow you to remove the symptom, but it probably wouldn't fix the actual problem (that probably exists elsewhere in your code or configuration)
For a "quick" workaround..you might be able to mock the source-map-support/install
module using a library like https://github.com/theKashey/rewiremock - but you would have to do it before electron-webpack requires it, so it's not trivial either. Maybe the -r
(or --require
) argument of the node executable can help, maybe it's more difficult because it's electron.
Maybe it even works passing it via ELECTRON_ARGS
(see https://github.com/electron-userland/electron-webpack/issues/284).
process.env.ELECTRON_WEBPACK_DISABLE_SOURCE_MAP_SUPPORT = false
does not work
Yes, indeed it was just a suggestion but nothing was done yet. PRs welcome, should be straight-forward.
Here is my workaround. add follow lines to package.json
"electronWebpack" : {
"main": {
"webpackConfig": "electron.config.js"
}
}
// electron.config.js
module.exports = function (config) {
config.devtool = false
config.plugins = config.plugins.filter(plugin => plugin.constructor.name !== 'BannerPlugin')
return config
}
BannerPlugin
is used to generate require("source-map-support/source-map-support.js").install()
codes ,so we can just remove this plugin
I have a same problem. When I open devtool in config, HMR is too slow. Enable devtools: 60s Disable devtools: 9s
「wdm」: Hash: 188e8d20873448e6f3bf
Version: webpack 4.43.0
Time: 60176ms
Built at: 2021/01/30 上午10:35:47
Asset Size Chunks Chunk Names
fa0e3d75b010d8aa1506.hot-update.json 50 bytes [emitted] [immutable] [hmr]
index.html 424 bytes [emitted]
renderer.fa0e3d75b010d8aa1506.hot-update.js 8.31 KiB renderer [emitted] [immutable] [hmr] renderer
renderer.js 27.6 MiB renderer [emitted] renderer
styles.css 590 KiB renderer [emitted] renderer
Entrypoint renderer = styles.css renderer.js renderer.fa0e3d75b010d8aa1506.hot-update.js
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js] 2.38 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js] 500 bytes {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/errorEventHandlers.js] 2.91 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/formatWebpackErrors.js] 3.34 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/safeThis.js] 523 bytes {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js] 5.62 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/overlay/index.js] 8.82 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/WDSSocket.js] 871 bytes {renderer} [built]
[./node_modules/antd/dist/antd.less] 294 bytes {renderer} [built]
[./node_modules/css-hot-loader/hotModuleReplacement.js] 3.05 KiB {renderer} [built]
[./node_modules/css-hot-loader/node_modules/normalize-url/index.js] 3.85 KiB {renderer} [built]
[./node_modules/lodash/debounce.js] 5.96 KiB {renderer} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:9080] (webpack)-dev-server/client?http://localhost:9080 4.29 KiB {renderer} [built]
[./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.59 KiB {renderer} [built]
[./src/renderer/index.tsx] 3.02 KiB {renderer} [built]
「wdm」: Hash: d52ac8ff71c03d292796
Version: webpack 4.43.0
Time: 9145ms
Built at: 2021/01/30 上午10:40:17
Asset Size Chunks Chunk Names
eb253c5e0a70736f7fb5.hot-update.json 50 bytes [emitted] [immutable] [hmr]
index.html 424 bytes [emitted]
renderer.eb253c5e0a70736f7fb5.hot-update.js 5.86 KiB renderer [emitted] [immutable] [hmr] renderer
renderer.js 12.3 MiB renderer [emitted] renderer
styles.css 590 KiB renderer [emitted] renderer
Entrypoint renderer = styles.css renderer.js renderer.eb253c5e0a70736f7fb5.hot-update.js
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ErrorOverlayEntry.js] 2.38 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js] 500 bytes {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/errorEventHandlers.js] 2.91 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/formatWebpackErrors.js] 3.34 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/utils/safeThis.js] 523 bytes {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js] 5.62 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/overlay/index.js] 8.82 KiB {renderer} [built]
[./node_modules/@pmmmwh/react-refresh-webpack-plugin/sockets/WDSSocket.js] 871 bytes {renderer} [built]
[./node_modules/antd/dist/antd.less] 294 bytes {renderer} [built]
[./node_modules/css-hot-loader/hotModuleReplacement.js] 3.05 KiB {renderer} [built]
[./node_modules/css-hot-loader/node_modules/normalize-url/index.js] 3.85 KiB {renderer} [built]
[./node_modules/lodash/debounce.js] 5.96 KiB {renderer} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:9080] (webpack)-dev-server/client?http://localhost:9080 4.29 KiB {renderer} [built]
[./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.59 KiB {renderer} [built]
[./src/renderer/index.tsx] 3.02 KiB {renderer} [built]
It cost 1.1minute to "retrieveSourceMapURL", why? How can I disable it?