Check if the main function exists and is exported when bundling#1368
Conversation
fsoikin
left a comment
There was a problem hiding this comment.
The code looks good, but here's a suggestion: since we're already parsing the module, how about also checking that the main's type is Effect Unit? It's true that the type could be aliased and not look like Effect Unit, but I think it's a reasonable requirement to have the entry point typed exactly like that. Or, alternatively, it could be a warning. Or can be disabled with a switch.
| , "Add `main` to the module's export list, remove the explicit export list, or use --bundle-type=module." | ||
| ] | ||
| EntryPoint.ParseError err -> | ||
| logWarn $ "Could not verify main export: " <> err |
There was a problem hiding this comment.
Should this also be an error? If the module failed to parse, surely we can't bundle, right?
There was a problem hiding this comment.
Actually I just downgraded this to a debug log - the point where we run this is right after a build, so we know that the code compiles; if there's a parse error then the issue must be somewhere else and it's not worth warning the user about it (but still useful to report a debug log in case this is wrong and we need to trace it 🙂)
|
@fsoikin makes sense, I added detection for the |
Fix #181 (at last!!) by following my own suggestion from here