graypegg / chromatism

:rainbow: A simple set of utility functions for colours.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ES Modules

TehShrike opened this issue · comments

Would you consider switching the code from CommonJS to ES Modules and exposing an entry point via pkg.module? That would allow my bundler to pull in just the exposed functions that I actually use when I want to use this library in the browser.

You would still expose a UMD or CJS entry point via main, this would just be a help to users targeting the browser.

Sure, sounds like a smart way to modernize a bit. I'll look up some ways to get this to work well with webpack's library setting, guessing I'll need the .esm.js file to not get transpiled by babel aswell

Will try to get this fixed up today!

Logged into a project here https://github.com/toish/chromatism/projects/4

haha, that's certainly much sooner than I was expecting :-)

I think there's something to the axiom "Use Webpack for apps, and Rollup for libraries", and I think it might be easier to drop in Rollup than tweak Webpack, but at the end of the day exposing the different entry points for ESM vs CJS vs ESM is what matters.

I'd be happy to help if possible. I'm on Discord if you like text chat, my id is in my Github profile.

Merged initial ES module support, See PR #3

This is complete in the refactor branch - fixed via #18, #20