packages feed

Shpadoinkle-backend-snabbdom-0.3.0.2: README.md

# Shpadoinkle Backend Snabbdom

[![Goldwater](https://gitlab.com/platonic/shpadoinkle/badges/master/pipeline.svg)](https://gitlab.com/platonic/shpadoinkle)
[![Haddock](https://img.shields.io/badge/haddock-master-informational)](https://shpadoinkle.org/backend-snabbdom)
[![BSD-3](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![built with nix](https://img.shields.io/badge/built%20with-nix-41439a)](https://builtwithnix.org)
[![Hackage](https://img.shields.io/hackage/v/Shpadoinkle-backend-snabbdom.svg)](https://hackage.haskell.org/package/Shpadoinkle-backend-snabbdom)
[![Hackage Deps](https://img.shields.io/hackage-deps/v/Shpadoinkle-backend-snabbdom.svg)](http://packdeps.haskellers.com/reverse/Shpadoinkle-backend-snabbdom)
[![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/Shpadoinkle-backend-snabbdom/badge)](https://matrix.hackage.haskell.org/#/package/Shpadoinkle-backend-snabbdom)

This package contains a script to setup the [Snabbdom](https://github.com/snabbdom/snabbdom) virtual dom library as a backend to render Shpadoinkle applications.

> Snabbdom consists of an extremely simple, performant, and extensible core that is only ≈ 200 SLOC. It offers a modular architecture with rich functionality for extensions through custom modules. To keep the core simple, all non-essential functionality is delegated to modules.

These design decisions made Snabbdom a good fit for Shpadoinkle's first high-performance pure JavaScript backend. Right now Snabbdom is being provided statically, and a [slightly modified build](https://github.com/fresheyeball/snabbdom) is included in this repo. Although this increases the size of the resulting executable, it's necessary for reproducible and stable builds.

# Building

In order to re-build `Shpadoinkle/Backend/Snabbdom/Setup.js`, it needs to be bundled with a tool like [parcel](https://parceljs.org/) - the following methodology is how it's currently done:

```bash
# clone outside the source directory of Shpadoinkl
git clone git@github.com:snabbdom/snabbdom.git
# compile its typescript so we can bundle the javascript
cd snabbdom && npm install && npm run compile
# Setup_src.js imports the snabbdom sources locally, so we need to manually move it
cp path-to-shpadoinkle/backends/snabbdom/Shpadoinkle/Backend/Snabbdom/Setup_src.js build/package/
# nix is most reliable for running parcel
nix-shell -p nodePackages.parcel-bundler --command "parcel build build/package/Setup_src.js"
# copy the bundled output as Setup.js
cp dist/Setup_src.js path-to-shpadoinkle/backends/snabbdom/Shpadoinkle/Backend/Snabbdom/Setup.js
```

Now when you build your shpadoinkle project, this new `Setup.js` will be statically allocated with your GHCJS output.