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

[@swc-node/register] passing flag --condition (-C) to node with esm-register import has no effect #890

Open
mkvlrn opened this issue Dec 30, 2024 · 0 comments

Comments

@mkvlrn
Copy link

mkvlrn commented Dec 30, 2024

In order to resolve user conditions defined in package.json we're supposed to pass a flag to node indicating which condition is to be used.

In my package.json:

"imports": {
  "#*": {
    "dev": "./src/*",
    "default": "./dist/*"
  }
},
node -C dev --import @swc-node/register/esm-register src/main.ts

^ this does not pass the -C flag to node and any imports are searched in the default path, in ./dist.

I could not find anything regarding this flag in this repo, but I assume it is supposed to work the way tsx does:

node -C dev --import tsx src/main.ts

^ this passes the flag to node and the correct imports are used

edit: browsing the source I found this regarding conditions

conditionNames: ['node', 'import'],

and out of curiosity I've updated it locally to:

conditionNames: ['node', 'import', 'dev'],

and it worked as I thought it would be in the first attempt.

This is a local hack just to see if it works and I have no idea what could be done to allow it to work properly. Hoping someone competent can take a look at this.

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

No branches or pull requests

1 participant