Registry / devops / gulp-esbuild

gulp-esbuild

JSON →
library0.14.1jsnpmunverified

The `gulp-esbuild` package provides a Gulp plugin that integrates the high-performance `esbuild` bundler into Gulp-based build workflows. It allows developers to efficiently bundle, minify, and transform JavaScript and TypeScript assets as part of their Gulp pipelines, leveraging `esbuild`'s speed. The current stable version is 0.14.1, and the package frequently releases updates, often in response to breaking changes in the upstream `esbuild` library. A key feature is the ability to enable `esbuild`'s incremental build mode via the `createGulpEsbuild` factory function, which significantly speeds up rebuilds during development when combined with Gulp's `watch` API. Unlike direct `esbuild` usage, `gulp-esbuild` is designed to work with Gulp's virtual file streams, but it has a specific limitation: all input files specified in `gulp.src()` must physically exist on the filesystem, even if their contents are subsequently modified by earlier Gulp pipeline steps.

npm install gulp-esbuild
INSTALL
IMPORT
SIG · GULP-ESBUILD
G
gulp-esbuild
devopsjavascriptv0.14.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gulpEsbuild
import gulpEsbuild from 'gulp-esbuild';
import { gulpEsbuild } from 'gulp-esbuild'; const gulpEsbuild = require('gulp-esbuild').gulpEsbuild;
The main plugin function for non-incremental builds. In ESM, it is the default export. In CommonJS, it's the direct `module.exports` from `require("gulp-esbuild")`.
createGulpEsbuild
import { createGulpEsbuild } from 'gulp-esbuild';
import createGulpEsbuild from 'gulp-esbuild'; const createGulpEsbuild = require('gulp-esbuild');
Used to create an instance of the plugin that supports esbuild's incremental builds. This is a named export, available for both ESM and CommonJS.
BuildOptions
import type { BuildOptions } from 'esbuild';
import type { BuildOptions } from 'gulp-esbuild';
For type-checking the configuration object passed to gulp-esbuild, it is essential to import `BuildOptions` directly from the `esbuild` package, as `gulp-esbuild` expects compatible options.

Demonstrates how to bundle a TypeScript file (`index.tsx`) using `gulp-esbuild` into a single JavaScript file (`bundle.js`) and output it to the `dist` directory, including minification and sourcemaps.

import { src, dest } from 'gulp'; import gulpEsbuild from 'gulp-esbuild'; /** * Gulp task to build a TypeScript application using gulp-esbuild. * It bundles 'index.tsx', configures esbuild for bundling and TSX loading, * and outputs the result to 'dist/bundle.js'. */ function build() { return src('./index.tsx') .pipe(gulpEsbuild({ outfile: 'bundle.js', bundle: true, loader: { '.tsx': 'tsx' }, minify: true, sourcemap: 'external' })) .pipe(dest('./dist')); } export { build }; // To run: `npx gulp build` (assuming 'gulp' is installed globally or via npx)
Debug
Known issues
breakingSince v0.14.0, `esbuild` is a peer dependency of `gulp-esbuild` and must be installed separately. Failing to do so will result in module not found errors during runtime.
fix
Run `npm install gulp-esbuild esbuild` or `yarn add gulp-esbuild esbuild` to ensure both packages are installed.
affects: >=0.14.0
breakingThe `pipe` flag, previously used to enable processing of virtual files, was removed in v0.13.0. The plugin now automatically handles both file system files and virtual files by default.
fix
Remove the `{ pipe: true }` option from any calls to `createGulpEsbuild`. The `createGulpEsbuild` function itself is still necessary for enabling incremental builds.
affects: >=0.13.0
gotchaWhen processing files with `src(...).pipe(gulpEsbuild(...))`, every file passed to `src` must physically exist on the file system, even if its content is overridden by Gulp's virtual file stream. This is a limitation stemming from `esbuild`'s architecture.
fix
Ensure all source files specified in `gulp.src()` exist on disk. For dynamically generated content, consider writing it to a temporary file before passing it to `gulp-esbuild`.
affects: >=0.1.0
breakingMajor releases of `esbuild` frequently introduce breaking changes to its API. `gulp-esbuild` often reflects these changes, requiring updates to `esbuild` options or configuration in your `gulpfile`.
fix
Consult the `esbuild` release notes (often linked in `gulp-esbuild` changelogs) and update your `esbuild` configuration options accordingly after upgrading `gulp-esbuild`.
affects: >=0.11.0
gotchaTo enable `esbuild`'s incremental build feature for faster rebuilds during development (e.g., with `gulp.watch`), you must use the `createGulpEsbuild` factory function with `{ incremental: true }`. The default `gulpEsbuild` export does not support incremental builds.
fix
Import `createGulpEsbuild` and instantiate the plugin with `const gulpEsbuildInstance = createGulpEsbuild({ incremental: true });` then use `gulpEsbuildInstance` in your pipeline.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild'
The 'esbuild' package is a peer dependency of 'gulp-esbuild' and was not installed alongside it.
fix
Install esbuild alongside gulp-esbuild: `npm install esbuild gulp-esbuild` or `yarn add esbuild gulp-esbuild`.
Error: Unknown option: 'pipe'
The 'pipe' option was removed from `gulp-esbuild` in v0.13.0.
fix
Remove the `{ pipe: true }` option from your `createGulpEsbuild` configuration. The plugin now handles both file system and virtual files by default.
esbuild: Could not resolve './some-virtual-file.js' (or similar file not found error)
The input file passed to `gulp-esbuild` via `gulp.src()` does not physically exist on the file system, which is a requirement for `esbuild`'s operation even when processing virtual file contents.
fix
Ensure that all files processed by `gulp-esbuild` (i.e., those passed into `gulp.src()`) have a corresponding physical file on disk. If generating content virtually, write it to a temporary file first.
Upgrade
Version history
0.14.1latest on npm
Audit
Dependencies
esbuildrequiredRequired peer dependency for the core bundling functionality. Must be installed alongside gulp-esbuild.
Agent activity
6 hits · last 30 days
node
6
Resources