Skip to content

Allow to disable regenerator-runtime #3994

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
z-vr opened this issue Feb 8, 2018 · 10 comments
Closed

Allow to disable regenerator-runtime #3994

z-vr opened this issue Feb 8, 2018 · 10 comments

Comments

@z-vr
Copy link

z-vr commented Feb 8, 2018

With the current configuration, async is transpiled into generators. If I have an error in an async function, my VS Code with chrome-debugger extension loads bundle.js and jumps to _asyncToGenerator ... catch (error) { reject(error); return; } ... there which is quite laggy.

Exception has occurred: Error
Error
    at _callee3$ (/Users/anton/Work/abc/src/containers/src.js:125:1)
    at tryCatch (/Users/anton/Work/abc/node_modules/regenerator-runtime/runtime.js:62:1)
    at Generator.invoke [as _invoke] (/Users/anton/Work/campaign-design/node_modules/regenerator-runtime/runtime.js:296:1)
    at Generator.prototype.(anonymous function) [as next] (/Users/anton/Work/abc/node_modules/regenerator-runtime/runtime.js:114:1)
    at step (http://localhost:3000/static/js/bundle.js:93038:191)
    at http://localhost:3000/static/js/bundle.js:93038:361
    at <anonymous>

Since async/await is widely supported, and during development, it's desirable to disable the regenrator runtime.

For anyone interested, you have to update node_modules/babel-preset-react-app/index.js and add

        exclude: [
            'transform-regenerator',
            'transform-async-to-generator',
          ],

at line 113 (babel-preset-env config), then do yarn --force.

This also means I can't set brakepoints at the lines with await keyword which is pretty annoying.

@Timer
Copy link
Contributor

Timer commented Feb 8, 2018

You can try the 2.x alphas which let you specify target browsers. If you target the latest chrome version, your async functions will remain as-is.

@Timer Timer closed this as completed Feb 8, 2018
@z-vr
Copy link
Author

z-vr commented Feb 17, 2018

@Timer if there any more info on how to do that anywhere please?

@Timer
Copy link
Contributor

Timer commented Feb 18, 2018

#3815

@z-vr
Copy link
Author

z-vr commented Feb 19, 2018

@Timer I know you've closed this, but is it possible to have 2 separate configs for dev and prod? Otherwise it's always required to remove "browserlist" from package.json when building.

@z-vr
Copy link
Author

z-vr commented Feb 19, 2018

I think I can do

"browserslist": {
  "development": [
    "last 1 Chrome version"
  ]
}

actually
thanks.

@kyeotic
Copy link

kyeotic commented Apr 20, 2018

@z-vr can you explain where that config goes?

@Timer
Copy link
Contributor

Timer commented Apr 20, 2018

@tyrsius when you start an app with react-scripts 2.0, look in your package.json -- you'll find browserslist there.

@kyeotic
Copy link

kyeotic commented Apr 20, 2018

@Timer Ok, I don't think I have that then. I've ejected and Im trying to figure out how to send this option into babel (or preset-env)

@samdesota
Copy link

I've been fighting this for hours now, it appears "browserslist": { "development": [ "last 1 Chrome version" ] }
Dosen't do anything on the latest create-react-app on linux. Anybody able to reproduce?

@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
@facebook facebook unlocked this conversation Feb 12, 2019
@justingrant
Copy link
Contributor

@mrapogee - Unfortunately the ability to use browsersList to disable regenerator and other polyfills was removed before V2 of CRA was released. Like you, I also wasted a bunch of time before figuring it out that the advice given by @Timer and @z-vr was accurate when they gave it, but it doesn't apply anymore to current CRA2 releases.

If you (like me!) want to see this implemented, @ianschmitz suggested to make #6198 the master issue to track this request. Go there add your votes and ideas!

@facebook facebook locked and limited conversation to collaborators Feb 12, 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

5 participants