On `elm publish` can't find exposed modules

I’m trying to publish a package that contains other source code (CSS in this case, which won’t be published to packages.elm-lang.org). The problem I’m running into is that the elm publish command doesn’t seem to respect the source-directories setting in the elm.json. Anyone else have this issue?

My elm.json for example:

{
    "type": "package",
    "name": "waratuman/elm-uniform",
    "summary": "Elm implementation of the Uniform HTML/CSS library.",
    "license": "BSD-3-Clause",
    "version": "0.0.0",
    "exposed-modules": [
        "Uniform",
        "Uniform.Autocomplete"
    ],
    "source-directories": [
        "src/elm"
    ],
    "elm-version": "0.19.0 <= v <= 0.20.0",
    "dependencies": {
        "elm/core": "1.0.0 <= v <= 2.0.0",
        "elm/html": "1.0.0 <= v <= 2.0.0"
    },
    "test-dependencies": {}
}

After running the elm-publish command:

This package has never been published before. Here's how things work:

  - Versions all have exactly three parts: MAJOR.MINOR.PATCH

  - All packages start with initial version 1.0.0

  - Versions are incremented based on how the API changes:

        PATCH = the API is the same, no risk of breaking code
        MINOR = values have been added, existing values are unchanged
        MAJOR = existing values have been changed or removed

  - I will bump versions for you, automatically enforcing these rules


I will now verify that everything is in order...

  ● Found README.md      
  ● Found LICENSE      
  ✗ Problem with documentation

-- MISSING MODULE ----------------------------------------------------- elm.json

The "exposed-modules" of your elm.json lists the following module:

    Uniform

But I cannot find it in your src/ directory. Is there a typo? Was it renamed?

source-directories is only for applications, packages must have their source in src.

If you run a new elm install ... command for example, you will see that it will remove this field in your elm.json because it is not valid for "type": "package".

PS: v <= 0.20.0 is not advised, you don’t know if your package will work with a major update of Elm. You could use elm-json new command for example (see elm-json) to initialize a sane default elm.json for a new package.

Got it. So I can just structure my library as elm/{elm-structure} and css/{css-structure}.

Here’s a link to a resource I recently found which might help:
https://korban.net/posts/elm/2018-10-02-basic-steps-publish-package-elm-19/

I found it useful, hope you do too.

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