-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Lazy imports not accessible when accessed by key #616
Comments
The rule of thumb: if "Find All References" for the Knip covers more when using the Not sure it's because this is a demo, but Could you be more specific in how Knip could help here? E.g how to ignore such seemingly non-deterministic cases? |
We are also facing the same issue. |
@AndreaPontrandolfo Does "Find all references" on the exported component find usages? Knip finds this the examples of https://knip.dev/guides/handling-issues#external-libraries But not the pattern from the OP: const Component = lazyImport(() => import('./Foo'), 'Foo'); Would be good to find the "boundaries" here and document it better. And, indeed, ways to more easily ignore stuff and while still getting valuable reporting from Knip. |
Actually yes.
|
Interesting. Assuming you've tried |
@webpro oh sorry i wasn't clear, that was WITHOUT |
It's not enabled by default, because what's required for this makes Knip pretty slow especially in larger projects. Not sure how to "auto opt-in", but better docs/discoverability would help for sure. Or some kind of "aggregate flag" to group related flags for easier opt-in. Thanks for the input. |
that would be b/c of the demo i think, it's correctly typed in normal repos
I'd like to tell Knip that these are usages, ideally with my own plugin. FWIW these cases aren't non-deterministic, they are strictly and correctly typed, but defeat the tool |
Sorry, still not sure how to deal with this. At this point I also don't really see how plugins could help here if they can't be determined through glob pattern(s). The repro should be minimal yet complete/functional (at least from a TS/compiler perspective). In general, the |
Going to close this issue. Feel free to open a new one, and take the following into account:
|
https://stackblitz.com/edit/github-yu5k5m?file=index.ts
Here is a trimmed down helper we use all the time demostrating the failure case. We have a more complicated one that is type safe, but is curried e.g.
lazyImporter(() => import('./Foo')).getComponent('Bar')
. TBH I don't really expect knip to see these, but I would love to be able to tell knip that these cases are ok via a plugin or something. Annotating the hundred+ components with knip ignore isn't really feasible and there isn't a way to determine these via a globThe text was updated successfully, but these errors were encountered: