https://github.com/7ph/esbuild-plugin-shelljs
Plugin for esbuild to be able to bundle shelljs
https://github.com/7ph/esbuild-plugin-shelljs
Last synced: 8 months ago
JSON representation
Plugin for esbuild to be able to bundle shelljs
- Host: GitHub
- URL: https://github.com/7ph/esbuild-plugin-shelljs
- Owner: 7PH
- Created: 2024-06-04T22:01:48.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-24T00:42:03.000Z (over 1 year ago)
- Last Synced: 2025-03-01T23:56:24.611Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://github.com/shelljs/shelljs/issues/1160
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# esbuild-plugin-shelljs
Plugin for esbuild to be able to bundle [shelljs](https://github.com/shelljs/shelljs). Without this fix, bundling shelljs gives error:
```text
Error: Module not found in bundle: ./src/cat
```
### Install
```bash
npm i -D esbuild-plugin-shelljs
```
```javascript
import { shellJsPlugin } from "esbuild-plugin-shelljs";
esbuild.build({
// [..]
plugins: [shellJsPlugin],
});
```
### How does it work
This plugin patches the `shelljs` dependency before bundling it. Esbuild knows the path of `shelljs` local dependencies with `.js` suffixes, but a dynamic import which omits the extension makes esbuild fail to resolve dependencies. The patch adds `.js` to the dynamic imports.