Skip to content
Tree shaking breeze for PureScript CoreFn AST
Haskell Nix PureScript Other
Branch: master
Clone or download
colinwahl and coot bump purescript version to 0.13.3 (#21)
* bump purescript to 0.13.2

* Fix non-exhaustive pattern matching on JSStatement and JSExpression

* add base-4.11.1.0 to extra-deps

* bump stack version

* test

* version adjustments

* work this time

* address some feedback
Latest commit 8017f8c Sep 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app bump purescript version to 0.13.3 (#21) Sep 14, 2019
bundle Updated build script & deployment May 30, 2018
nix Use PureScript ffiCodegen Sep 24, 2018
src/Language/PureScript bump purescript version to 0.13.3 (#21) Sep 14, 2019
test Amend test Sep 16, 2018
.gitignore
.travis.yml Bump nodejs version in travis Sep 16, 2018
LICENSE license: mpl-2.0 Aug 19, 2017
README.md
Setup.hs
appveyor.yml bump purescript version to 0.13.3 (#21) Sep 14, 2019
cabal.project QuickCheck tests Sep 9, 2018
default.nix Nix & cabal Sep 20, 2018
pkg.nix Version v0.2.1 Sep 16, 2018
shell.nix nix changes Sep 20, 2018
stack.yaml
zephyr.cabal bump purescript version to 0.13.3 (#21) Sep 14, 2019

README.md

zephyr

Maintainer: coot Travis Build Status Appveyor Build Status

Experimental tree shaking tool for PureScript.

Usage

# compile your project (or use `pulp build -- -g corefn`)
purs compile -g corefn bower_components/purescript-*/src/**/*.purs src/**/*.purs

# run `zephyr`
zephyr -f Main.main

# bundle your code
webpack

or you can bundle with pulp:

pulp browserify --skip-compile -o dce-output -t app.js

You can also specify modules as entry points, which is the same as specifying all exported identifiers.

# include all identifiers from Data.Eq module
zephyr Data.Eq

# as above
zephyr module:Data.Eq

# include Data.Eq.Eq identifier of Data.Eq module
zephyr ident:Data.Eq.Eq

# include Data.Eq.eq identifier (not the lower case of the identifier!)
zpehyr Data.Eq.eq

zephyr reads corefn json representation from output directory, removes non transitive dependencies of entry points and dumps common js modules (or corefn representation) to dce-output directory.

Zephyr eval

Zephyr can evaluate some literal expressions.

import Config (isProduction)

a = if isProduction
  then "api/prod/"
  else "api/dev/"

will be transformed to

a = "api/prod/"

whenever isProduction is true. This allows you to have different development and production environment while still ship a minified code in your production environment. You may define isProduction in a module under a src-prod directory and include it when compiling production code with pulp build -I src-prod and to have another copy for your development environment under src-dev where isProduction is set to false.

Build & Test

To build just run stack build (or with nix stack --nix build). If you want to run test stack --nix test is the prefered method, stack test will also work, unless you don't have one of the dependencies: git, node, npm and bower.

Comments

The -f switch is not 100% safe. When on zephyr will remove exports from foreign modules that seems to be not used: are not used in purescript code and seem not to be used in the foreign module. If you simply assign to exports using javascript dot notation then you will be fine, but if you use square notation exports[var] in a dynamic way (i.e. var is a true variable rather than a string literal) then zephyr might remove code that shouldn't be removed.

It is good to run webpack or rollup to run a javascript tree shaking algorithm on the javascript code that is pulled in your bundle by your by your foreign imports.

You can’t perform that action at this time.