halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

Multiple elm-package.json files #35

Closed pauldijou closed 7 years ago

pauldijou commented 7 years ago

This plugin looks awesome but it crashes when I try to use it. The reason is that my project does not have a elm-package.json at the root of the folder. That's because I have two Elm projects, one for server-side, one for client-side, and some common source code.

├── client
│   ├── [some Elm code]
│   └── elm-package.json 
├── server
│   ├── [some Elm code]
│   └── elm-package.json 
└── src
    └──  [some common Elm code]

Is there any chance for the plugin to search for elm-package.json files inside subdirectories and support several Elm projects at once? Maybe with some ignored folders (either based on .gitignore or from plugin settings)

halohalospecial commented 7 years ago

Hi, what did you mean by "it crashes"? Were there error notifications or console errors?

pauldijou commented 7 years ago

This is what I get right after enabling elmjutsu on my project (atom is opened at the root of the folder, not inside client nor server). Using 2.10.1, I'm having some internet issues and failed to update to last version. Will try again tomorrow.

image

halohalospecial commented 7 years ago

Ah, I see. Did you open a .elm file in the src directory (which does not have an elm-package.json)? When you open a .elm file, Elmjutsu will search for an elm-package.json in that directory or the parent directories. Elmjutsu will treat the directory (where elm-package.json was found) as the "project directory" and needs to read elm-package.json for info about imports and such. I don't know how to solve this elegantly right now :disappointed: Suggestions are welcome!

pauldijou commented 7 years ago

Yeah, you're right... I can't see a way to do that either. So I tried to create a "fake" elm-package.json at the root of the project with all dependencies from both client and server but I got a new error.

halohalospecial commented 7 years ago

Hi, do you have a sample project that I can use to replicate the issue?

halohalospecial commented 7 years ago

Hi, does the new directory structure look like this?

├── client
│   └── [some Elm code]
├── server
│   └── [some Elm code]
└── src
    └── [some common Elm code]
└── elm-package.json
pauldijou commented 7 years ago

Yes, exactly. I will try to do the sample project this weekend.

pauldijou commented 7 years ago

Doing the sample project, I realized I had a wrong configuration in the project (one wrong source-directories in the elm-package.json). Fixing it fixed the Atom error.

There is only one thing that's not working but that's ok because I don't see any way how it could. It's the autocompletion when both client and server have the same module inside their respective folders exposing the same API (for example, a logger implementation) which is imported inside the common Elm code. Using the top level elm-package.json, there is no way to know which one is used.

Thanks again for the plugin!