Reputation:
I have an application that requires to import some modules every time I create a new view; is there a pattern to create some kind of "bundle" of imports and them import the bundle instead of importing separate modules every time?
example:
import x from 'x'
import y from 'y'
would be something like
import bundle from 'viewBundle'
Upvotes: 0
Views: 115
Reputation: 211
When modules are exported, they're placed into an Object. So you could simply create a singular file that exports both x and y and then import using Object destructuring.
It would look like so when imported:
import {x,y} from 'bundledFile'
Upvotes: 1