Skip to content

Instantly share code, notes, and snippets.

View Pauan's full-sized avatar

Pauan

View GitHub Profile
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class
import Control.Monad.Aff (launchAff, Aff, makeAff, attempt)
import Control.Monad.Aff.Console (CONSOLE, log)
import Control.Monad.Eff.Exception (Error, try)
import Network.HTTP.Affjax as Ajax
import Data.Either (Either(..), either)
@Pauan
Pauan / commonjs-to-es6-modules.js
Created September 30, 2016 02:33 — forked from wegry/commonjs-to-es6-modules.js
purescript psc 0.9 output webpack loader that allows tree shaking
"use strict"
/*
* Webpack 2 loader that can take CommonJS output by psc 0.9.1 and convert
* it into tree shakable ES6 modules. No transpiling required.
*/
const fs = require('fs')
const commonJsRequire = /var ([_$a-zA-Z0-9]+) = require\([\'\"]([^\'\"]+)[\'\"]\)/g
const moduleExports = /module\.exports = \{(\n( ([\"\'_$a-zA-Z0-9]+): ([_$a-zA-Z0-9\.]+)(, )?\n)*)?\};/m