K
K
KondakovVE2018-06-23 12:18:50
Node.js
KondakovVE, 2018-06-23 12:18:50

ES6 export default (app)=>{} - returns an object. How to return a function?

Hello. Dealing with a training example, I ran into an already known problem.

module.export = app => { ... }
import foo from 'module' //foo = function(app)

export default app => { ... } 
import foo from 'module' //foo = { default : function (app)}

In principle, there are no problems using foo.default() in the code, but there are modules for autoloading (well, for example, consign, which breaks.
Is it possible to export in ES6 style in some other way so that the import (or at least require) takes exactly the function?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2018-06-23
@mak_ufo

Use require, not import

A
Abcdefgk, 2018-06-24
@Abcdefgk

export {foo}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question