Skip to content
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

Support spago alternate entry point option #63

Open
joprice opened this issue Oct 3, 2020 · 0 comments
Open

Support spago alternate entry point option #63

joprice opened this issue Oct 3, 2020 · 0 comments
Labels
enhancement Golang Applies to the Go target

Comments

@joprice
Copy link

joprice commented Oct 3, 2020

When providing an argument to the -m flag to spago run such as spago run -m Parser, I get following error

getModificationTime:getFileStatus: does not exist (No such file or directory)

This seems to do with how the module name "Main" is reserved https://github.com/andyarvanitis/purescript-native/pull/60/files#diff-bbb636505a367cfa1f620353cba3c3e3R452. Main is compiled in package main, while libraries intended to be imported and not run are compiled with a package named after the module path.

In order to use the same module as a library and make it runnable, it seems that modules that define a main of the right type should have a wrapper module generated with package main and a library module with the normal module path name. The main module can simply import the library package and call the main function in the package, so that the main function is still visible to consumers of the library as a normal main as it is in purescript js.

A workaround for this is to define multiple spago projects as described here https://github.com/purescript/spago#monorepo, one with the shared code, and one for each binary. This mirrors go's restriction of having one main per folder.

@andyarvanitis andyarvanitis added the Golang Applies to the Go target label Oct 3, 2020
@andyarvanitis andyarvanitis changed the title Error running alternate entry point Support spago alternate entry point option Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Golang Applies to the Go target
Projects
None yet
Development

No branches or pull requests

2 participants