D
D
Dmitry Ivchenkov2019-11-17 21:30:40
npm
Dmitry Ivchenkov, 2019-11-17 21:30:40

How to make dynamic import of many modules through 1 file?

There are many libraries and modules that are connected in the same way to various components. The project has babel and webpack.
Read these articles:

  • Export and import
  • Dynamic Imports

I did this (a special react mini-project to test this possibility):
Link to a mini-project based on the "learn.javascript.ru" resources.
But with this option, I will have to list many modules in each component (we are talking about large applications where it is too time-consuming to fix imports).
1. Is it possible to import libraries into a separate file and include the '../shared-sources' file (which is index.js) into a component without listing all modules? That is, without listing the modules themselves, I want to automatically import them from an external file (and list everything there).
2. Or, if possible, make sets of imports. For example, separately for components, separately for middleware plugins.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Dozmorov, 2019-11-18
@Dzmitryj_Black

You are most likely looking for https://webpack.js.org/plugins/provide-plugin/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question