Skip to content
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

rxjs-es es5 code with es2015 modules #1925

Closed
danbucholtz opened this issue Sep 6, 2016 · 10 comments
Closed

rxjs-es es5 code with es2015 modules #1925

danbucholtz opened this issue Sep 6, 2016 · 10 comments

Comments

@danbucholtz
Copy link

The .js files in rxjs-es contain es2015 code (let, const, arrow functions, etc). The es2015 module declarations are great for tree shaking but the code needs to be transpiled to es5 to be used by most browsers/apps.

My use case was tree shaking out unused rxjs stuff from an Angular 2 library (Ionic Framework).

I reached out to Ben Lesh and he asked me to create an issue and link to the twitter discussion.

Thanks so much,
Dan

@jayphelps
Copy link
Member

This very much is related to any action we would take in #1671 as well but not sure if there was a final verdict from there.

That said, I believe the goal of rxjs-es was indeed to just be ES5.1 w/ ES6 modules, but it wasn't specifically stated AFAICT so this just wasn't thought about and not noticed because the angular peeps must have been running the code through a compiler that understood all ES6 features.

@danbucholtz
Copy link
Author

Thanks @jayphelps,

I will close this issue and post my comment there.

Thanks,
Dan

@imcotton
Copy link
Contributor

imcotton commented Oct 5, 2016

I think #1671 is talking about using rxjs to serve both CMD CJS / UMD / ESM all at one place, while on the other hand, that rxjs-es could just change to provide ES5 w/ ESM in next tag publish, which we could start to use right away.

They couldn't do this right now because the building facility still using TypeScript 1.8, which has to be upgrade to TypeScript v2 in order to generate ES5 code w/ ESM, that's PR #1968 currently on hold with other matter depends on merging.

It'd be really helpful to have ES5 w/ ESM for Angular 2 users (or ES6 devs), because:

  1. Angular 2 shipped by ES5 w/ ESM as default and its EventEmitter is extending Subject from rxjs
  2. you couldn't get Angular 2 code running without first transpiling rxjs-es by Babel or Bublé etc., because ES6 Class couldn't subclassing by ES5 code
  3. you can't therefor to use CMD CJS bundle of rxjs because ESM is what Rollup alike needs for tree-shaking

Right now during development stage, it really helps to use ES6 code without transpiler since it's perfectly fine to run in most browser, so as an experimental you could:

  • have this repo cloned locally
  • change TypeScript version to v2
  • modify npm script compile_dist_es6 to -m es6 -t es5 --lib dom,es2017 and run
  • link dist folder as new rxjs-es into node_modules inside your project

With setup above, everything works great.
So before #1671 getting settled down, could we have rxjs-es to have ES5 w/ ESM first? (and reopen this issue along)

@danbucholtz
Copy link
Author

I agree with @imcotton.

Thanks,
Dan

@benlesh
Copy link
Member

benlesh commented Oct 5, 2016

I'm reopening this. I consider it a bug that it's not ES5 with ES2015 modules

@benlesh benlesh reopened this Oct 5, 2016
@danbucholtz
Copy link
Author

danbucholtz commented Oct 5, 2016

@Blesh,

I think it'd be ideal if rxjs-es was completely es2015, and then rxjs took advantage of the module or jsnext:main options to provide es5 code with es2015 import/exports. By keeping rxjs-es 100% es2015, it is easier to minify by using property renaming if someone was interested in going down that route.

That way, for all of the Angular projects that depend on rxjs set-up, they'll switch over automatically (more than likely) to use the es5 code with es2015 modules, and tree shaking will work.

Thanks,
Dan

@benlesh
Copy link
Member

benlesh commented Oct 5, 2016

I think it'd be ideal if rxjs-es was completely es2015, and then rxjs took advantage of the module or jsnext:main options to provide es5 code with es2015 import/exports. By keeping rxjs-es 100% es2015, it is easier to minify by using property renaming if someone was interested in going down that route.

I think the primary use-case for most people is having modules with es5 code for bunding and tree-shaking purposes. The minification angle is interesting, but seems edge-casey.

@jayphelps
Copy link
Member

We decided collective to stop publishing rxjs-es for now, and revisit publishing ES modules and/or entire ES6 code for future releases. We want to unblock v5 release and it's easier to publish something later than to commit to something for 5.0.0 and then change our minds. My gut tells me at the very least we'll publish ES modules somehow in the coming months, at the very least so we don't keep asked about it and tooling that expects it "just works".

@kwonoj
Copy link
Member

kwonoj commented Apr 16, 2017

I believe issue itself is explained adequately, that we do no longer publish rxjs-es module issue itself does not exists anymore. As discussed in #2335 there are possibly lot of confusions of bringing es2015 modules package without finalized spec, while benefit is nearly non exist such as tree shaking's not working with Rx's codebase. This whole issue of publish native ES modules will be revisted with release planning once later.

@kwonoj kwonoj closed this as completed Apr 16, 2017
@lock
Copy link

lock bot commented Jun 6, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants