user10918789
user10918789

Reputation:

Export bundle of modules

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

Answers (1)

James
James

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

Related Questions