Skip to content

Support spago alternate entry point option #63

@joprice

Description

@joprice

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions