Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/developit/preact-cli-plugin-async
Preact CLI plugin that adds converts async/await to Promises.
https://github.com/developit/preact-cli-plugin-async
async async-await preact preact-cli preact-cli-plugin
Last synced: 28 days ago
JSON representation
Preact CLI plugin that adds converts async/await to Promises.
- Host: GitHub
- URL: https://github.com/developit/preact-cli-plugin-async
- Owner: developit
- Created: 2017-12-13T17:05:22.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-08T21:01:53.000Z (over 4 years ago)
- Last Synced: 2024-10-05T04:08:26.657Z (about 1 month ago)
- Topics: async, async-await, preact, preact-cli, preact-cli-plugin
- Language: JavaScript
- Homepage: https://npm.im/preact-cli-plugin-async
- Size: 36.1 KB
- Stars: 44
- Watchers: 5
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# preact-cli-plugin-async
[![npm](https://img.shields.io/npm/v/preact-cli-plugin-async.svg)](https://npm.im/preact-cli-plugin-async) [![travis](https://travis-ci.org/developit/preact-cli-plugin-async.svg?branch=master)](https://travis-ci.org/developit/preact-cli-plugin-async) [![greenkeeper](https://badges.greenkeeper.io/developit/preact-cli-plugin-async.svg)](https://greenkeeper.io/)
[Preact CLI] plugin that adds optimized support for async/await via [fast-async].
> **Note:** this is now just a copy of [preact-cli-plugin-fast-async](https://github.com/plusCubed/preact-cli-plugin-fast-async) by [@plusCubed](https://github.com/pluscubed).
## Why do I want this?
ormally, transpiling async/await produces a large amount of code and depends on a runtime like `regenerator-runtime`. While that is optimal from a compatibility standpoint, it's not so great for bundle size. Using [fast-async], this plugin transforms your async functions into Promises just like you would write by hand!
It transforms this:
```js
async () => await (await fetch('/')).text()
```... to something that roughly looks like this:
```js
function () {
return Promise.resolve().then(function() {
return fetch("/")
}).then(function(e) {
return e.text()
})
}
```Pretty great, right?
## Installation
```bash
npm i -D preact-cli-plugin-async
```... then include it in your project by creating a `preact.config.js`:
```js
import asyncPlugin from 'preact-cli-plugin-async';export default (config) => {
asyncPlugin(config);
}
```## License
MIT
Original version © [developit](https://github.com/developit)
Current fast-async version © [Daniel Ciao](https://github.com/pluscubed)[Preact CLI]: https://github.com/developit/preact-cli
[fast-async]: https://github.com/MatAtBread/fast-async