Registry / devops / esbuild-plugin-shelljs

esbuild-plugin-shelljs

JSON →
library1.1.2jsnpmunverified

Esbuild plugin to patch shelljs at build time, making it compatible with esbuild by adding missing `.js` extensions to dynamic imports. Current version 1.1.2. Release cadence is low, as the plugin is stable. Key differentiator: solves a specific esbuild + shelljs bundling issue (extensions) without forking or modifying shelljs source. Alternatives: using `require('shelljs')` in Node.js or bundling with other tools like Webpack, but this plugin integrates cleanly into esbuild's plugin system.

npm install esbuild-plugin-shelljs
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-SHE
E
esbuild-plugin-shelljs
devopsjavascriptv1.1.2
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.

shellJsPlugin
import { shellJsPlugin } from 'esbuild-plugin-shelljs'
import shellJsPlugin from 'esbuild-plugin-shelljs'
This is a named export, not default. Also works with require: const { shellJsPlugin } = require('esbuild-plugin-shelljs').
require('esbuild-plugin-shelljs')
const { shellJsPlugin } = require('esbuild-plugin-shelljs')
const shellJsPlugin = require('esbuild-plugin-shelljs')
CommonJS require only works if you destructure the named export.
default import
import { shellJsPlugin } from 'esbuild-plugin-shelljs'
import shellJsPlugin from 'esbuild-plugin-shelljs'
There is no default export; only named.

Demonstrates basic usage of the shellJsPlugin in an esbuild build script to resolve shelljs dependencies.

import { shellJsPlugin } from 'esbuild-plugin-shelljs'; import esbuild from 'esbuild'; import shelljs from 'shelljs'; await esbuild.build({ entryPoints: ['src/index.js'], bundle: true, outfile: 'out/bundle.js', plugins: [shellJsPlugin], }); // Your code that uses shelljs (e.g., shelljs.ls('.')) will now bundle correctly.
Debug
Known issues
gotchaPlugin only patches shelljs's own dynamic imports; does not fix other packages with missing extensions.
fix
For other packages, consider a generic esbuild-ignore or resolve alias.
affects: >=1.0.0
deprecatedRequires esbuild 0.9+ (uses `onResolve` and `onLoad` hooks).
fix
Ensure esbuild version is >= 0.9.
affects: >=1.0.0
gotchaIf shelljs is installed as devDependency or not installed at all, the plugin will fail to find shelljs path.
fix
Add shelljs as a dependency (npm install shelljs).
affects: >=1.0.0
Errors
Common errors & fixes
Error: Module not found in bundle: ./src/cat
shelljs uses dynamic imports without file extensions; esbuild cannot resolve them.
fix
Use the esbuild-plugin-shelljs plugin to patch shelljs.
Cannot find module 'shelljs'
shelljs is not installed or not in node_modules.
fix
Run npm install shelljs (or ensure it's in package.json).
TypeError: shellJsPlugin is not a function
Incorrect import: default import used instead of named import.
fix
Use import { shellJsPlugin } from 'esbuild-plugin-shelljs' (named export).
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency; plugin hooks into esbuild build process
shelljsrequiredpeer dependency; the package being patched
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-shelljs — npm install esbuild-plugin-shelljs · libregistry