TypeStrong / ts-loader

TypeScript loader for webpack
https://johnnyreilly.com/ts-loader-goes-webpack-5
MIT License
3.44k stars 429 forks source link

Use custom transformer when building solution references #1550

Closed feosuna1 closed 1 year ago

feosuna1 commented 1 year ago

This PR adds support for custom transformers in project references.

While attempting to use custom transformers, I realized that the transformers were only being applied to the main target and not to any of my referenced projects. After a bit of spelunking, I found that #1025 was a similar issue to my own. #1274 attempted to solve the problem, but some changes needed to be made in Typescript to allow for custom transformers in project references. All the necessary changes to support are available in Typescript v4.3+.

I've modeled my changes after @gasnier's original PR (#1025). This change set:

  1. Moves the getCustomTransformers logic out of initializeInstance and into a dedicated function, so that it can be shared.
  2. Refactors makeSolutionBuilderHost to include the new getCustomTransformer field in the solutionBuilderHost and have it return the transformers made available in the loader options.

Fixes #1025

johnnyreilly commented 1 year ago

Thanks for this - little snowed right now. Will look when I can

johnnyreilly commented 1 year ago

Have updated your branch - it's possible you might need to do some repairs

johnnyreilly commented 1 year ago

Failing tests following merge I'm afraid - could you take a look please?

feosuna1 commented 1 year ago

Failing tests following merge I'm afraid - could you take a look please?

It started failing because the typescript compiler is complaining that options can be a bunch of different types.

CleanShot 2022-11-26 at 09 24 22@2x
johnnyreilly commented 1 year ago

I think we might be nearly there. Could you update the version in the package.json and put an entry in the changeling.md please?

johnnyreilly commented 1 year ago

Thanks!

johnnyreilly commented 1 year ago

https://github.com/TypeStrong/ts-loader/releases/tag/v9.4.2