0

In my PureScript 'Main' module, in file Main.purs, something like this:-

test :: Boolean
test = true

will be exported in the compiled, bundled and optimised JavaScript output, and will be available to my JS code.

But if I have another .purs file (in the same src folder), which declares another module, and it has:-

test1 :: Boolean
test1 = true

then this is not exported in the output JS when pulp builds the project.

I tried importing the other module into Main.purs, but got an error saying that the import was redundant.

What should I do to have test1 appear in the built JavaScript file?

Bellarmine Head
  • 3,397
  • 2
  • 22
  • 31
  • My pulp build command looks like this:- `pulp build --optimise --to "$(ProjectDir)Scripts\app\ps\purescript-dist.js"`. I want optimization so I can easily read the output JS. – Bellarmine Head Jan 22 '17 at 18:17

2 Answers2

2

The answer, via @hdgarrood, is to use the --modules <comma-separated list of module names> build option; so my build command now becomes:-

pulp build --optimise --to "$(ProjectDir)Scripts\app\ps\purescript-dist.js" --modules MyOtherModule

Bellarmine Head
  • 3,397
  • 2
  • 22
  • 31
1

Have you tried this

module MyModule (test1) where
    test1 :: Boolean
    test1 = true

basically on your module definition you announce which values and types you want to export.
See also https://github.com/purescript/purescript/wiki/Export-lists

robkuz
  • 9,488
  • 5
  • 29
  • 50
  • Are you using that module somewhere in your code? I remember (i think) that there was an issue of pulp excluding stuff that is not being used – robkuz Jan 22 '17 at 18:18
  • No, I'm not using that module anywhere else in my PureScript code. Nor do I want to... just yet. – Bellarmine Head Jan 22 '17 at 18:19
  • try to at least simply import it in your main module. Pulp (or even psc) goes thru your code and excludes stuff not used. At least so you can check if this is a build issue or something completely different – robkuz Jan 22 '17 at 18:24
  • If I import `test1` into Main.purs, it will be included in the built JS - as you might expect. But I don't know if this is all by design - or, as you suggest, pulp is excluding stuff that isn't referenced explicitly by PS code. – Bellarmine Head Jan 22 '17 at 18:26
  • Have a look into Purescript by Example "2.7 Removing Unused Code Pulp provides an alternative command, pulp build, which can be used with the -O option to apply dead code elimination, which removes unnecessary Javascript from the output. The result is much smaller:" – robkuz Jan 22 '17 at 18:31