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
Pass through ResolveTypes
from Webpack
#97
Conversation
Codecov Report
@@ Coverage Diff @@
## master #97 +/- ##
=======================================
Coverage 56.20% 56.20%
=======================================
Files 4 4
Lines 153 153
Branches 32 32
=======================================
Hits 86 86
Misses 56 56
Partials 11 11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
ResolveTypes
from Webpack
src/plugin.ts
Outdated
@@ -160,7 +160,7 @@ export class TsconfigPathsPlugin implements ResolvePluginInstance { | |||
this.matchPath = TsconfigPaths.createMatchPathAsync( | |||
this.absoluteBaseUrl, | |||
loadResult.paths, | |||
options.mainFields | |||
options.mainFields as string[] | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we can solve this just as a typing assertion. createMatchPathAsync()
does not know what to do with Array<Array<string>>
so allowing to pass that may be misleading. Not sure what it means to use Array<Array<string>>
as mainfields, should it just be unnested to Array<string>
or does it have other meaning to webpack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did figure out what it's for, at least: it's a nested main field selector.
webpack/webpack#7204 (comment)
It turns out your concern was valid; I tried adding a test to tsconfig-paths
with a string[]
in mainFields
and it failed.
This wouldn't be a new failure, of course; it would crash just as readily now. But obviously you don't want to advertise an invalid type.
I'll see if I can get them a PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dividab/tsconfig-paths#218 - we'll see if they accept it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I maintain that package too :-). I left some comments in the tsconfig-paths issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove "attention to detail" from my resume, ha.
This assertion is now gone, thank you!
Now that nested mainfields is supported in tsconfig-paths 4.1.0 you could try to upgrade and see if the types match better. |
They do! I've updated this PR to remove the type assertion, since it's no longer necessary. |
@jonaskello, friendly bump here, as I believe this is still release-ready. |
Resolves #88.
Unlike #93, this time I made the necessary internal changes.
Note there is now one type assertion due to a bad upstream type intsconfig-paths
. I filed dividab/tsconfig-paths#217 to resolve, but for now the assertion should be fine, since it's only a type change - no functional changes.