I have tried to update my library that depends on other cjs libraries.
But I encountered a problem, that import * as foo from 'foo' treats it as
{default: {bar, baz}}
when foo/index.js contains
As I know such module representation does not match current implementations, e.g. Babel, which doesn't wrap module content into {default: ...}.
So if I write
import * as foo from 'foo'
foo.bar()
Node will complain "bar is not a function", because foo.default.bar should be used
And if I write
import foo from 'foo'
foo.bar()
Babel will complain "Cannot read property 'bar' of undefined", because default export is undefined, so foo is undefined too
I guess TS it works like Babel here.
I don't understand why module-as-default representation of a module was implemented, I think it is very weird.
So how I should write my library so it can be used with native Node and can be transpiled too?