# ElmX re-written - v1.1.0 - Edge Cases now handled

**URL:** <https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351>\
**Category:** Show and Tell\
**Created:** [September 25, 2023, 2:20am UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351 "2023-09-25T02:20:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 25, 2023, 2:20am UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351/1 "2023-09-25T02:20:54Z")

</div>

Hello,

In response to the feedback provided by @lydell & @wolfadex I’ve completely re-written ElmX in order to handle the edge-cases [they pointed out](https://discourse.elm-lang.org/t/elmx-find-and-delete-unused-modules/9309/7).

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.

`source-directories` in `elm.json` is used to ensure correct identification of [unused] modules.

For full details of all the fixes and additions, please see the [CHANGELOG](https://github.com/phollyer/ElmX/blob/main/CHANGELOG.md).

For full details regarding installation and usage, please see the [README](https://github.com/phollyer/ElmX).

At the moment, only elm projects of type `application` are supported. I’m hoping to add support for `package`s 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](https://github.com/phollyer/ElmX).

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 🙂

---

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 26, 2023, 1:19pm UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351/2 "2023-09-26T13:19:23Z")

</div>

v1.1.1 now supports Elm Packages.

---

<div class="post-metadata">

**Author:** ![lydell](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/lydell/32/178_2.png) [@lydell](https://discourse.elm-lang.org/u/lydell)\
**Post date:** [September 26, 2023, 7:36pm UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351/3 "2023-09-26T19:36:18Z")

</div>

Well done! 👏

I very quickly looked at some of the code, but was too lazy to actually run it. Here’s a thing I wonder: Does it support `{- nested {- comments -} -}`, `{- comments -}{- next to each other -}` and `import{-nospace-}Something`? (Some annoying comment edge cases, that is.)

---

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 26, 2023, 10:13pm UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351/4 "2023-09-26T22:13:13Z")

</div>

> [@lydell](#):
>
> {- nested {- comments -} -}

Not yet

> [@lydell](#):
>
> {- comments -}{- next to each other -}

Yes

> [@lydell](#):
>
> import{-nospace-}Something

Yes

I’ve just started work on unused imports, will look into nested comments when I’ve finished this feature, which shouldn’t take long 🙂

---

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 28, 2023, 6:30pm UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351/5 "2023-09-28T18:30:51Z")

</div>

> [@paulh](#):
>
> which shouldn’t take long

Er, it might take a while, or at least a bit longer than I initially considered.

I’m probably going to build up some objects that represent all the Elm types and functions that are found after parsing each module, and use that information to do the discovery work.

More to follow…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [October 8, 2023, 6:31pm UTC](https://discourse.elm-lang.org/t/elmx-re-written-v1-1-0-edge-cases-now-handled/9351/6 "2023-10-08T18:31:25Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
