Closed samydoesit closed 2 months ago
+1 Same issue here...
Thanks @samydoesit for raising, and taking the time to make that repro.
I've looked at the config there, but my understanding is that it would not work with or without Cucumber. From the relevant ts-node documentation:
...
"paths"
are intended to describe mappings that the build tool or runtime already performs, not to tell the build tool or runtime how to resolve modules. In other words, they intend us to write our imports in a waynode
already understands. For this reason, ts-node does not modifynode
's module resolution behavior to implement"paths"
mappings.
ts-config-paths tends to be used for this, but from what I can see lacks ESM support for now, so unfortunately to have path mapping like this you may need to go back to CommonJS output.
Thanks for your quick response. :) I thought maybe there is another way.
We will keep the CommonJS output for now.
👓 What did you see?
When using cucumber-js with
ts-node
as the loader in ESM mode, TypeScript path aliases specified intsconfig.json
fail to resolve.Path aliases are not resolved, resulting in module resolution errors when attempting to execute tests.
Error:
✅ What did you expect to see?
TypeScript path aliases should resolve correctly when cucumber-js is run in ESM mode using
ts-node
.📦 Which tool/library version are you using?
🔬 How could we reproduce it?
Steps to Reproduce
npm install
npm test
📚 Any additional context?
No response