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, sh...
For further actions, you may consider blocking this person and/or reporting abuse
No you cant - there is no such thing as
ES6
.What you can - you can publish as
esmodules
. Theseesmodules
are not "ES Modules", akaimport/export
, but a special Babel target which targets some abstract browser, which does support these "ES Modules"(🤷♂️), plus stuff like async/await and generators(🔥), but not class members for example.So - you can publish code in
esmodules
-import/export
and language transpiled down to some "well-known" target. But any "special" babel plugin (or typescript) should do their job and disappear.After publishing module that way you will have two problems:
jest-transform
for Jest. Drawback - first run, yet without a cache, might be very slow.So - as long as you are removing any "vendor specific" stuff(like stage-1 language features, or babel-plugins) from the package code - it would be ok 👍.
This one may solve the problem github.com/WICG/import-maps#the-ba...
I believe there is no problem publishing ES6 as you call it on NPM. I post stuff all the time that uses ES10 or Electron specific features. Besides, NPM was never browser-only anyway. Lots of stuff needs to be compiled before even using it.
The most important thing is that your package adds value and that it contains a readme.md so people at least know how and in what context to use it.
Here's a resource for npm + modules: pika.dev/cdn.
It's a CDN that serves npm modules as es6 modules! I haven't tried it out, but it seems pretty cool.
So I tried it. Indeed it solves the problem. My module is ES6 (unminified, with node-style module resolution), and it works in the browser as is.
Pika CDN transpiled it for me and changed
import React from"react"
toimport React from"https://cdn.pika.dev/_/react/v16"
👌that is really cool. Thanks for trying it out and posting an update!
Yeah, I want to look into this one. Need some free time to read through
More discussion about the subject