-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support tsconfig paths mapping similar to Jest's moduleNameMapper #4904
Comments
So, I actually think that the issue was caused not by the |
Well, this is weird, I don't really understand what is going on. this doesn't work
this works
However, this also seems to be working, although it might be that it is just a
What is going on? How can I use imports with path aliases and json files? |
Sounds like this is a question more than anything else. Closing as questions should go in Discord or StackOverflow. Good luck! |
So, path aliases are supported by mocha, am I reading this right? Because in my previous experiment, it was clear that this doesn't work
and this works
|
(re-opening to put back in the triage queue) |
Ok, yes, coming back to this now that I know more about Mocha: you're correct that Mocha doesn't natively support path aliases. Mocha directly runs JavaScript files. It doesn't set up fancy virtual environments with mapped names the way, say, Jest's Mocha does support using Node.js-style loaders that can modify files on the fly - including rewriting import paths and/or transpiling TypeScript syntax to pure JavaScript. mochajs/mocha-examples#75 -> mochajs/mocha-examples#76 shows a couple examples of that. If that examples repo & its open PRs doesn't include an example of using Mocha+TypeScript the way you're looking for, I'd suggest filing an issue on the repo. There's definitely a lot missing at the moment. Cheers! 🤎 |
Is your feature request related to a problem or a nice-to-have?? Please describe.
In a TypeScript project that uses custom
paths
aliases intsconfig.json
, it is not possible to import files using e.g.@abi/something
, which is mapped intsconfig.json
like thisDescribe the solution you'd like
The custom paths are supported by jest using modulenamemapper
https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring
Describe alternatives you've considered
using hardhat plugins
The text was updated successfully, but these errors were encountered: