You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed one of the last commits by @tomalrussell was cleaning up the d3 imports a bit. This has been annoying how d3 needs to be imported in projects relying in ES6 modules in quite a different manner than it used to work back in the days of global objects. Especially when you need to use functions from more than two submodules in one file.
Recently I came up with this approach on a different project:
The d3 object contains all the exports from all the installed submodules. They need to be manually destructured just once in this central file. Later, it's enough to just import d3 from this file, and because it's a named export, it works well with IntelliSense etc. Usage is:
I noticed one of the last commits by @tomalrussell was cleaning up the d3 imports a bit. This has been annoying how d3 needs to be imported in projects relying in ES6 modules in quite a different manner than it used to work back in the days of global objects. Especially when you need to use functions from more than two submodules in one file.
Recently I came up with this approach on a different project:
[in a file such as
/lib/d3.ts
]:The
d3
object contains all the exports from all the installed submodules. They need to be manually destructured just once in this central file. Later, it's enough to just importd3
from this file, and because it's a named export, it works well with IntelliSense etc. Usage is:The
D3
namespace helps with the fact that it's not possible to destructure and re-export types. Usage is:I won't change this for now, but something to consider. I've been quite happy with the DX this provides on other projects.
The text was updated successfully, but these errors were encountered: