question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How could I use async/await in browser with babel6?

See original GitHub issue

babel-core 6.1.21 babel-loader 6.2.0

    module: {
      loaders: [{
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          plugins: ['transform-runtime'],
          presets: ['es2015', 'stage-0', 'stage-3']
        }
      }]
    }

have an error:

Uncaught TypeError: (0 , _typeof3.default) is not a function

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
felipelsguzmancommented, Dec 2, 2015

@liam4 @jtHwong hi guys, in order to use async/await functions with webpack and babel you need to add a babel polyfill in your entry on webpack config, this work on both, nodejs and browser, take a look:

    entry:  ['babel-polyfill', path_to_entry],

    module: {

        loaders: [
            {
                test: /\.js$/,
                loader: 'babel',
                query: {
                    presets: ['es2015', 'stage-0'],
                    plugins: ['transform-runtime']
                }
            },
        ]
    }

this is how is working for me.

0reactions
xgqfrmscommented, Apr 27, 2018

solution

https://esausilva.com/2017/07/11/uncaught-referenceerror-regeneratorruntime-is-not-defined-two-solutions/

https://babeljs.io/docs/usage/polyfill/

OR

https://babeljs.io/docs/plugins/transform-regenerator/


OK

.babelrc


{
    "presets": ["env"]
}

webpack


require("babel-polyfill");

entry: ["babel-polyfill", "./src/backend-system/select-tree"],

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

A guide to through async/await with Babel and Webpack
At first, the JavaScript projects with Webpack ran well. Then I realized that our project should be able to run on an outdated...
Read more >
babel 6 async / await: Unexpected token - Stack Overflow
Just using babel with stage-0 and es2015 preset works for me as long as you import babel-polyfill in your entry point. As BrunoLM...
Read more >
babel/plugin-transform-async-to-generator
Turn async functions into a Bluebird coroutine (caveats) ... When using await with non-promise values, Bluebird will throw "Error: A value was yielded...
Read more >
Add ES7 Async/Await Support for your Webapp in 3 Easy Steps
Step by step guide to add async/await in your build flow.
Read more >
Async await with ES6/Babel and TypeScript - Temple Coding
Using it today with Babel and Webpack ... Async functions are still a proposal for future versions of JavaScript, but it can already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found