feat(nuxt): use nuxt to resolve its own paths#1265
feat(nuxt): use nuxt to resolve its own paths#1265danielroe wants to merge 13 commits intowebpro-nl:mainfrom
nuxt to resolve its own paths#1265Conversation
Co-authored-by: OrbisK <robin.kehl@singular-it.de>
There was a problem hiding this comment.
this is a valid nuxt entry, believe it or not, and if present nuxt would actually use this
| // TODO: we need to register these as source files which may not be all used | ||
| for (const path of availableSources) { | ||
| inputs.push(toProductionEntry(path, { allowIncludeExports: true })); | ||
| } |
There was a problem hiding this comment.
is there a way to register these paths so any imports into them are respected, but unused exports are detected?
There was a problem hiding this comment.
Yes, if I understand correctly, this is the breakdown:
- default behavior: exports of entry files are not reported
skipExportsAnalysis: false- report unused exports (what you're asking for)allowIncludeExports: true- report unused exports only with flag--include-entry-exports/includeEntryExports
|
Would be awesome to see this finished :) |
f4844ad to
0faa3b8
Compare
|
What's the status here? Is there still interest in wrapping this up? |
|
yes! apologies on the long delay. |
|
Took a different stab at this in #1517. If anyone could take it for a spin in their projects, that would be great :) |
Thanks! I tried your PR and for me it worked pretty well and I could already remove a bit of dead code from my project. 👍 A few things I noticed:
Not sure how much I normally would need to use a knip ignore list (if this exists) as I have never used knip outside of this one nuxt project. |
|
Thanks Yannik! This is great feedback. Any chance you could copy-paste it into #1517? |
9adf502 to
23f8020
Compare
# Conflicts: # packages/knip/package.json # packages/knip/src/plugins/nuxt/index.ts # pnpm-lock.yaml
# Conflicts: # packages/knip/src/plugins/nuxt/index.ts
|
Thanks for the PR, Daniel! It is much appreciated. Using
Either approach needs to
By design, Knip has affordances to take what it needs from configuration files with input helpers like The vision, direction and resources of this project do not align with taking in more of such complexity, and I would prefer not to include the extra dev/peer dependencies. We could still refactor the pull request and skip the new dependencies. Keep the remaining improvements to help the Knip + Nuxt community minimize their required configuration. What do you think? |
resolves #1255
this rewrites the nuxt plugin to use nuxt itself to resolve its own paths, supporting layers, modules, etc.
🚧 todo
at the moment test is failing.
we need to enable components + imports to register dependencies without being entries - ie. detect unused composables, but if a composable imports from something else, then that should count as that other thing being used
(this may be straightforward)