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

Register global ESM loader #460

Open
jcalfee opened this issue Feb 6, 2025 · 1 comment
Open

Register global ESM loader #460

jcalfee opened this issue Feb 6, 2025 · 1 comment

Comments

@jcalfee
Copy link

jcalfee commented Feb 6, 2025

Is this easy to add? node --import vinxi/register index.ts

Just like: https://github.com/unjs/jiti?tab=readme-ov-file#register-global-esm-loader

// https://nodejs.org/api/module.html#moduleregisterspecifier-parenturl-options
import { register } from "node:module";

register("./jiti-hooks.mjs", import.meta.url, {});
@jcalfee
Copy link
Author

jcalfee commented Feb 6, 2025

The reason is, scripts in a package that use #!/usr/bin/env -S vinxi run do not export vinxi, instead the package that depends on this script must install vinxi as well. If it were registered, as above, it would instead find vinxi using the module loader and allow the dependent package to run the script even if vinxi were not installed.

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

1 participant