-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
Add paths support #254
Add paths support #254
Conversation
1 similar comment
I mentioned it in #138 (comment), but I don't have any desire to enable this in |
+1 for plugin |
Yes, I did read that comment but I wasn't aware of the Now that I know the
For these reasons I think there is a growing number of projects that use paths. I consider ts-node a great tool for the typescript community and I think it would be unfortunate if the part of the community that uses paths in their tsconfig could not use it, or had to take special steps to make it work. Just to clarify, the only reason it cannot be included directly in ts-node is that it is using the undocumented patch of Mode._load or are there other reasons? One question about doing it as a |
After further research I found that the I still think that eventually having the "it just works" experience would be the nicest way in ts-node, but until we find an agreeable way to do that I'll close this and report back on my progress as a separate module loadable with |
Mostly don't want to include it in core as it's not something I can maintain myself. My time is pretty limited for OSS lately and new features like this can sometimes come with a lot of bugs. Bugs mean issues I would need to dedicate time to fixing. A better way to support a feature like this is to build the module independently (I always intended to write an abstract version, but as you know - not a priority for me) and allow it's usage programmatically. Once it's stable, I can just require it and include it in Edit: There's likely two useful levels to a module like this. 1. "low-level" paths mapping for people to use in other TS environments (Webpack, Browserify, etc.) and 2. "high-level" node-specific version. |
I hear you about the lack of time, I did not get my standing christmas wish for 36h days this year either :-). My current efforts are now in the tsconfig-paths package. I can get it to work with
I'll investigate whats going on. |
Btw, awesome-typescript-loader already has this paths functionality for webpack so it might make sense to make a separate resolver package and share it as you mentioned. |
I think I found what is going on, I started #257 rather than discussing it here. |
Just stumbling into this issue and I want to add my voice to this:
paths is bad. It defeats portability and is a hell to maintain. |
How does it defeat portability? Used with baseUrl it can separate 'modules'. I use relative paths in my 'paths', combined with extends in my tsconfig.json. |
I assume you don’t share your code on NPM, or use different bundlers, or work with other people that don’t also have |
Don't worry Blake, it's all good. Thank you for your source code contributions! :) |
To follow up on this, I think @jonaskello would always love help maintaining the paths support 😄 It looks like it's a project as big as |
to solve this issue, i have workaround on this issue answer : #138 (comment) |
Add support for executing typescript projects that uses
paths
in tsconfig. Discussed in #138 and #219.It is achieved by patching node's
Module._load
function which is undocumented and but I found this technique used elsewhere such as in mock-require. The loader patch is only applied if there are paths specified in tsconfig so it should not alter the behaviour if there are no paths.There is also a small example here to test it. I would like to add some tests for this PR but not sure how to do it since my functions are not exported.