Sign in
Log inSign up

Splitting Javascript library into modules

Panagiotis Vourtsis's photo
Panagiotis Vourtsis
·Dec 13, 2016

Hi, I want some opinions regarding a change that i want to do. I currently have a library of js (one file) written in ES5. This lib has a main function that behaves as a class and does certain things plus has some utility functions as prototypes. This function is beign called several times (new Lib()). Also lib holds a config object with default values that on class initialization this can change e.g

var lib = new Library();
lib.init({
    a: "a",
    b: "b"
});

What i want to do is to split the library to different modules and have a main.js that will call the helpers to build the outcome.

My question is now that is it better to do that with ES6? I've seen several implementations on ES6 or ES5 with rollup.

What do you suggest.