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

Compile to JavaScript module #46

Open
1 of 3 tasks
epost opened this issue Nov 22, 2019 · 3 comments
Open
1 of 3 tasks

Compile to JavaScript module #46

epost opened this issue Nov 22, 2019 · 3 comments

Comments

@epost
Copy link
Member

epost commented Nov 22, 2019

During the Summit, @clayrat, @marcosh and @epost found that the compiler-generated JavaScript wasn't usable with our existing code. What we want is for idris to generate a (CommonJS) module that we can include and use from other code.

  • Summarise current output format of idris compiler
    • format 1 (browser): TODO
    • format 2 (node): TODO
  • Describe in what way these formats are not what we need. (We need (CommonJS) modules).
  • Consider solutions
    • Patch idris to generate sensible js output.
    • Use a bundler? (Jelle's suggestion.)
    • Other?
@sjoerdvisscher
Copy link
Member

sjoerdvisscher commented Feb 3, 2020

Both javascript and node formats generate a single javascript file that runs the main function. There is no way to call other functions. As long as this is all we need, a bundler would work indeed.

@sjoerdvisscher
Copy link
Member

This is the way to create a CommonJS module:

test : String -> String
test a = a ++ a

lib : FFI_Export FFI_JS "" []
lib = Fun test "test" $
      End

Compile this with idris --codegen node --interface

@sjoerdvisscher
Copy link
Member

Information came from typedefs, see JS.Main there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants