dev: webpack bundle sizes #1758
Replies: 6 comments
-
PS: note that bundle compression/optimization is enabled only to remove whitespaces, not to mangle class/function names, and not to perform any other smart processing of the Javascript AST. See: thorium-reader/webpack.config.main.js Lines 203 to 225 in bee2de1 thorium-reader/webpack.config.preload.js Lines 28 to 48 in bee2de1 thorium-reader/webpack.config.renderer-library.js Lines 274 to 294 in bee2de1 thorium-reader/webpack.config.renderer-pdf.js Lines 270 to 290 in bee2de1 thorium-reader/webpack.config.renderer-reader.js Lines 262 to 282 in bee2de1 |
Beta Was this translation helpful? Give feedback.
-
This commit introduces |
Beta Was this translation helpful? Give feedback.
-
I'd advice switching from momentjs to date-fns, you can then drop out all momentjs localizations, if you need all the localizations then there's nothing you can do there. There seems to be quite a lot of lodash... depending on your browser targets most of the lodash stuff is easy to accomplish with modern JS or just tweak your imports to tree shakeable. You might find some help on that here https://www.azavea.com/blog/2019/03/07/lessons-on-tree-shaking-lodash/. Especially the tree shaking part could help to reduce that quite a bit.
Anyhow for a packaged / desktop application this isn't so much of an issue, but a good thing to keep your eyes on. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your input. Some of the heavy dependencies are transitive, so we might need to dig deeper to find the culprits. |
Beta Was this translation helpful? Give feedback.
-
The Javascript bundles generated by WebPack for the "reader" and "library" renderer Electron processes include code that is shared with / common to the "main" process bundle. Therefore, there is an opportunity to factor out some dependencies by placing them into |
Beta Was this translation helpful? Give feedback.
-
PS: when "node integration" is disabled in renderer processes, standard OpenWebPlatform APIs can be used (such as postMessage/WebSocket/HTTP), but there is probably a better alternative: |
Beta Was this translation helpful? Give feedback.
-
Perhaps there is some room for improvement ...
(removing Moment locales would decrease the bundle size, for example)
Beta Was this translation helpful? Give feedback.
All reactions