s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 181 forks source link

Use absolute paths in TsConfigPathsPlugin #525

Open Bergmann89 opened 6 years ago

Bergmann89 commented 6 years ago

I have moved all config files of my project to a separate folder (./config) and TsConfigPathsPlugin uses relative paths to resolve file paths defined in my tsconfig. So the typescript and webpack compiler could not find the files. TsConfigPathsPlugin should use the baseUrl specified in tsconfig and generate a absolute path using the location of tsconfig: + +

For example:

- config -- tsconfig.json { baseUrl="../src", paths={ "lib/*": ["src/lib/*"] } } -- webpack.js - src -- lib TsConfigPathsPlugin should resolve "lib/test" to /config/../src/lib/test
lodybo commented 6 years ago

I also have this issue. For my test cases I have a separate tsconfig.test.json which uses baseUrl and paths for path resolution within the test cases (using the resolution 'App/' to lead to 'src/js/'. I used to have that in the regular tsconfig.json file, which worked correctly.

I then extracted the test-specific parts of the tsconfig.json into tsconfig.test.json and tried to set the configFileName option in both the loader options and the TsConfigPathsPlugin. But it doesn't get picked up, and I get "Cannot find module 'App/test'".

Is there any word or an update on this?