Registry / devops / grunt-esbuild

grunt-esbuild

JSON →
library1.0.1jsnpmunverified

Grunt plugin to run esbuild builds. Version 1.0.0+ actively maintained. Configuration is passed directly to esbuild's build function, which must be provided via options.buildFunction. Unlike other Grunt bundler plugins, it does not wrap esbuild's API, giving full access to esbuild options. Requires Node.js and a compatible Grunt >=1. Releases are irregular; no known breaking changes yet.

npm install grunt-esbuild
INSTALL
IMPORT
SIG · GRUNT-ESBUILD
G
grunt-esbuild
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

grunt-esbuild
grunt.loadNpmTasks('grunt-esbuild') or use load-grunt-tasks
const esbuild = require('grunt-esbuild')
This is a Grunt plugin, not a Node module. It should be loaded via grunt.loadNpmTasks or a task loader like load-grunt-tasks.
buildFunction
options: { buildFunction: require('esbuild').build }
options: { buildFunction: esbuild.build } (if esbuild is not required correctly)
esbuild must be required and its .build method passed explicitly. Do not pass the entire esbuild object.
task config
grunt.initConfig({ esbuild: { dist: { entryPoints: ['src/main.js'], bundle: true } } })
grunt.initConfig({ esbuild: { dist: { entryPoints: 'src/main.js' } } }) (string instead of array)
entryPoints should be an array of strings, not a single string.

Configure Grunt to run esbuild with a single bundle target.

// Gruntfile.js module.exports = function(grunt) { require('load-grunt-tasks')(grunt); grunt.initConfig({ esbuild: { options: { buildFunction: require('esbuild').build }, dist: { entryPoints: ['src/main.js'], bundle: true, outfile: 'dist/main.js', } } }); grunt.registerTask('default', ['esbuild']); };
Debug
Known issues
gotchabuildFunction is required: you must pass require('esbuild').build in options.
fix
Set options.buildFunction to require('esbuild').build in your Gruntfile.
affects: >=0
gotchaEntry points must be an array, even for a single file.
fix
Use entryPoints: ['src/main.js'] instead of entryPoints: 'src/main.js'.
affects: >=0
gotchaThe plugin does not support esbuild's watch mode or incremental builds.
fix
Use a separate watch task (e.g., grunt-contrib-watch) to trigger rebuilds.
affects: >=0
Errors
Common errors & fixes
Warning: Task "esbuild" not found.
grunt-esbuild not loaded correctly.
fix
Add grunt.loadNpmTasks('grunt-esbuild') or use load-grunt-tasks in Gruntfile.
TypeError: options.buildFunction is not a function
buildFunction not set or set incorrectly.
fix
Set options.buildFunction = require('esbuild').build in grunt.initConfig.
Error: Invalid entry point. Must be an array of strings.
entryPoints is a string instead of an array.
fix
Change entryPoints: 'src/main.js' to entryPoints: ['src/main.js'].
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
gruntrequiredPeer dependency: requires Grunt >=1 as task runner
esbuildrequiredPeer dependency: must be installed separately and passed via options.buildFunction
Agent activity
4 hits · last 30 days
node
4
Resources
grunt-esbuild — npm install grunt-esbuild · libregistry