I want to export all methods of a file from another file.
currently I am doing this, and it works. How can I merge below two into 1 export expression
import * as db from './web/query';
export default db;
I tried below written 1 line exports but all failed
export * from './web/query'; //==error
export * as default from './web/query'; //==error
export * as {default} from './web/query'; //==error
export from from './web/query'; //== error
export default from './web/query'; //== error
Error means
import db from '../db/index';
db is undefined here. However the the first methods works
Inside of file './web/query' looks like
export function foo(){}
export function baar(){}
You cannot in ES2016. To create a module namespace object, you need to give it an identifier (like
db
) in your current module scope, and then re-export that. There's no way around it.There is however a stage 1 proposal to add the
export * as default from …
syntax you were trying.