Create an ESM build of the library so it can be imported
Lukenickerson opened this issue · comments
Background
ESM (modules) are the future; they let developers handle dependencies without polluting the window
scope.
Improvements
- Create a
w.esm.js
build that usesexport default W
Challenges
Can this be done in a way that...
- doesn't increase the final build of a game?
- uses the same source file (so there aren't two divergent main js files)?
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.
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:
- 4, 5, 6 - Needed to define these
- 131 - fix from #23
- 472 - cheap way to define
AB
andBC
- 635 - the
export
@xem -- Do you have the process of creating the zip documented? Then I could do a build and compare sizes.
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