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

Unnecessary polyfilling + wrongly renaming imports #42

Closed
anilanar opened this issue Nov 25, 2020 · 4 comments
Closed

Unnecessary polyfilling + wrongly renaming imports #42

anilanar opened this issue Nov 25, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@anilanar
Copy link

anilanar commented Nov 25, 2020

I babelify + auto polyfill node_modules too; because it's usually unclear what ES version+browser libraries target nowadays. After switching to babel-polyfills (corejs3), one curious case failed.

For esm5/esm2015 builds of rxjs@6.6.3; in node_modules/rxjs/_esm5/index.js:

  • babel-polyfills adds import _Observable from "core-js-pure/features/observable/index.js"; at the top of the file.
  • then replaces some (or all) occurences of the term Observable with _Observable.
  • rxjs has a re-export export { Observable } from './internal/Observable';. babel-polyfills replaces that with export { _Observable as Observable } from './internal/Observable';
  • bundler rightfully complains that there's no _Observable in ./internal/Observable.

I see two problems here:

  1. Why polyfill Observable in this case? Observable is imported (or re-exported) from somewhere, it's not the global Observable.
  2. Even if it polyfills, why break the imports?
@nicolo-ribaudo nicolo-ribaudo added the bug Something isn't working label Nov 25, 2020
@anilanar
Copy link
Author

It's actually the proposals flag that causes the issue (because Observable is a proposal), which is broken for @babel/plugin-transform-runtime too.

@nicolo-ribaudo
Copy link
Member

Thanks for the bug report! It turns out this is not only for proposals, but it was a generic bug with export ... from.

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Nov 27, 2020

This will be fixed when babel/babel#12395 is released. In the meaintinme, you can exclude that file by adding ignore: ["node_modules/rxjs/_esm5/index.js"] to your Babel config.

PS. Thanks for reporting these bugs!

@nicolo-ribaudo
Copy link
Member

Fixed in @babel/types@7.12.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants