-
Notifications
You must be signed in to change notification settings - Fork 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
Stop publishing rxjs-es. Move ES6 build to output .mjs files alongside the CJS .js files. #1671
Comments
I'm not big on jumping on the That said, if we did publish Also--I do not think we should stop publishing |
should be clear - i'm not advocating at all the Sigh. |
@robwormald Great clarification, I didn't realize that. oy vey module systems... I'm way more OK with including the source as ES6 modules w/
|
Just to make things more interesting, TypeScript does not currently support targeting ES5 but keeping ES6 module syntax. e.g. Open issue: microsoft/TypeScript#6319 Sooooo...we could output entirely ES6 code, but then you must transpile all ES6 syntax, not just the module syntax. Is that OK? AFAIK rollup only supports the module syntax, not all of ES6 so you'd need an additional transpilation step in between...... |
hahaha actually, we could build |
we (currently) figure that just outputting full on ES6 code there is probably fine for the moment. Note that latest versions of TS allow .js input with |
We're doing the |
So, @robwormald and @jayphelps ... are we currently, then, proposing to moving to build everything out into one package? Basically, what we currently publish to In turn, we'd have one UMD output, and would no longer produce a special AMD bulid? |
that all seems reasonable to me. we don't need a
|
Over on some much less complex libraries than RxJS, we have been doing the same thing as @robwormald explained above, with excellent results. It "just works" and can be consumed without special tooling effort both as commonJS ES5 and ES6 with ES6 modules. Lacking any better plan (and with similar hesitation on the MJS thing) I think this would be an excellent step forward for RxJS. |
+1 there are no great options out there right now, but the keep in mind that there are two kinds of path resolutions going on: 1/ typescript does a resolution when looking for type declarations stored we (angular) opted to not support deep imports except for a few very On Sun, May 29, 2016 at 9:26 AM Kyle Cordes [email protected]
|
@IgorMinar, interesting. I'd there a write up as to why deep imports don't work with bundlers? |
The tldr is that while its easy to remap an entry point file via something like |
@robwormald @IgorMinar so what's actionable out of this issue? Seems like:
Is that it? Related: I also want to stop building the AMD stuff in favor of UMD, and rename the UMD output file to just |
On Thu, Jun 2, 2016 at 10:22 AM Ben Lesh [email protected] wrote:
|
As an expedient way to get the current mechanism easily importable via ES6, one easyish answer is to mechanically create a top level module in the RxJS package which exports a bunch of separate add functions, one for each operator. I think there is a way to shape this file correctly that the packaging mechanism only picks up the specific things you want. So instead of this:
You do this:
? |
that wouldn't work for importing type information for that operator. On Thu, Jun 2, 2016 at 11:50 AM Kyle Cordes [email protected]
|
@robwormald could we codegen remappings for people at build time and distribute it with the package? |
Ah, I had forgotten the very clever type set up. Okay, here are more ideas:
It's not all that bad to look at, and it fits in the ability to have just one "/" in the path.
By this scheme we get two "/" and still have support for node resolution with esnext. Obviously this implies shipping rxjs as a set of packages, like Angular itself. Either of the these things could be generated rather than and coded. This latter model is a bit of a blast the past, it wasn't that many months ago when this was all in scoped packages. I don't know the motivation for moving it back out to a top-level package, but now that Angular itself is in the scope package certainly everyone is going to find them acceptably familiar and all the tooling is going to have to work well enough with them anyway. |
btw TypeScript is very shortly going to support |
Revisiting this... @IgorMinar, can you clarify this statement?
Why will deep imports not work? if |
Because, apparently, that's just the way it is, see: rollup/rollup-plugin-node-resolve#44 What we need is agreement (LO-freaking-L) on a |
FYI, we've implemented this structure in Angular2: index.js (ES5 + ES Modules) package.json:
So far, so good. This allows commonJS users to simply |
The .js files in Our use case was tree shaking out unused We are using the Thanks so much, |
Okay, this is really the last issue blocking release, AFAICT... I feel we have a few options:
Both 2 and 3 still require the change that we should be outputting ES5 code with ES2015 modules. Looking at the npm stats, |
@robwormald wouldn't the plan you outlined above prevent "tree-shaking" and/or encourage usage that would forgo the advantages of modularity in RxJS 5? |
The Ionic team is following suit with what Angular is doing and encouraging others to do the same. What @robwormald is suggesting is the way to go IMO. I am currently producing documentation for library makers on how to get their lib into this state as we have seen a lot of popular Angular libraries still using @Blesh, no it would not because bundlers will read the Thanks, |
After discussing this further IRL, we're not entirely sure of the actual benefits of tree shaking for RxJS itself. RxJS is almost entirely operator based. So let me elaborate. If you import everything a la
|
I randomly saw this issue and got curious... In the Angular 2 docs we use the Is there a practical difference between doing that and targeting released esm source like es-rxjs directly? If there is no practical difference, isn't this easier than publishing two versions of the source? I remember there was an extra step integrating the es-rxjs code with rollup but not too bad at the end of the day though.
|
@jayphelps I think your assessment is correct (at least based on my relatively slim knowledge of Rx) that tree-shaking will provide minimal benefits as things stand.
We do have vague plans to improve the tree-shaking to the level that Rollup is able to remove unused class methods etc, but it's all a bit blue sky at the moment with no actual working code. If it does see the light of day, it won't be for a while. My own inclination if |
@Rich-Harris thanks for the insight! 👍 @thelgevold I don't quite follow what you're suggesting. We would need to publish two versions of the source, both in ES5 but differing module formats CJS/ESM. I think you are prolly referring to npm packages e.g. We may still do it, just wanted to bring up some concerns. |
@jayphelps I was thinking that the commonjs -> esm conversion in the bundler (via plugin) would remove the need for publishing esm at all. Wouldn't it be enough to only publish the commonjs source like in the current rxjs npm package? I might be missing something though :-) |
@thelgevold I think ESM -> CJS -> ESM is a lossy conversion in theory; which is why true tree shaking is only done with ESM and that plugin provides ways for you to "tell it" how to handle ambiguous cases. In practice it |
@jayphelps That makes sense. Thanks for the explenation |
Why? Are they shipping the full contents of |
@jeffbcross #YOLO I've seen this repeatedly with Electron users, not just those using RxJS |
At this point, I'm leaning in favor of just ceasing to publish
|
Would someone be able to regenerate the docs for http://reactivex.io/rxjs/manual/installation.html#es6-via-npm? As of 2017-08-22, it still recommends I just installed rxjs-es (thinking it was still in favor) and stumbled upon this thread and #2218 after TypeScript raised a fit about file name casing. 😅 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
In speaking with @robwormald the Angular folks are forced to swap between
rxjs
andrxjs-es
during their build to enable proper tree-shaking. This is probably less than ideal. If all of the es6 files were under the same directories as.mjs
files, then it would be as easy as configuring the bundler to look at that file extension to use ES6 modules.This would mean that the
rxjs-es
build would likely not have a use anymore.cc/ @IgorMinar @jeffbcross @bradlygreen
The text was updated successfully, but these errors were encountered: