-
-
Save wubin1989/b7165afa8b8fb12d03d9a7e4f8e6228b to your computer and use it in GitHub Desktop.
async/await with webpack+babel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["es2015"], | |
"plugins": ["transform-async-to-generator"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function foo() { | |
console.log('async working!') | |
} | |
async function bar() { | |
await foo() | |
console.log('after foo') | |
} | |
bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "async-await", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "MIT", | |
"devDependencies": { | |
"babel-loader": "^6.2.2", | |
"babel-plugin-transform-async-to-generator": "^6.5.0", | |
"babel-polyfill": "^6.5.0", | |
"babel-preset-es2015": "^6.5.0", | |
"webpack": "^1.12.13" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
entry: ['babel-polyfill', './index.js'], | |
output: { | |
filename: 'bundle.js' | |
}, | |
devtool: 'sourcemap', | |
module: { | |
loaders: [{ | |
test: /\.js?$/, | |
exclude: /(node_modules)/, | |
loader: 'babel' | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment