-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spago does not emit an error when bundling an app's main module that does not have a main
function
#181
Comments
main
function
main
functionmain
function
Good catch! This is interesting because Pulp however implements this check, and fails with a nice error message: $ pulp build -m Main -t dist/main.js
* Building project in /Users/fabrizio/code/explore-bundle-no-main
* Build successful.
* Bundling JavaScript...
* Main cannot be used as an entry point module because it
* does not export a `main` value.
*
* If you need to create a JavaScript bundle without an entry point, use
* the --skip-entry-point flag.
*
* ERROR: Failed entry point check for module Main Since that looks like a bunch of code, this makes me wonder if it should be instead EDIT: it looks like there's an entire PureScript package dedicated to this check: |
Ping @hdgarrood: thoughts on adding this check to |
This is something we previously decided is best not done inside purs bundle (since purs bundle only has access to the generated js). See purescript/purescript#2086 |
@hdgarrood thanks for the context! It makes sense, I'll look into using the externs files for the check 👍 |
Then again I suppose since |
It is certainly less than ideal that pulp is depending on the externs files format, since these are not part of the compiler’s public API. |
Indeed, but if it's necessary to rely on them and other tools (e.g. spago) start doing that too then it could make sense to include them in the public API? (though I'd be more for |
Yeah what I’m suggesting is that we modify purs bundle to have access to externs files as well as the js so that it can do this check. |
I created an issue: purescript/purescript#3621 |
Thank you! |
I'm removing the "blocked" label because a good first take at this (i.e. solving 90% of the problem) would be literally grepping the file searching for the string " |
Assuming this isn't been worked, I'd be interested in picking it up 😄 I've not worked on spago before so wondered if I could be pointed to where I'd do the |
What's an updated repro for this? Or am I being dense in failing to follow the original repro? 😄 |
@samhh
The last command fails because there's no |
@Cmdv I'm so sorry I missed your comment! Every once in a while some notification slips through, apologies. Also feel free to ping me in the future. The patch should go somewhere in this function, somewhere before line 379, which is where we call the compiler: Lines 376 to 381 in 8b8f06a
If we are bundling At this point though I'm thinking that it might be easier to fix this in the compiler. |
This is even easier these days - we'd just need to copy this bit of code |
@f-f well looks like I'm even worse just spotted your reply only took me 2 years 😅 |
It's alright, this issue has been open for 4y, we'll eventually get to it 😂 |
Steps to reproduce:
Spago doesn't fail with an error that
Main.purs
does not have a function calledmain
. Thus, the output of the bundle is this:One won't realize that the source of their issue is the compiled output until after exploring a few things more.
I only came across this because I used the wrong module name in the
spago bundle
command.The text was updated successfully, but these errors were encountered: