-
Notifications
You must be signed in to change notification settings - Fork 45
Lift restriction on multiple main modules now that the compiler supports it #11
Comments
I don't understand the premise. "Given that the compiler can now generate javascript with multiple main modules, ..." What does that mean exactly? Is it true? What is the root problem you are trying to resolve? |
Sorry I might be unclear. We're currently using this to build... elm_modules=`printf "\
\nsrc/A/Main.elm
\nsrc/B/Main.elm\
\nsrc/C/Main.elm\
\nsrc/D/Main.elm\
\nsrc/E/Main.elm"`
elm-make $elm_modules --output elm-components.js --yes ...which works fine but has some maintenance burden (each of these modules is the main entry point to an embedded widget). Today I tried to use the {
"version": "1.0.0",
"summary": "My app",
"repository": "https://github.com/...",
"license": "Copyright",
"source-directories": [
"src"
],
"exposed-modules": [
"A.Main",
"B.Main",
"C.Main",
"D.Main"
],
"dependencies": { ... }
} and then build without explicitly list the modules... $ elm-make --output elm-components.js --yes
Error in ././src/A/Main.elm:
Port Error: ports may only appear in the main module. We do not want ports
appearing in library code where it adds a non-modular dependency. If I
import it twice, what does that really mean? This restriction may be
lifted later. I hope that's more clear... |
Yeah, that helps a lot! Here is my understanding. You would like to use I think of My feeling is that it makes the most sense to specify builds with some separate thing rather than trying to jam it all into Maybe there could be something like Do you agree with the reasoning here? |
TLDR; My reply is sloppy - see my comment at the bottom :) That does make sense to me, actually I hadn't even thought about it this way because I'm so used to I don't know the correct thing here, but for the sake of progress I'll try and argue the opposite. Is it possible Something else I could try and bring up is that many tools like
Well, one thing I will mention is that there tends to be a lot of asset processing and install hooks that tend to go into this sort of thing (and JSON is absolutely horrendous for that sort of business). I suppose it is better to recommend EDIT: in this case the build command would essentially be
So I assume you don't compile these into a single Javascript file though? It would be impossible to distinguish between different Main modules after all. I wonder if you wouldn't want to build this into a single In any case... how about we shelve this issue for now? It doesn't seem like something that deserves a lot of attention right now, I'm happy to polish up our build script slightly instead! |
I'm hesitant to put command line stuff in the package repo because I wouldn't say that command line stuff is explicitly supported, or that there is a "nice solution" for that case that everyone should be using. I think things will look different when that comes into existence. I'm okay to shelve things, but I'd say keep the general problem in mind as you work on your build script! I think we are pushing the frontiers of Elm so anything you learn or any patterns you notice should be super valuable. I think the more data we have the better decisions we can make when we do a general solution. Also, @rtfeldman made a grunt plugin for Elm which may be helpful for you? |
That does looks useful, thank you. We're using gulp so maybe we'll port the plugin to that. I'll let you know if we do something interesting for this, but I highly doubt it. I think I'm likely to simply extract the list of |
I believe the idea in #49 covers this in a nicer way, so I am going to close this issue for now. Please open a new issue if you are looking for something else. |
Given that the compiler can now generate javascript with multiple main modules it may be possible to lift the restriction over here.
I noticed that the code checks whether modules are "public modules" before allowing them to pass the check, so I thought maybe these were
"exposed-modules"
in theelm-package.json
.At the moment we still need to compile this way:
Alternatively, perhaps the
elm-package.json
needs"main-modules"
or something similar?The text was updated successfully, but these errors were encountered: