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

View unused modules in a monorepo for dead code elimination #13

Open
ild0tt0re opened this issue Dec 15, 2022 · 5 comments
Open

View unused modules in a monorepo for dead code elimination #13

ild0tt0re opened this issue Dec 15, 2022 · 5 comments
Labels
core enhancement New feature or request

Comments

@ild0tt0re
Copy link

I would like to see unused modules so that I can easily remove dead code from the codebase.

Note:
Since the module can be used in NOT production code like tests, storybook and other tooling files, there should be an option to skip them

@antoine-coulon
Copy link
Owner

antoine-coulon commented Dec 19, 2022

Hey @ild0tt0re,

Thanks for submitting that feature request.

It is indeed the next feature planned before v1 is released, I'll probably open an issue where we can track the different milestones of that big feature.

Few milestones that I can see without even thinking about it are:

  • provide a new API to list all unused modules, with a possibility of filtering the glob pattern (since you were talking about targeting specific sets of tests)
  • provide a new API that automatically prunes unused modules using the first API (like 'ts-prune', but for all kind of files, not only typescript ones

Do you have any other ideas that could be valuable for Skott?

@antoine-coulon antoine-coulon added enhancement New feature or request road-to-v1 features planned to be added for v1 labels Dec 21, 2022
@antoine-coulon antoine-coulon added core and removed road-to-v1 features planned to be added for v1 labels Apr 22, 2023
@dufrenb
Copy link

dufrenb commented Jun 12, 2024

Hi, any update on this feature request ? We would be very interested by this feature using it on an angular monolithic codebase in order to split our applications and keep them separated

@antoine-coulon
Copy link
Owner

antoine-coulon commented Jun 12, 2024

Hello @dufrenb, there is unfortunately no new update regarding the elimination of local dead code.

However, I have been discussing with the author of knip which is an awesome library, and I will probably end up opening discussions regarding the need of exposing a knip API allowing tools like skott to integrate with it.

For your information, in the future, skott aims to provide dead code elimination for third-party + local modules by analyzing the graph. But if you want to start removing dead code of your own code as of today, I would recommend you to start using knip. Combining it with skott (that checks unused third-party modules) could be a great combination in order to remove most of the dead code (local+third-party) while being able to take full control over your project graph :)

@antoine-coulon
Copy link
Owner

antoine-coulon commented Jun 12, 2024

@dufrenb

Just to be 100% sure, when talking about "unused modules" in a monorepo, do you have in mind "unused files" or "unused identifiers (import/export)"? As the time flies by, I don't remember what I initially had in mind, sorry about that.

Identifying "unused files" could be pretty straightforward to implement actually, I could do that in one day.

But knowing if an import/export from a module is being actually used is another game.

So please, could you help me clarify what are your expectations?

@antoine-coulon
Copy link
Owner

Hello @dufrenb and @ild0tt0re,

I just published a new 0.35.0 skott version including a new --showUnusedFiles CLI option to list unused files (can only be used when not providing any entrypoint). The feature is also available through the API.

Let me know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants