Esbuild Plugin Transform • Pipe transformation plugin for esbuild.
Install
$ npm i @chialab/esbuild-plugin-transform -D
$ yarn add @chialab/esbuild-plugin-transform -D
Usage
import esbuild from 'esbuild';
import transform from '@chialab/esbuild-plugin-transform';
await esbuild.build({
plugins: [
transform([
]),
],
});
Create a plugin
First of all, install Esbuild Plugin Transform:
npm i @chialab/esbuild-plugin-transform
Then, use module helpers to retrieve contents and mappings:
import { getEntry, finalizeEntry, createFilter } from '@chialab/esbuild-plugin-transform';
async function transform(code, map) {
...
}
export default {
name: '...',
setup(build) {
build.onLoad({ filter: createFilter(build), namespace: 'file' }, async (args) => {
const entry = await getEntry(build, args.path);
const { code, map } = await transform(entry.code);
return finalizeEntry(entry, {
code,
map,
loader: 'js',
});
});
},
};
License
Esbuild Plugin Transform is released under the MIT license.