Skip to content

Commit

Permalink
Docs: add section on (preventing) bundling with esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Mar 12, 2022
1 parent ac18bbb commit 72fd8ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=x64 --platform=linux sharp
To get the best performance select the largest memory available.
A 1536 MB function provides ~12x more CPU time than a 128 MB function.

## Webpack
## Bundlers

Ensure sharp is added to the
### webpack

Ensure sharp is excluded from bundling via the
[externals](https://webpack.js.org/configuration/externals/)
configuration.

Expand All @@ -225,6 +227,25 @@ externals: {
}
```

### esbuild

Ensure sharp is excluded from bundling via the
[external](https://esbuild.github.io/api/#external)
configuration.

```js
buildSync({
entryPoints: ['app.js'],
bundle: true,
platform: 'node',
external: ['sharp'],
})
```

```sh
esbuild app.js --bundle --platform=node --external:sharp
```

## Worker threads

The main thread must call `require('sharp')`
Expand Down
Loading

0 comments on commit 72fd8ab

Please sign in to comment.