Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.16 KB

README.md

File metadata and controls

42 lines (33 loc) · 1.16 KB

Node challenge

This is a minimal project on how to import cjs and esm and ps v0.15.0 for node.

The project is defined in the project-node folder. It is a minimal project that loads and prints a string

  • from a common js module, see example-cjs
  • from an esm module, see example-esm
  • from a ps v0.15.0 esm module, see example-ps-esm
    • first, via purescript import
    • second, via esm import in the FFI

To run it in node, we currently need to define a simple wrapper function for our application, see index.mjs. This is probably something that spago run should generate. The alternative is to run it fromt he cli:

node -e "import('./output/Main/index.js').then(m => m.main())"

Running

purs --version # make sure you get v0.15.0
cd example-ps-esm
spago build
cd ..

cd project-node
spago build
node index.mjs # use the wrapper
# or run it directly
node -e "import('./output/Main/index.js').then(m => m.main())"

Output

Hello from my project
Hello from CJS
Hello from ESM
Hello from Purescript ESM
Hello from Purescript ESM via FFI