Docs: add section on (preventing) bundling with esbuild

This commit is contained in:
Lovell Fuller 2022-03-12 13:17:36 +00:00
parent ac18bbbc7c
commit 72fd8abe2c
2 changed files with 24 additions and 3 deletions

View File

@ -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.
@ -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')`

File diff suppressed because one or more lines are too long