Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature req: bundler option/ js runtime #541

Closed
danikhan632 opened this issue Nov 1, 2022 · 6 comments
Closed

Feature req: bundler option/ js runtime #541

danikhan632 opened this issue Nov 1, 2022 · 6 comments

Comments

@danikhan632
Copy link

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

@antonmedv
Copy link
Collaborator

Now sure about deno/bun. Zx uses nodejs stuff. For example, async_hooks package.

Bundled version can be created, I think.

@antongolub
Copy link
Collaborator

antongolub commented Nov 1, 2022

No chance to enable async_hooks in bun for now: oven-sh/bun#158.

@danikhan632
Copy link
Author

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?

@borestad
Copy link

borestad commented Nov 7, 2022

@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

  • Broken build with rollup for node due to global "navigator" chalk/supports-color#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)

@josephrocca
Copy link

josephrocca commented Jan 13, 2023

[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:

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.

@antonmedv
Copy link
Collaborator

Well, I haVE AN IDEA TO CRETEASE A STRIPPEN dOWN VERSION OF ZX FOR ONLY $. This can hgelp./

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants