Skip to content

Commit

Permalink
chore: update paperwork
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Dec 5, 2023
1 parent 267348c commit d03b709
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,43 @@ instances.

## Usage

> API Status: `unstable`
Please use the `build.js` file to get a basic idea of the current API, this will
change till the library reaches `0.0.1`
```js
import { createContext } from 'esbuild-multicontext'

const buildContext = createContext()

// Use the helper glob to find files and directories
const entries = await buildContext.glob('./src/*.js', {
filesOnly: true,
})

buildContext.add('esm', {
entryPoints: entries,
outdir: './dist/esm',
format: 'esm',
outExtension: {
'.js': '.mjs',
},
})

buildContext.hook('esm:complete', async () => {
// context built completely
})

buildContext.hook('esm:error', async error => {
// context failed with `error`
})

buildContext.hook('error', async error => {
// multi context build failed
})

// Watch each context and re-build on change
await buildContext.watch()

// Build each context and notify the respective hooks
await buildContext.build()
```

## License

Expand Down

0 comments on commit d03b709

Please sign in to comment.