Support baseUrl and paths resolution as implemented in TS 1.9 #156
Comments
@guncha this error is about webpack and how it resolves modules. Webpack knows nothing about typescript, it uses basic
|
I see, that's very interesting. I had assumed that the loader tells webpack "hey, add these files as dependencies", but I guess it's the other way around. |
@s-panferov how would you go about setting this in
|
@TheLarkInn yes, aliases is the right way to go. I just need to think if it possible to set them automatically , using info from tsconfig.json. I suppose we need something like
|
@s-panferov could you set it in compiler.plugin('run') or ('watch-run') or both. |
@TheLarkInn I don't think so, because as far as I remember webpack creates resolver one time during init process. I need to dig into this. |
@sokra do you have any suggestions for this? I'm not sure the best way to handle aliasing like this. |
You can write a resolver plugin for webpack, which takes care of resolving dependencies accoring to a |
@sokra ok, I'll try to implement this. Do you have any examples? |
@s-panferov https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsApply.js#L273-L286 Looks like how webpack reads aliases and applies them.
|
Here is the webpack alias plugin: https://github.com/webpack/enhanced-resolve/blob/master/lib/AliasPlugin.js It's used here: https://github.com/webpack/enhanced-resolve/blob/master/lib/ResolverFactory.js#L155 So you can write your own alias plugin: resolve: {
plugins: [
new TsConfigAliasPlugin("described-resolve", "resolve")
]
} |
Basic implementation landed in
Please try and say what you think. |
Good timing I'll try right now. Great work. |
I didn't see |
@s-panferov I am still seeing that error. Just to confirm, I don't have to pass any arguments to the plugin, it likes in the code it already picked up and obtained from |
Here is a gist of the configuration if this helps. |
@TheLarkInn just to confirm, you don't have a |
I've fixed the error in This is right config for your app:
Unfortunately, the plugin can't communicate with the loader, so you have to specify |
This is for a situation where angular CLI I which generates projects. so the tsconfig is not at the root execution path it's the projects patg |
Thank you that's no problem at all. I'll let you know here in a bit, sorry for this edge-casey kind of stuff. |
@TheLarkInn could you please confirm that everything works? |
@s-panferov Yup. I'll take a look at it again today. And let you know what I find. |
Nice, I can confirm that it works with
Either way, awesome work. Can't wait to use this. Now if the editors could catch up to 1.9.x, that'd be great. |
My edge case project is really hard to test this feature and tell you reliably if it's working so I'm going to create a test project and test this feature more in depth. |
@s-panferov I had to back port an isolated hack of this to v1.1.1 but when I did I could confirm it was working (did have some a-t-loader diagnostic errors because a-t-loader 's Resolver was failing to find 1 or two files). In regards to the back port there seems to be some strange path resolution issues outside of this use. Second when |
I was trying to use
awesome-typescript-loader
withtypescript@next
to see if I could set it all up to avoid this wholeimport {..} from "../../../../../dep
business and it seems likebaseUrl
option solves it, but only when not running through the loader.When running with the loader, I'm getting an error:
Does the loader have its own module resolution strategy? If so, can we extend it to support what's being discussed in microsoft/TypeScript#5039 or perhaps use the compiler's?
The text was updated successfully, but these errors were encountered: