metafizzy / zdog

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG

Home Page:https://zzz.dog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source code in ES6+?

partynikko opened this issue Β· comments

Hiya πŸ‘‹

I'm currently digging through the source code and I see it's written in ES5. I see a lot of places where ES6+ code would have simplified both development and understanding the logic.
Have you considered rewriting it to ES6+ and use a bundler with transpiler to make the library browser ready?

If it's something you'd like I could look into it and see how much effort it would take. I have good experiences bundling with rollup so I could give that a try.

Thanks
BR

Hello! Thanks for this suggestion. I'm currently using ES5 so I can support IE11 #57. Zdog v2 will likely be re-written in ES6+.

As for rollup & transpiling. See my comment #22 (comment)

Hi, thanks for reply.

I understand your argument but I don't agree. You can still get proper and full IE11 support with transpilation presets and polyfills (although I think we should ditch IE11 but that's more of a personal opinion). You won't have to debug the transpiled code and you'll have a lot of gains from using a bundler. rollup for instance doesn't clutter your bundle like certain other bundlers, code becomes pretty clean and neat.

For instance, producing three different bundles (.umd, .cjs, .esm) will give you bundles that are runnable in the browser, node and for other bundlers. The latter will let us developers who are using bundlers to take advantage of tree shaking, proper import/exports, not having to pollute with global variables and much more. Also for users that are stripping kilobytes this is necessary as importing a complete library without tree shaking just brings unused code.

If you're still not sold on the idea of having a bundler transpiling the code to the correct targets allow me to show what can be done. Even if you perhaps wouldn't like the idea yourself, I assure you that the users of this library would appreciate it (especially ES modules (.esm)) and it should therefore be considered (I would certainly love it). I can also see that there's a lot of duplicate code in the source code that could be taken care of using ES6/bundlers so you would end up with a reduced library size.

Hope you are open to this, would be fun and interesting.
If you have any other questions let me know 😊

Thanks
BR