At the beginning of 2017 we started using Elm in production at my company, and I am happy to say we now have 7 Elm applications totaling over 35,000 lines of Elm code. Our team is fairly small but I can already see a problem looming on the horizon: organization and re-use of non-published modules.
Each of the seven different Elm apps in our software are loaded on various pages of a monolithic MVC application. With this in mind, there are certain modules that make sense to reuse. However, for a variety of reasons I would not consider them open-source quality and do not think they are good candidates for publishing on package.elm-lang.org.
Currently our Elm project directory setup is something like this.
app/
...non-Elm-related files...
webroot/
/elm-dist -- symlink to /elm-app/dist
elm-app/
dist/
first-elm-app.js
second-elm-app.js
third-elm-app.js
first-elm-app/
/src
BootstrapHelper.elm
...other files...
elm-package.json
build-script
second-elm-app/
/src
BootstrapHelper.elm
...other files...
elm-package.json
build-script
third-elm-app/
/src
BootstrapHelper.elm
...other files...
elm-package.json
build-script
In the example above, BootstrapHelper.elm has to be copy-and-pasted to each Elm app’s /src directory. In each case, the file is essentially identical, but may receive small incremental changes. There are several problems I see with this approach.
- The initial copy-and-paste takes some work (especially when you aren’t sure which version is the “best” one to copy)
- There is a possible divergence in the API/types of of the module as it is expanded to accommodate the needs of the various apps
I have seen some npm packages to help manage this problem, but that was quite a while ago. I would appreciate any feedback from anyone who has been in a similar situation and has a solution they would recommend to solve the scenario described above.
EDIT: I realize that there may be a good solution to this problem in Elm 0.19. If that is the case then I am happy to wait.