-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ES6 export syntax #150
Conversation
01b51da
to
ca6a13f
Compare
ca6a13f
to
3dda741
Compare
@dcousens @JedWatson friendly 🏓 |
Thanks! But, I don't think this is necessary. It doesn't make things any simpler, and it doesn't resolve any issues. edit: downvotes! eep |
@dcousens I've created an illustration of the problem that this would solve, you can check this out here. This is a project with a simple structure:
|
The tl;dr being that non-ES6 imports stop tree-shaking? Well ok! As is, there is like 3 new dev dependencies, simply to account for bower users. |
Yeah, that was the point of my PR - sorry for not explaining this before.
Im not sure what I could minimize more. Let's sum up the changes:
If you want I can create those "proxy" directories in favour of gitignoring them and building them automatically within build script. I can also make any other change regarding everything Ive done & listed above - but Im not sure what exactly you'd like to have refactored, I'd love if you could clarify this for me 😃
From my point of view devDeps are of no cost (except maintenance). I understand that not everyone agrees with that statement. That being said this PR does not target bower users, it targets most bundlers - webpack, rollup, browserify, etc - and for a library such as |
@dcousens 👋 could you specify what has to be done to get this merged in? :) |
@Andarist technically we shouldn't need to do anything but ES6ify the code. If you remove it, it may impact users who download/deploy from the GitHub repository directly. If we drop the need for |
You had no
is not relevant here.
If one download/deploy directly from GitHub he/she shouldn't ever rely on I haven't realized though that bower does not have its registry, but rather it uses git urls. I'm not sure how one is supposed to consume bower package - how one requires it etc. It seems that one of possible ways to do it listed in the docs is:
This would mean that ANY directory structure change is a possible breaking change for bower users (which I personally consider as internal detail, not part of the public API). Because bower itself recognizes its tool as outdated (they have this text on their front page - "...psst! While Bower is maintained, we recommend using Yarn and Webpack for front-end projects read how to migrate!") I would consider 2 options:
I can tweak this PR however you want, but I'm still unsure about exact steps that you'd like to see taken here. I can add |
Oops, thanks. IMHO, I'd rather drop Bower, but, I think this is up to @JedWatson now. I don't think I'd want to force a Personally, I'd probably drop the AMD exports, solely require-js, and then let the rest figure itself out, with ES6 when ready (probably when Node is ready). |
👍
This actually is not forcing anything on anyone, |
[edited to clarify my support for this PR] @Andarist - great job refactoring to use ES6+ features! This strategy is perfect for supporting new syntax without dropping support for people who need older syntax. I definitely would prefer using classNames as an ES6 module. For those not familiar with the strategy for supporting CJS and ESM at the same time through NPM, below is a reference that talks about how to do this: https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c |
@drewpc this PR targets both CJS and ESM consumers already, everything should be covered 😃 |
+1 This would add autocomplete and auto importing in all IDE's of the IntelliJ family (WebStorm, PHPStorm etc.) |
For #167 |
@doxiaodong ur solution is really more of a hack than a fix for this whole issue |
@JedWatson @dcousens Is there any further movement toward approving this PR? This is really the way JS libraries should be published going forward. |
Can this PR be re-based? What is the cost of dropping I don't know how damaging this will be overall seeing as Bower is deprecated, but I'm willing to deal with the nightmare if necessary. |
Sure, gonna do that some time later & ping you when I'm done.
Babel by default (when using core plugins, not community ones) won't output // with rollup
var classnames = require('classnames')
// with babel
var classnames = require('classnames').default Also it's IMHO easier to setup rollup with different module outputs (esm, cjs, umd) than in case of babel alone. If we drop using const/let directly we could also drop babel entirely and just let rollup output appropriate module format - without transpiling rest of the file. |
@Andarist like you, I don't like the present state of the module export handling, however, this still doesn't feel "production ready" to me. I personally use ES6 everywhere, and then I let babel/browserify handle it all at the top level. But, this package is used, a lot, and by so many different use cases, I can't see this transition happening smoothly... yet. Maybe in 6-12 months we'll have progressed even further? |
@dcocchia would making this a major version change be sufficient for not breaking it for current users? |
@dcousens Why not just make a major release? It won't break anything. This module is too small to be a dependency bloat. |
@Andarist wouldn't the present approach prevent tree shaking as it compiles down to ES5? |
ESM bundle will be treeshaken. CJS will be used by node and other who does not support |
What is the current status of this? Any blockers? Would love to see this merged. |
Would be great to see this become a part of the project! |
Marked as a breaking change. |
Do you plan on merging this? I could rebase to make it mergeable. |
Still not merged? if I use classnames as a dependency in my shareable components I can't bundle it - and this pr will help me
|
Try https://github.com/lukeed/clsx. Though there is no bind support. |
@TrySound thank you. Actually binding not a big deal
|
Just wanted to note that I'm about to revisit this package and publish a new major version with esmodule support and some performance improvements that have been contributed. Sorry for the lack of updates until now, but the js ecosystem has come a long way since this was last seriously reviewed and things are different now so I'm going to dust it all off and do something about improving it. |
ES module support has been implemented on the |
From what I see, what's on the |
The only thing Im unsure about is how "main" field of bower.json should get adjusted.