Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Pass through ResolveTypes from Webpack #97

wants to merge 3 commits into from

Conversation

aaronadamsCA
Copy link
Contributor

@aaronadamsCA aaronadamsCA commented Jul 29, 2022

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 in tsconfig-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.

@codecov
Copy link

codecov bot commented Jul 29, 2022

Codecov Report

Merging #97 (d2d7b83) into master (a960c6b) will not change coverage.
The diff coverage is n/a.

@@           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           
Impacted Files Coverage Δ
src/options.ts 85.71% <ø> (ø)
src/plugin.ts 46.07% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@aaronadamsCA aaronadamsCA changed the title Import mainFields, extensions types from Webpack Pass through ResolveTypes from Webpack Jul 29, 2022
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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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!

Copy link
Member

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.

Copy link
Contributor Author

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!

@jonaskello
Copy link
Member

Now that nested mainfields is supported in tsconfig-paths 4.1.0 you could try to upgrade and see if the types match better.

@aaronadamsCA
Copy link
Contributor Author

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.

@aaronadamsCA
Copy link
Contributor Author

@jonaskello, friendly bump here, as I believe this is still release-ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mainFields type mismatch with webpack
2 participants