Skip to content

Commit 3732344

Browse files
committed
Merge branch 'plusCubed-master'
2 parents 016f1fa + 9df87ec commit 3732344

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
[![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/)
44

5-
[Preact CLI] plugin that adds optimized support for async/await via [Kneden].
5+
[Preact CLI] plugin that adds optimized support for async/await via [fast-async].
66

7+
> **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).
78
89
## Why do I want this?
910

10-
Normally, 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 Kneden, this plugin transforms your async functions into Promises just like you would write by hand!
11+
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!
1112

1213
It transforms this:
1314

1415
```js
1516
async () => await (await fetch('/')).text()
1617
```
1718

18-
... to this:
19+
... to something that roughly looks like this:
1920

2021
```js
2122
function () {
@@ -27,8 +28,7 @@ function () {
2728
}
2829
```
2930

30-
Pretty great, right?
31-
31+
Pretty great, right?
3232

3333
## Installation
3434

@@ -49,7 +49,9 @@ export default (config) => {
4949

5050
## License
5151

52-
MIT © [developit](https://github.com/developit)
52+
MIT
53+
Original version © [developit](https://github.com/developit)
54+
Current fast-async version © [Daniel Ciao](https://github.com/pluscubed)
5355

5456
[Preact CLI]: https://github.com/developit/preact-cli
55-
[Kneden]: https://github.com/babel/kneden
57+
[fast-async]: https://github.com/MatAtBread/fast-async

async-plugin.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ export default function asyncPlugin(config) {
22
let babel = config.module.loaders.filter(loader => loader.loader === 'babel-loader')[0].options;
33

44
// Blacklist regenerator within env preset:
5-
babel.presets[0][1].exclude.push(
6-
'transform-async-to-generator'
7-
);
5+
babel.presets[0][1].exclude.push('transform-async-to-generator');
86

9-
// Add missing plugin syntax, until new patch for (developit/preact-cli#461)
10-
babel.plugins.push('syntax-dynamic-import');
11-
12-
// Add Kneden
13-
babel.plugins.push(require.resolve('babel-plugin-async-to-promises'));
7+
// Add fast-async
8+
babel.plugins.push([require.resolve('fast-async'), { spec: true }]);
149
}

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "preact-cli-plugin-async",
3-
"version": "1.0.0",
4-
"description": "Preact CLI plugin that adds optimized support for async/await via Kneden.",
2+
"name": "preact-cli-plugin-fast-async",
3+
"version": "1.0.1",
4+
"description": "Preact CLI plugin that adds support for async/await via fast-async",
55
"main": "dist/async-plugin.js",
66
"source": "async-plugin.js",
77
"scripts": {
@@ -19,7 +19,11 @@
1919
"preact-cli",
2020
"preact cli plugin"
2121
],
22-
"author": "Jason Miller <jason@developit.ca> (http://jasonformat.com)",
22+
"author": "Daniel Ciao <pluscubed@gmail.com> (http://pluscubed.com)",
23+
"contributors": [
24+
"Jason Miller <jason@developit.ca> (http://jasonformat.com)"
25+
],
26+
"repository": "pluscubed/preact-cli-plugin-fast-async",
2327
"license": "MIT",
2428
"devDependencies": {
2529
"bundlesize": "^0.15.3",
@@ -29,6 +33,6 @@
2933
"preact-cli": "^2.1.0"
3034
},
3135
"dependencies": {
32-
"babel-plugin-async-to-promises": "^1.0.5"
36+
"fast-async": "^6.3.0"
3337
}
3438
}

0 commit comments

Comments
 (0)