https://github.com/m90/esbuild-plugin-browserify-adapter
Use Browserify transforms as esbuild plugins
https://github.com/m90/esbuild-plugin-browserify-adapter
browserify browserify-transform esbuild esbuild-plugin
Last synced: 3 months ago
JSON representation
Use Browserify transforms as esbuild plugins
- Host: GitHub
- URL: https://github.com/m90/esbuild-plugin-browserify-adapter
- Owner: m90
- License: mpl-2.0
- Created: 2021-02-07T09:36:41.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-17T17:38:46.000Z (over 2 years ago)
- Last Synced: 2025-03-16T01:29:09.339Z (3 months ago)
- Topics: browserify, browserify-transform, esbuild, esbuild-plugin
- Language: JavaScript
- Homepage:
- Size: 361 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# esbuild-plugin-browserify-adapter
Use [Browserify transforms](https://github.com/browserify/browserify-handbook#transforms) as [esbuild plugins](https://esbuild.github.io/plugins/).
## Installation
The package is released to npm as `esbuild-plugin-browserify-adapter`:
```
npm install esbuild-plugin-browserify-adapter -D
```## Usage
This adapter lets you use any existing Browserify transform as an esbuild plugin. The plugin function can be passed an arbitrary number of transforms. Just like with Browserify itself, options are passed by wrapping the transform in an array and appending the options to that list.
__Please note: This module does not work with Browserify plugins.__
### Basic usage
```js
const esbuild = require('esbuild')
const coffeeify = require('coffeeify') // any transform works
const browserifyAdapter = require('esbuild-plugin-browserify-adapter')esbuild.build({
entryPoints: ['./app.coffee'],
bundle: true,
plugins: [browserifyAdapter(coffeeify)],
outdir: './public'
})
```### Passing options
```js
const esbuild = require('esbuild')
const envify = require('envify') // any transform works
const browserifyAdapter = require('esbuild-plugin-browserify-adapter')esbuild.build({
entryPoints: ['./app.js'],
bundle: true,
plugins: [browserifyAdapter([envify, { BUNDLE_TIME: new Date().toJSON() }])],
outdir: './public'
})
```### Passing multiple transforms
In case you need to use multiple transforms, pass all of them to the adapter at once. Just like in Browserify, they will be run in the order given.
```js
const esbuild = require('esbuild')
const coffeeify = require('coffeeify') // any transform works
const envify = require('envify') // any transform works
const browserifyAdapter = require('esbuild-plugin-browserify-adapter')esbuild.build({
entryPoints: ['./app.coffee'],
bundle: true,
plugins: [browserifyAdapter(
coffeeify,
[envify, { BUNDLE_TIME: new Date().toJSON() }]
)],
outdir: './public'
})
```## Why?
This plugin can help you with gradually migrating a Browserify-based setup to an esbuild-based one without having to change everything at once. It is not intended to be used as a permanent solution unless your transform usage is very limited.
---
## Releasing a new version
New versions can be released using `npm version `.
## License
Copyright 2021 Frederik Ring - Available under the Mozilla Public License 2.0