Recently I wrote a small library for fun, which implements styled-components pattern for CSS Modules. I had a dilemma: how should I publish it, should I compile it down to ES5 and CJS or UMD or publish more than one version at once, which tool to use for it. Previously I tried
kcd-scripts (by Kent C. Dodds) and
microbundle (by Jason Miller).
This time I thought it would be a way to much trouble for a toy project. So I went ahead and published it as ES6 (source code as is without minification or anything), but with node-style module resolution.
Strictly speaking, it is not consumable by the browser, because of node-style module resolution. It is not consumable by node, because node support of ES6 modules is behind the flag. It is only consumable by bundlers, like webpack (CRA for example) and Parcel (actually I haven't tested it).
In my case, I have external dependency (React), but for example, polished doesn't have external dependencies.
What are the downsides of publishing ES6? What your approach here? Tell me your thoughts
Photo by chuttersnap on Unsplash