Rather than the initial, rather naive approach, ElmX now starts from the entry module and follows all the imports down each branch in order to build up knowledge of the application structure. This is then compared to the list of all elm files found in order to extract the unused modules.
This means that any and all cyclical modules that are not imported by any used modules are found correctly in a single pass.
Import statements are now extracted correctly when defined across multiple lines, and also comments in and around import statements do not prevent the import statement from being extracted correctly.
elm.json is used to ensure correct identification of [unused] modules.
For full details of all the fixes and additions, please see the CHANGELOG.
For full details regarding installation and usage, please see the README.
At the moment, only elm projects of type
application are supported. I’m hoping to add support for
packages within a couple of days, hopefully tomorrow, (which is now actually later today , time allowing), and then I’ll be starting on the features TODO list that is detailed at the bottom of the README.
I have only run this against small projects comprising a couple of hundred modules, I would love to hear how it performs on larger projects.
You can run
elmx unused-modules -s in order to simply show any unused modules found, so this is completely non-invassive. You must add the
-d flag in order for any modules to actually be deleted.
As always, feedback, suggestions and constructive criticism are all welcome.
Thanks for reading