-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Add support for Ionic / enhance the capacitor plugin #604
Comments
Thanks @ptmkenny! Added to the central list. |
New ionic fixture/repro in which I attempted to minimize the dependencies: https://github.com/ptmkenny/ionic-knip
Output will be:
However, all three of these packages are actually used.
This repo includes a
|
Looking at it, there's a little bit of "magic" going on here:
This all seems Capacitor area to me. Before we're going to try and automate this in Knip, I would like to understand whether the following configuration helps to get rid of false positives? {
"entry": ["src/main.tsx"] // can be omitted since it's included by default
"project": ["src/**/*.{ts,tsx}"] // alternative: ["**/*.{ts,tsx}", "!ios/**", "!android/**"],
"ignoreDependencies": ["@capacitor/android", "@capacitor/ios", "@capacitor/cli"]
} Do you think there are further issues? And additional issues specific to Ionic? |
Thank you for looking into this. I tried the config you suggested locally and it successfully eliminates the false positives. That said, this pattern ( As for In fact, on my main project (not the repro I shared here),
That would be great! |
For now, this is something to control in
Knip would detect
Yes this I have now locally, just checking of those files exist. But just to be sure: looking at https://github.com/ptmkenny/ionic-knip/blob/main/android/capacitor.settings.gradle and https://github.com/ptmkenny/ionic-knip/blob/main/ios/App/Podfile, they reference more packages, such as |
The plugins such as
The other capacitor plugins are used to access native device features from app source code, so they can be handled the same as other npm packages. |
🚀 This issue has been resolved in v5.12.0. See Release 5.12.0 for release notes. Using Knip in a commercial project? Please consider sponsoring me. |
knip already has a plugin for
capacitor
, but it doesn't seem to have anything for Ionic. Ionic is a framework built on top of capacitor (by the same developers) that provides the developer's choice of PWA, Android, iOS, and/or Windows apps.I ran
knip
in my Ionic project with no configuration and, because of the lack of Ionic support, some parts of the report are incorrect.Specifically:
@capacitor/android
and@capacitor/ios
are packages for building mobile apps with the capacitor cli. (getting started instructions)So they are used by the project, but
knip
seems unable to detect that.Also:
These are the Ionic build outputs from capacitor in the default locations; these are build artifacts, so I assume normally
knip
does not need to parse them at all (they should be ignored, since they are generated from the build scripts and code).So this is a feature request to support Ionic (specifically the capacitor plugins for building mobile apps, @capacitor/android, @capacitor/ios) and ignoring their build artifacts (when @capacitor/android is present, the
android
directory, and when@capacitor/ios
is present, theios
directory).Repro
https://github.com/ptmkenny/ionic-react-conference-app/tree/knip
Thanks
Thank you for this awesome project; it has helped me remove a lot of cruft that has built up over the past couple years!
The text was updated successfully, but these errors were encountered: