Skip to content

Commit 58b24ed

Browse files
committed
support async plugin "setup" (#111)
1 parent 274d347 commit 58b24ed

File tree

4 files changed

+266
-166
lines changed

4 files changed

+266
-166
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616

1717
With this release, esbuild will now ignore the `override` keyword when parsing TypeScript code instead of treating this keyword as a syntax error, which means esbuild can now support TypeScript 4.3 syntax. This change was contributed by [@g-plane](https://github.com/g-plane).
1818

19+
* Allow `async` plugin `setup` functions
20+
21+
With this release, you can now return a promise from your plugin's `setup` function to delay the start of the build:
22+
23+
```js
24+
let slowInitPlugin = {
25+
name: 'slow-init',
26+
async setup(build) {
27+
// Delay the start of the build
28+
await new Promise(r => setTimeout(r, 1000))
29+
},
30+
}
31+
```
32+
33+
This is useful if your plugin needs to do something asynchronous before the build starts. For example, you may need some asynchronous information before modifying the `initialOptions` object, which must be done before the build starts for the modifications to take effect.
34+
1935
## 0.11.4
2036

2137
* Avoid name collisions with TypeScript helper functions ([#1102](https://github.com/evanw/esbuild/issues/1102))

0 commit comments

Comments
 (0)