Feature req: bundler option/ js runtime
Enable the use of webpack/bundler and an alternative JS runtime such as Deno/ Bun.js
current implementation relies on slow/long setup
- feature would bundle node_modules and index.mjs to a single file
- additionally, packaging a lite JS runtime in an shell script would make deployments ideal
really love this repo, let me know I can help make this happen
Now sure about deno/bun. Zx uses nodejs stuff. For example, async_hooks package.
Bundled version can be created, I think.
No chance to enable async_hooks in bun for now: https://github.com/oven-sh/bun/issues/158.
Bundled version can be created, I think. @antonmedv I'd love to work on the bundling feature, if I wanted to merge or if I needed some clarity would that be okay?
@danikhan632
Just FYI: I've experimented a bit with this and found some caveats. (tried both esbuild / rollup, parcel) didn't have the energy to go webpack
- https://github.com/chalk/supports-color/issues/113
- Creating a bundle that both supports to be run with a node and a zx shebang. (Error: Dynamic require of "path" is not supported )
- I had good luck with esbuild, but it doesn't support types by design, and my goal is to use the same distribution both on dev & and prod.
- For now, I'm just executing the bundled file with zx, but it would be nice to create a vanilla esm build (that also contains types)
[Not] sure about deno/bun. Zx uses nodejs stuff. For example, async_hooks package.
Deno has pretty good support for a lot of node/npm stuff now:
- https://github.com/denoland/deno_std/tree/main/node#deno-nodejs-compatibility
- https://deno.land/[email protected]/node/npm_specifiers
- https://deno.land/[email protected]/node/cdns
- https://deno.land/[email protected]/node/internal/async_hooks.ts
I just tried this out of over-optimistic curiosity:
deno install --allow-all npm:[email protected]
And it appears to install correctly, but then throws this when trying to run a script with zx:
error: Could not resolve 'node:repl' from 'file:///home/joe/.cache/deno/npm/registry.npmjs.org/zx/7.1.1/build/repl.js'.
Caused by:
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLS are supported by the default ESM loader. Received protocol 'node'
I'm guessing that a deno.json config file (pointing to a Deno-specific import map) would be needed to work around this sort of problem.
Well, I haVE AN IDEA TO CRETEASE A STRIPPEN dOWN VERSION OF ZX FOR ONLY $. This can hgelp./