multiavatar / Multiavatar

Multicultural Avatar Generator in JavaScript
https://multiavatar.com
Other
1.78k stars 172 forks source link

Support UMD and ES modules #3

Closed shadowtime2000 closed 3 years ago

shadowtime2000 commented 3 years ago

More and more people are using ES modules because of their static nature. It would be great if Multiavatar supported that. Support for UMD would also be great so then users of AMD and people who just read off the global object could also use it. There a couple different ways this could be implemented, the most organized being a rollup build setup or something, the least being copy and pasting the same code into different files for different formats.

giekaton commented 3 years ago

Yes, it would be great to support ES and UMD, thanks for the suggestion. I will check Rollup, and think about how best to do this.

giekaton commented 3 years ago

Is it a bad idea to manually add the ES and UMD build scripts in the package.json? Similarly like I did for Common JS?

From Rollup docs: "Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application."

Currently, Multiavatar is dependency-free and not using any framework. It's not made from small pieces of code, but it is a single monolithic script.

You have mentioned two extremes: manually copy-pasting, or using Rollup. Maybe there is also a middle way, which would be manually creating automated build scripts? Then a single npm run build could prepare all the three formats.

shadowtime2000 commented 3 years ago

@giekaton Seems like a good idea, we could create a tools/build.js which generates all 3 builds in a dist folder or something. If you want, I can work on that.

giekaton commented 3 years ago

That would be great! Thanks for the initiative.

If we need to discuss any details, please join our Telegram channel (https://t.me/multiavatar) or contact me by email.

Maybe the PHP build script from the svg folder should also go to the tools folder, and later it can be rewritten in JS to make the build process more seamless and this repository in a single programming language.