{"id":25407,"library":"esbuild-plugin-shelljs","title":"esbuild-plugin-shelljs","description":"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.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install esbuild-plugin-shelljs","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-shelljs","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-shelljs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin hooks into esbuild build process","package":"esbuild","optional":false},{"reason":"peer dependency; the package being patched","package":"shelljs","optional":false}],"imports":[{"note":"This is a named export, not default. Also works with require: const { shellJsPlugin } = require('esbuild-plugin-shelljs').","wrong":"import shellJsPlugin from 'esbuild-plugin-shelljs'","symbol":"shellJsPlugin","correct":"import { shellJsPlugin } from 'esbuild-plugin-shelljs'"},{"note":"CommonJS require only works if you destructure the named export.","wrong":"const shellJsPlugin = require('esbuild-plugin-shelljs')","symbol":"require('esbuild-plugin-shelljs')","correct":"const { shellJsPlugin } = require('esbuild-plugin-shelljs')"},{"note":"There is no default export; only named.","wrong":"import shellJsPlugin from 'esbuild-plugin-shelljs'","symbol":"default import","correct":"import { shellJsPlugin } from 'esbuild-plugin-shelljs'"}],"quickstart":{"code":"import { shellJsPlugin } from 'esbuild-plugin-shelljs';\nimport esbuild from 'esbuild';\nimport shelljs from 'shelljs';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'out/bundle.js',\n  plugins: [shellJsPlugin],\n});\n\n// Your code that uses shelljs (e.g., shelljs.ls('.')) will now bundle correctly.","lang":"javascript","description":"Demonstrates basic usage of the shellJsPlugin in an esbuild build script to resolve shelljs dependencies."},"warnings":[{"fix":"For other packages, consider a generic esbuild-ignore or resolve alias.","message":"Plugin only patches shelljs's own dynamic imports; does not fix other packages with missing extensions.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure esbuild version is >= 0.9.","message":"Requires esbuild 0.9+ (uses `onResolve` and `onLoad` hooks).","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Add shelljs as a dependency (npm install shelljs).","message":"If shelljs is installed as devDependency or not installed at all, the plugin will fail to find shelljs path.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use the esbuild-plugin-shelljs plugin to patch shelljs.","cause":"shelljs uses dynamic imports without file extensions; esbuild cannot resolve them.","error":"Error: Module not found in bundle: ./src/cat"},{"fix":"Run npm install shelljs (or ensure it's in package.json).","cause":"shelljs is not installed or not in node_modules.","error":"Cannot find module 'shelljs'"},{"fix":"Use import { shellJsPlugin } from 'esbuild-plugin-shelljs' (named export).","cause":"Incorrect import: default import used instead of named import.","error":"TypeError: shellJsPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}