4 ms·
Yeah I am sad that ES6 imports don't allow for easy namespacing. You can get around this with a double barrel. In the outer barrel, export your individual thin
by apatheticonion 6y ago
Yeah I am sad that ES6 imports don't allow for easy namespacing.
You can get around this with a double barrel. In the outer barrel, export your individual things
// index.barrel.js
export * from './foo.js'
Then in your main barrel re-export them under a namespace
// index.js
export * as foobar from './index.barrel.js'
Then from you application you are forced to have a named import with the namespace defined
// main.js
import { foobar } from './foobar/index.js'
foobar.foo()
You can submit a proposal to introduce namespacing to ES6 imports