Better to export an object containing function, or just export multiple functions in ES6 (Is there a convention?)

Going forward, it’s probably better to export multiple functions, as tree shaking allows module bundlers to eliminate dead code based on whether it’s been imported or not.

If you export one large object, it’s not always possible to use static analysis to tell which functions need to be kept and which can be safely discarded.

If you export multiple named functions, then the module bundler can analyze the AST then safely whitelist the functions which you are actually importing.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)