mardi 6 août 2019

ES6 Modules vs Module design patterns

After the introduction of ES6 modules(import/export) , do we really care about the module pattern/Revealing module pattern. since the namespace behaviour is acheived with ES6 modules

ex:

//library.js
export function foo(){ ... }
export function somethingelse(){ ... }
...

   OR
var libfunctions = {
  foo: function(){ ... },
  somethingelse: function { ... },
  ...
}
export default libfunctions;

//index.js

import {foo, somethingelse, ...} from './library';
/*Considering there can be a duplicate function from some other library 
then we have the alias(as) utility in **import** */
ex: 

import {foo, somethingelse, ...} from './library';
import {foo as <sometext>, ...} from './another-library';


Considering in the module and revealing module pattern is acheived by ES6 modules, then what other new patterns are introduced by ES6.

Here I am just pointing out my thoughts, Please help me by answering this question and understanding the design patterns better.

Aucun commentaire:

Enregistrer un commentaire