I can do:
import fs from 'fs'
//now use fs normally
fs.open('file')
But I can't do the same with the modules I write:
import myModule from 'myModule'
^^^^^^^^
SyntaxError: The requested module 'myModule' does not provide an export named 'default'
I am forced to do:
import * as myModule from 'myModule'
//now use myModule normally
myModule.do_something()
Is it possible to automatically export all the named exports in the default one so that it's not required to import * as?
you cannot export multiple default exports. use named exports instead.
example here is the exported modules from a file named Test.js:
export const namedVar = "named1";
export const do_something = () => console.log("do something");
you can use it this way:
import { namedVar, do_something } from './Test'
console.log(namedVar);
console.log(do_something());