zephyr: Zephyr tree shaking for PureScript Language

[ development, library, mpl, program ] [ Propose Tags ]

Tree shaking tool and partial evaluator for PureScript CoreFn AST.


[Skip to Readme]
Versions 0.1.1.0, 0.1.4, 0.2.0
Dependencies aeson (>=1.0 && <1.3), ansi-terminal (>=0.7.1 && <0.9), ansi-wl-pprint, base (>=4.8 && <4.11), base-compat (>=0.6.0), boxes (>=0.1.4 && <0.2.0), bytestring, containers, directory (>=1.2.3), filepath, formatting, Glob (==0.9.*), language-javascript (>=0.6.0.11 && <0.7), mtl (>=2.1.0 && <2.3.0), optparse-applicative (>=0.13.0), purescript (==0.12.*), safe (>=0.3.14 && <0.4), text, transformers (>=0.3.0 && <0.6), transformers-base (>=0.4.0 && <0.5), transformers-compat (>=0.3.0), utf8-string (==1.*), zephyr [details]
License MPL-2.0
Copyright (c) 2017-2018 Marcin Szamotulski
Author Marcin Szamotulski <profunctor@pm.me>
Maintainer Marcin Szamotulski <profunctor@pm.me>
Category Development
Home page https://github.com/coot/zephyr#readme
Source repo head: git clone https://github.com/coot/zephyr
Uploaded by coot at Sat Sep 15 19:03:14 UTC 2018
Distributions NixOS:0.1.4
Executables zephyr
Downloads 133 total (40 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2018-09-15 [all 2 reports]
Hackage Matrix CI

Modules

[Index]

Flags

NameDescriptionDefaultType
test-with-cabal

use `cabal exec zephyr` in tests

DisabledManual

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for zephyr-0.2.0

[back to package description]

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

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

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.