0

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'
  • Possible duplicate of [Is it possible to import modules from all files in a directory, using a wildcard?](https://stackoverflow.com/questions/29722270/is-it-possible-to-import-modules-from-all-files-in-a-directory-using-a-wildcard) – Nino Filiu Jul 12 '19 at 16:25

1 Answers1

1

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'

James
  • 201
  • 2
  • 7