pika-plugin-esbuild
v0.3.5
Published
A @pika/pack plugin: Adds a bundled Web distribution to your package, built & optimized to run in most web browsers (and bundlers).
Downloads
8
Readme
pika-plugin-esbuild
A @pika/pack build plugin. Adds a bundled Web distribution to your package, built & optimized to run in a web browsers. Useful for hosting on a CDN like UNPKG and/or when package dependencies aren't written to run natively on the web. Uses
esbuild
for speed.
Install
# npm:
npm install pika-plugin-esbuild --save-dev
# yarn:
yarn add pika-plugin-esbuild --dev
Usage
{
"name": "example-package-json",
"version": "1.0.0",
"@pika/pack": {
"pipeline": [
["@pika/plugin-standard-pkg"],
["@pika/plugin-build-web"], // Required to precede in pipeline
["pika-plugin-esbuild", { /* esbuild options (optional) */ }]
]
}
}
For more information about @pika/pack & help getting started, check out the main project repo.
Options
This plugin accepts an optional options object which is passed directly to esbuild
. We set some defaults:
"sourcemap"
(Default:"true"
): Adds a source map for this build."minify"
(Default:true
): Specify if bundle should be minifed usingterser
or not. Can also beterser
options object to further tweak minification."target"
(Default:es2017
): The browsers supported/targeted by the build. Defaults to support all browsers that support ES Module (ESM) syntax."entrypoint"
(Default:"browser"
): Customize the package.json manifest entrypoint set by this plugin. Accepts either a string, an array of strings, ornull
to disable entrypoint. Changing this is not recommended for most usage.
Result
- Adds a web bundled distribution to your built package:
dist-web/index.bundled.js
- ES Module (ESM) syntax (by default)
- Transpiled to run on all browsers where ES Module syntax is supported.
- All dependencies inlined into this file.
- Minified using
esbuild
(Can optionally be skipped) - (if specified) Adds the file to your specified "entrypoint".
Note that this does not add or modify the "module" entrypoint to your package.json. Bundles should continue to use the "module" entrypoint, while this build can be loaded directly in the browser (from a CDN like UNPKG).