-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
jsnext:main should point to a distributable ES6 bundle #1042
Comments
Hmm. What is a “distributable ES6 bundle”? Something that doesn’t have |
@dchambers So basically what we need is to run babel on src with most of the transforms, but exclude the module transforms so that import and export remain in the transpiled |
Good question! I did wonder myself, but assumed it was only me that didn't quite get it :-). @Rich-Harris, can you clarify please? |
Other than that possibility, it could either mean that it needs to be bundled in to a single file (which I think defeats the purpose of Rollup, so I imagine it is not that case) or that the es7 features used in the codebase are the blocker. There isn't extensive usage of es7 but the object spread operation would probably be enough to make it "not es6 distributable" I'm sure Rich-Harris can provide a solid answer, though. |
Sure, I'll try and clarify – but with the caveat that this is my interpretation! Unfortunately as a community we haven't quite figured out a consensus on how to transition to ES6 modules – there's lots of room for different views on how exactly to go about it. There's a thread over here though if you'd like to participate --> jsforum/jsforum#5 'Distributable ES6 bundle' is a poorly-chosen phrase but I meant code that is runnable except for the You might reasonably ask what's so special about In an ideal world we wouldn't need Apologies for the long answer, I didn't have time to write a shorter one 😉 |
So it sounds like there are few options:
Did I miss any options? |
Also, how does this relate to #964? It seems like that PR wouldn't work without this issue being handled, right? edit: I see now that Rollup is indeed bundling the compiled source. |
The fourth option – let's call it 2b – is to create a single file containing the whole of Redux, but as an ES6 module. It would look like this: https://gist.github.com/Rich-Harris/d3269558c4cd30a3f41b This is basically the same as the current UMD build, but, well, without the UMD. There isn't really any advantage in this case to exposing a directory that mirrored the structure of src but with transpiled-except-modules JavaScript – bundling is better. It's orthogonal to #964, which is purely about a faster/leaner UMD build. That PR is ready to go – it's entirely up to @gaearon and the other contributors whether they want to use it or not. |
BTW, this is how we're considering setting things up for React Router: remix-run/react-router#2530. By my understanding, |
@taion Yea, that looks to be about what I was thinking would work too. To be candid about this though: I probably wouldn't have suggested adding jsnext:main if I had known/understood about this aspect of it. |
I'm coming at this from the sidelines a bit - I think for a package like React Router where most users will use most of the exported things, the practical benefit of adding an ES6 build is pretty minimal. My vague understanding of Redux is that it's in the same boat. Packages that would help their users by distributing a build in this format would be more like |
@danmartinez101 I'm curious why you'd recommend against adding that |
I don't mean that I would recommend against it; I just mean that I wouldn't have initially suggested it in reduxjs/react-redux#186 (which I now realize isn't even in this project). Basically, I have no strong opinion for or against it. |
Hah. Okay. Yes, we turned down a PR on React Router to the same effect: remix-run/react-router#2523 I'd assert that reduxjs/react-redux#186 is incorrect - but there is an easy solution, one that I think as many libraries as possible should try to take. |
It's not just about whether the user only uses parts of your library, it's also about whether you only use parts of the libraries you use, etc, because this benefit will be transitive. |
@gaearon Do you want this set up per remix-run/react-router#2530? I can put together a PR. About to update both React Router and |
So any consensus here? |
IMO the best/easiest build setup available is something like what we have on the React Router and history repos. It's a little harder with Babel 6, because you can't just blacklist the module transform and instead have to make an "es2015-without-module-transform" preset, but you don't need rollup to build an ES6 module build. |
Who does this benefit? |
Almost nobody - in theory rollup and webpack 2 users, but you can't really bundle an application with rollup, and the webpack 2 beta isn't quite usable yet. More importantly, the tree-shaking benefit is almost non-existent here, too, given how small Redux is. Especially if you're looking at moving to Babel 6 soon, IMO just drop the |
Please give your comments on #1369. |
Fixed in 3.3.0. |
It's not currently spelt out in the wiki page, but jsnext:main is apparently meant to point to a distributable ES6 bundle rather than to the source code. For example, see:
taken from this comment.
The text was updated successfully, but these errors were encountered: