Change the purescript output file to ES6 modules, then we can benefit from ES6 tree shaking.
Control.Alt/index.js:
// Generated by purs version 0.11.7
"use strict";
var Data_Functor = require("../Data.Functor");
var Data_Semigroup = require("../Data.Semigroup");
var Alt = function (Functor0, alt) {
this.Functor0 = Functor0;
this.alt = alt;
};
var altArray = new Alt(function () {
return Data_Functor.functorArray;
}, Data_Semigroup.append(Data_Semigroup.semigroupArray));
var alt = function (dict) {
return dict.alt;
};
module.exports = {
Alt: Alt,
alt: alt,
altArray: altArray
};
Out goes ES6 js:
'use strict';
import { Data_Functor_functorArray } from '../Data.Functor';
import {
Data_Semigroup_append,
Data_Semigroup_semigroupArray
} from '../Data.Semigroup';
var Alt = function (Functor0, alt) {
this.Functor0 = Functor0;
this.alt = alt;
};
var altArray = new Alt(function () {
return Data_Functor_functorArray;
}, Data_Semigroup_append(Data_Semigroup_semigroupArray));
var alt = function (dict) {
return dict.alt;
};
export var Control_Alt_Alt = Alt;
export var Control_Alt_alt = alt;
export var Control_Alt_altArray = altArray;
const cjstoes = require('cjstoes')
const fse = require('fs-extra')
const glob = require('glob')
const { readFileSync, writeFileSync } = require('fs')
module.exports = () => {
fse.copySync(`${process.cwd()}/output`, `${process.cwd()}/.es6`)
glob.sync(`${process.cwd()}/.es6/**/*.js`).forEach(file => {
let f = readFileSync(file, 'utf8')
let nf = cjstoes(f, file)
writeFileSync(file, nf)
})
}