Skip to content

babel-preset-react-app doesn't transpile Object.values #5012

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

Closed
3stacks opened this issue Sep 14, 2018 · 4 comments
Closed

babel-preset-react-app doesn't transpile Object.values #5012

3stacks opened this issue Sep 14, 2018 · 4 comments

Comments

@3stacks
Copy link

3stacks commented Sep 14, 2018

Is this a bug report?

yes

Did you try recovering your dependencies?

yep

Which terms did you search for in User Guide?

I searched through the babel-preset-react-app documentation and source looking for config options etc

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 10.9.0
Yarn: 1.9.4
npm: 6.2.0
Watchman: Not Found
Xcode: Not Found
Android Studio: Not Found

Packages: (wanted => installed)
react: ^16.5.1 => 16.5.1
react-dom: ^16.5.1 => 16.5.1

Steps to Reproduce

demonstration: https://github.com/3stacks/but-why

  1. Clone repository
  2. yarn install
  3. yarn build
  4. Go to build/static/js/main.xxx.js
  5. Search for "Object.values"

Expected Behavior

It should be transpiling es2017 features. Or if it doesn't by default, it should listen to my browserslist query and support the version of IE I defined, therefore transpiling object.values

Actual Behavior

It spat out Object.values in the built verison.

@gaearon
Copy link
Contributor

gaearon commented Sep 14, 2018

A Babel preset isn't expected to fill in runtime features. It's not even possible to do reliably automatically unless you always bring in a polyfill.

It's meant to provide support for syntax. It's on you to choose the polyfills for your environment.

@gaearon gaearon closed this as completed Sep 14, 2018
@3stacks
Copy link
Author

3stacks commented Sep 14, 2018

Thanks for the info, is this what I'm looking for? https://babeljs.io/docs/en/babel-plugin-transform-runtime

@gaearon
Copy link
Contributor

gaearon commented Sep 14, 2018

Stuff like this is not reliable. For example

const o = Object
o.values(); // babel can't find it

If you need to polyfill, do it by importing a polyfill — not via a transform.

@3stacks
Copy link
Author

3stacks commented Sep 14, 2018

Oh right, gotcha. Thanks for pointing me in the right direction

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
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

2 participants