johannesjo / super-productivity

Super Productivity is an advanced todo list app with integrated Timeboxing and time tracking capabilities. It also comes with integrations for Jira, Gitlab, GitHub and Open Project.
http://super-productivity.com
MIT License
8.66k stars 753 forks source link

Lazy Load WebDAV and fix NO_REMOTE_DATA error #3140

Closed negue closed 2 months ago

negue commented 2 months ago

Description

While checking the bundle size (4.2ish MB) I wanted to try out a simple improvement and decided to lazy load webdav as an example, with that 100kb are now lazy-loaded only when webdav is actually used, sure it might not be a lot in comparison to the 4.2mb but each byte counts 😬

Also while changing it to lazy-load I saw it was missing some types, now thats added as well.

While testing it I came across the 404 Error, so I had to fix that haha

Issues Resolved

Check List

johannesjo commented 2 months ago

Thank you very much! Did you also test this with the a complete build using npm run dist?

negue commented 2 months ago

I thought npm run dist would also run in the PR CI ^^

Once I pulled master back in - dist ran through without errors :)

Althought there are 3 entries with

Error while running .clickElement() protocol action: The command failed because the referenced element is no longer attached to the DOM. – stale element reference: stale ele...

But the full process didn't stop in the middle, soo I should be fine?^^

johannesjo commented 2 months ago

It runs, but it doesn't auto test if this works :) I am asking, because I am not sure how the bundling works for this. If webdav/web is not bundled, it needs to be loaded from somewhere. Since the npm packages are not available from the compiled version I had the suspicion that this might not work for the compiled end result.

negue commented 2 months ago

If webdav/web is not bundled

using the import() call, webpack still bundles the packages, just not in the main.js file, it put this import()ed file next to it in the dist folder

it needs to be loaded from somewhere.

yep from the same folder where the main.js file is

currently without my PR it looks like this:

ls -al *.js
-rw-r--r--  1 negue  wheel     5518 Apr 24 22:01 lz.90f129666788ef51.js
-rw-r--r--  1 negue  wheel  4249892 Apr 24 22:01 main.a7176f91c6555883.js
-rw-r--r--  1 negue  wheel    63774 Apr 24 22:01 polyfills.8db5726c6ae16cfe.js
-rw-r--r--  1 negue  wheel      534 Apr 24 22:01 reminder.d44ab4085f820754.js
-rw-r--r--  1 negue  wheel     2165 Apr 24 22:01 runtime.49cc9ddf9bf315aa.js

with my pr:

ls -al *.js
-rw-r--r--  1 negue  wheel     5518 Apr 24 22:06 lz.90f129666788ef51.js
-rw-r--r--  1 negue  wheel  4142424 Apr 24 22:06 main.3ac21fab95011797.js
-rw-r--r--  1 negue  wheel    63774 Apr 24 22:06 polyfills.8db5726c6ae16cfe.js
-rw-r--r--  1 negue  wheel      534 Apr 24 22:06 reminder.d44ab4085f820754.js
-rw-r--r--  1 negue  wheel     3491 Apr 24 22:06 runtime.2764afd08133b7d3.js
-rw-r--r--  1 negue  wheel   105090 Apr 24 22:06 webdav-web.6195c46d6e0f6e15.js

Webpacks add it to the same list of lazy loaded libs like lz and reminder

({588:"lz",813:"webdav-web",954:"reminder"}[e]+"."+{588:"90f129666788ef51",813:"6195c46d6e0f6e15",954:"d44ab4085f820754"}[e]+".js")

johannesjo commented 2 months ago

Thank you very much for the explanation! I like the change! Probably makes sense to do more of this. Especially for the web version.

negue commented 2 months ago

Awesome!! :)

Probably makes sense to do more of this. Especially for the web version.

Yes I wanted to do some more lazy loads as well - first goal is to get the main.js files lower than 3.5mb 😬