xem / W

A micro WebGL2 framework with a ton of features
https://xem.github.io/W
331 stars 23 forks source link

Create an ESM build of the library so it can be imported #22

Open Lukenickerson opened 9 months ago

Lukenickerson commented 9 months ago

Background

ESM (modules) are the future; they let developers handle dependencies without polluting the window scope.

Improvements

Challenges

Can this be done in a way that...

xem commented 9 months ago

Hi and thank you for your suggestion. Can you please create a branch with an implementation that looks like what you propose here? I'm curious to see how it would look like and how to use it in a JS game. If it doesn't add too many bytes to the zip, it could replace the main version.

Lukenickerson commented 9 months ago

Here's a working version of an ESM build: https://github.com/rocket-boots/W/blob/057c2786ff92a230c7b7877436954ae95b0a5e03/w.esm.js#L4 I'm working on an implementation in a game.

Lines changed are:

@xem -- Do you have the process of creating the zip documented? Then I could do a build and compare sizes.

xem commented 9 months ago

sorry, it was long ago and I don't remember it in detail but I'm quite sure I used Terser (https://try.terser.org/) to minify and ECT to optimize the zip (https://github.com/fhanau/Efficient-Compression-Tool) with a command like ./ect.exe -9 -zip ./W.zip