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/Fix: Remove shebang from codes #596

Closed
renhiyama opened this issue Apr 18, 2023 · 3 comments
Closed

Feature/Fix: Remove shebang from codes #596

renhiyama opened this issue Apr 18, 2023 · 3 comments

Comments

@renhiyama
Copy link
Contributor

I was thinking of running my cli package that is a nodejs app, directly running it on deno like this:

 deno run -A -r https://esm.sh/[email protected]/src/cli/index.js test

However, the file doesn't make use of shebang, as we can see the code at https://esm.sh/v115/[email protected]/deno/src/cli/index.js

/* esm.sh - esbuild bundle([email protected]/src/cli/index) deno production */
import __Process$ from "https://deno.land/[email protected]/node/process.ts";#!/usr/bin/env node
import{dirname as m}from"/v115/[email protected]/deno/src/imports/env.js";import a from"/v115/[email protected]/deno/src/imports/nativeImport.js";import"/v115/[email protected]/deno/src/utils/log.js";import{Import as e}from"/v115/[email protected]/deno/src/imports/URLImport.js";import i from"/v115/[email protected]/deno/src/imports/dynamicImport.js";await Promise.all([e("[email protected]"),e("[email protected]"),e("[email protected]")]);var s=await e("[email protected]"),p=await a("node:fs"),d=await a("node:path"),n=i(await import("/v115/[email protected]/deno/package.json.js",{assert:{type:"json"}})),l=p.readdirSync(d.join(m,"./cli/cmds")),r={},o=s("reejs");o.version(n.version);for(let t of l)r[t.split(".")[0]]=i(await import(`./cmds/${t}`));for(let t in r)r[t].default(o);o.parse(__Process$.argv);
//# sourceMappingURL=index.js.map

Esm.sh adds its own comment at the start of the code, followed by polyfills... then comes our shebang...

Also, if possible, modify the shebang from node to the User-Agent used (like bun/node/deno) so it makes sure that we run directly on the runtime we want, and not just running a child process in theory 😄

@renhiyama renhiyama changed the title Feature/Fix: Properly make use of shebang. Feature/Fix: Properly make use of shebang to allow cli apps to run. Apr 18, 2023
@ije
Copy link
Member

ije commented Apr 18, 2023

since esm.sh serves module as url, i don't see the necessary to modify it for deno/bun.

@renhiyama
Copy link
Contributor Author

maybe atleast remove the shebang from the code so it isnt doesnt result in a syntax error ?

@renhiyama renhiyama changed the title Feature/Fix: Properly make use of shebang to allow cli apps to run. Feature/Fix: Remove shebang from codes Apr 18, 2023
@ije
Copy link
Member

ije commented Apr 18, 2023

yes, i am working on it

@ije ije closed this as completed in cffa844 Apr 18, 2023
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

2 participants