Explicitly require the commands to help JS bundlers find all the code
See original GitHub issueNode version (or tell us if you’re using electron or some other framework):
v12.8.1
ShellJS version (the most recent version/Github branch you see the bug on):
0.8.3
Operating system:
Ubuntu 18.04.3 LTS
Description of the bug:
First of all, thanks for an amazing library, it has been working great for me in all cases I needed it. Apart from today that I tried bundling one of my Node apps.
It would be great if the calls to requires were explicit and not dynamic as it’s done at https://github.com/shelljs/shelljs/blob/57df38c6ea264493a4219547331f2be049494ed5/shell.js#L24-L26
Reason is that when we want to bundle the whole Node application/script into a single JS file, it’s impossible to get it to bundle correctly.
One example is something I was trying to do today using Shadow-CLJS; more details at https://github.com/thheller/shadow-cljs/issues/290#issuecomment-524626179
I tried almost every popular bundler, including @zeit/ncc, Parcel-bundler, Rollup, and finally Webpack.
To be honest, I believe webpack managed to resolve the dynamic requires but then had other issues with __dirname which I use in my code (whole other different issue).
However, it would be much easier to integrate with these bundlers if the requires calls were explicit. Any specific reason why you go through the indirection of array of strings and a loop to require versus the direct require of the commands (other than saving a few characters)?
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (4 by maintainers)

Top Related StackOverflow Question
You are right. It seems that webpack manages to bundle the commands, but not the
exec-child.js.I used the following configuration in
webpack.config.js:and with the following source code in
src/js/index.js:and running the output file in a directory without the
node_modulesfolder throws the following error which indeed proves thatexec-child.jsis not part of the bundle.Hey @nfischer, can you please help with this? What do I configure typescript with? I’m getting this error, it’s clearly because of how typescript bundles, but how do I configure it?