Giter Site home page Giter Site logo

cjstoesmodule's Introduction

cjsToEsModule

A project to convert commonJS require to es6 import

Why?

Lets face it , if you have a javaScript app that has a build process involving webpack/rollup and you are not doing code optimization like code splitting and tree shaking, then you are not delivering it for audience in 2019+. If your app is built with commonJS (which was the standard in 2014, before es module spec was released) you cannot achive any of those optimizations in build process.

With features like modules and moduleMap getting builtIn to chrome and firefox , lets utilize it and cut the network dependent loading time for apps.

Fast loadTimes adds to better user experiences and its not a good idea to take it for granted

Goal

  1. require should be converted to import
const a = require('a') -> import a from 'a'
  1. Individual modules should work as well
const { b } = require('a') -> import { b } from 'a'
const b = require('a').b -> import { b } from 'a'
  1. Multiple require/import statements to one import, if its from same module
const c = require('a').c     | -> import a,{ b, c, d, e } from 'a'
const a = require('a')       |
const { d } = require('a')   |
import { e } from 'a'        |
  1. Dealing module.exports
// deafult export
module.exports = a -> export default a
// named export
module.exports = { b, c} -> export { b, c }

How(to contribute)?

The code for this will be in the src folder.

All the above mentioned goals will be created as issues.

Typescript will be used for both development and unit tests.

Fork this Repo and submit PR's to close the above issues!.

This app shall also work as CLI app

Once the above mentioned goals are accomplished, this readme should be re written for installation and usage instructions

cjstoesmodule's People

Contributors

akshayupadhya avatar

Watchers

 avatar  avatar

cjstoesmodule's Issues

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.