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.
In order to resolve user conditions defined in
package.jsonwe're supposed to pass a flag to node indicating which condition is to be used.In my
package.json:^ 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
tsxdoes:^ this passes the flag to node and the correct imports are used
edit: browsing the source I found this regarding conditions
swc-node/packages/register/esm.mts
Line 43 in 64d568b
and out of curiosity I've updated it locally to:
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.