s-panferov / awesome-typescript-loader

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

Can't get path aliasing to work with webpack #604

Open darewreck54 opened 6 years ago

darewreck54 commented 6 years ago

I actually posted this on stackoverflow but there is no tag for this project.

https://stackoverflow.com/questions/51624134/aliasing-with-webpack-4-and-awesome-typescript-loader-not-working

I'm basically having issues with getting alias to work properly with webpack 4 and awesome typescript loader. It's not clear to me if its the configuration or what.

Any advice appreciated, Thanks, Derek

sverweij commented 5 years ago

It seems ATL doesn't handle tsconfig paths where the lhs contains an * at the moment.

Not working:

"paths": {
  "*" : ["types/*"],
  "common/*": ["src/stuff/common/"]
}

working fine:

"paths": {
  "common": ["src/stuff/common/"]
}

There's three workarounds I've found:

  1. Rewrite the LHS of the paths so they don't have a * in them - but that isn't always possible.
  2. ... add the mappings with asterisks in them to the webpack config manually. Which sort of defeats the purpose of having a plugin for this in the first place.
  3. Use another plugin to handle path aliasing.
    I've had success with the one ts-loader's github README recommends; tsconfig-paths-webpack-plugin (which b.t.w. "uses work done in awesome-typescript-loader").