Phantom5800 / pmr-tracker

Web based tracker for Paper Mario Randomizer
MIT License
6 stars 12 forks source link

Add further optimizations to compile.bat #65

Open Phantom5800 opened 2 years ago

Phantom5800 commented 2 years ago

This is ticket for myself or someone else to try adding further optimization levels to the new compile.bat file. Closure needs a few code changes to properly optimize javascript using the more advanced flags. Right now all it does is basic minification.

MythicFrog commented 1 year ago

Looked into this and there is quite a bit of work required. We can use the ADVANCED compilation_level but we would need to reference localStorage as window.localStorage as well as make sure strict typing is being used for function calls.

Small example of an error with function and method calls

found   : boolean
required: string
  77|         window.localStorage.setItem("compact-tracker", isChecked);
                                                             ^^^^^^^^^

scripts/export.js:55:37: WARNING - [JSC_TYPE_MISMATCH] actual parameter 1 of JSONType.prototype.parse does not match formal parameter
found   : (ArrayBuffer|Blob|null|string)
required: string
  55|                 var obj = JSON.parse(json);
                                           ^^^^

While normally JS will just convert true|false to string and be done with it the advanced compilation requires it to be string going in. I'd probably just write wrapper functions for setItem to allow anything and cast them all to string before calling the localStorage method.

Phantom5800 commented 1 year ago

This is definitely something I'd like done, but also don't really have the motivation to do at the moment. It may not even help that much compared to more targeted optimization, but it would be nice to have regardless eventually.