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

_catch vs catch breaks ESM code built against the rxjs umd bundle #1924

Closed
IgorMinar opened this issue Sep 6, 2016 · 4 comments · Fixed by #1927
Closed

_catch vs catch breaks ESM code built against the rxjs umd bundle #1924

IgorMinar opened this issue Sep 6, 2016 · 4 comments · Fixed by #1927

Comments

@IgorMinar
Copy link
Contributor

IgorMinar commented Sep 6, 2016

RxJS version:
beta.11

Code to reproduce:

import {_catch} from 'rxjs/operator/catch';

full source: https://github.com/angular/angular/blob/ee88c3c976654f15d41f8d35345ad96026fe5fe8/modules/%40angular/router/src/apply_redirects.ts#L14

  • rollup config:
export default {
  entry: '../../../dist/packages-dist/router/index.js',
  dest: '../../../dist/packages-dist/router/bundles/router.umd.js',
  format: 'umd',
  moduleName: 'ng.router',
  globals: {
    ...
    'rxjs/operator/catch': 'Rx.Observable.prototype'
  }
}

full source: https://github.com/angular/angular/blob/ee88c3c976654f15d41f8d35345ad96026fe5fe8/modules/%40angular/router/rollup.config.js#L30

Expected behavior:

the router bundle should be able to get hold of the _catch operator from the prototype via _catch property.

Actual behavior:

the _catch operator is not found because in the UMD bundle it was exported as catch (without the leading underscore).

Additional information:

Angular router bug that first raised this issue: angular/angular#11300
Reproduction: http://plnkr.co/edit/aSPFwbLNxlT5sQzSyGIN?p=preview

@jayphelps
Copy link
Member

For our reference, these are all the operators I could find that would have this problem:

  • _catch
  • _switch
  • _do
  • _finally

@jayphelps
Copy link
Member

@IgorMinar Just so we have all the bases covered with full context, are you not adding the operators to an Observable prototype because you want absolutely no operators on them by default?

@IgorMinar
Copy link
Contributor Author

@jayphelps correct. we don't want loading of Angular's router to have a side-effect of monkey-patching the Observable prototype.

@lock
Copy link

lock bot commented Jun 7, 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 7, 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

Successfully merging a pull request may close this issue.

2 participants