Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Uncaught ReferenceError: regeneratorRuntime is not defined when use async/await #455

Open
lephamduythong opened this issue Jul 2, 2017 · 1 comment

Comments

@lephamduythong
Copy link

lephamduythong commented Jul 2, 2017

When I use "ts-loader" in webpack, it's not happend.
But with "awesome-typescript-loader", it show this error in Chrome console log.

My webpack config:

var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var webpack = require('webpack');

var basePath = __dirname;

module.exports = {
context: path.join(basePath, 'App'),
resolve: {
extensions: ['.js', '.ts', '.tsx']
},
entry: {
app: './index.tsx',
appStyles:'./css/site.css',
vendor: [
'react',
'react-dom',
'react-router',
],
vendorStyles: [
'../node_modules/bootstrap/dist/css/bootstrap.css',
],
},
output: {
path: path.join(basePath, 'wwwroot'),
filename: '[name].js',
},
module: {
rules: [
{
test: /.ts$/,
exclude: [/node_modules/],
loader: 'awesome-typescript-loader',
// loader: 'ts-loader',
options: {
useBabel: true,
},
},
{
test: /.tsx$/,
exclude: [/node_modules/],
loader: 'awesome-typescript-loader',
// loader: 'ts-loader',
options: {
useBabel: true,
},
},
{
test: /.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
],
},
// Loading glyphicons => https://github.com/gowravshekar/bootstrap-webpack
// Using here url-loader and file-loader
{
test: /.(woff|woff2)(?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /.ttf(?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
},
{
test: /.eot(?v=\d+.\d+.\d+)?$/,
loader: 'file-loader'
},
{
test: /.svg(?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
},
],
},
// For development https://webpack.js.org/configuration/devtool/#for-development
devtool: 'inline-source-map',
plugins: [
//Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html', //Name of file in ./dist/
template: 'index.html', //Name of template in ./src
hash: true,
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest'],
}),
],
};

My tsconfig file:

{
"compilerOptions": {
"target": "es6",
"module": "es6",
"moduleResolution": "node",
"declaration": false,
"noImplicitAny": false,
"sourceMap": true,
"jsx": "react",
"noLib": false,
"suppressImplicitAnyIndexErrors": true
},
"compileOnSave": false,
"exclude": [
"node_modules"
]
}

My code:

var longProcess = () => {
let result = 0;
return new Promise((resolve, reject) => {
setTimeout(()=> {
for (let i = 0; i <= 250000000 - 1; i++) {
result++;
}
resolve(result);
},0);
});
}

async function processAsync() {
console.log('Start 1');
let result1 = await longProcess().then((res) => console.log(res));
console.log('End 1');
console.log('Start 2');
let result2 = await longProcess().then((res) => console.log(res));
console.log('End 2');
}

processAsync();

console.log("End");

@charandas
Copy link

charandas commented Oct 18, 2017

Duplicate of #169

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