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
Functional imports when using multiple collections is fiddly and messy because you end up with loads of imports to manage in every source file, and you have to use aliasing a lot to account for commonalities among function names (e.g. freeze, get, etc.). I've discovered that a good pattern is to create an internal collections script that imports all of the required functions and exports them as unified collection types/namespaces. It's better for this to be done by the consuming application, because you lose the ability to tree-shake unused imports, so you want to make sure you only expose the methods you're actually using.
In the docs area, I want a page that lets you select all the collections and methods you want, then automatically generates a script with all of imports and exports ready to go.
import{getasmapGet,setasmapSet, ......................................}from'@collectable/map';import{getaslistGet,setaslistSet, ......................................}from'@collectable/list';// and way more imports here
The latter is much easier to manage, it doesn't suffer from having to constantly organise your imports as your code evolves to use or not use a given named import, and you still get tree-shaking, because even though you've bundled a bunch of functions into a singular export, you still have control over what your application uses, without dragging in extraneous stuff that will bloat your bundle with redundant code.
Functional imports when using multiple collections is fiddly and messy because you end up with loads of imports to manage in every source file, and you have to use aliasing a lot to account for commonalities among function names (e.g.
freeze
,get
, etc.). I've discovered that a good pattern is to create an internal collections script that imports all of the required functions and exports them as unified collection types/namespaces. It's better for this to be done by the consuming application, because you lose the ability to tree-shake unused imports, so you want to make sure you only expose the methods you're actually using.In the docs area, I want a page that lets you select all the collections and methods you want, then automatically generates a script with all of imports and exports ready to go.
Example script that would be generated:
The text was updated successfully, but these errors were encountered: