Coder Social home page Coder Social logo

cjstoes's Introduction

CommonJS to ES6 module

Change the purescript output file to ES6 modules, then we can benefit from ES6 tree shaking.

Example

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;

Usage

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)
  })
}

cjstoes's People

Contributors

elona2011 avatar

Stargazers

城管大队长 avatar 下雨就像弹钢琴🎹 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.