Answer the question
In order to leave comments, you need to log in
How to run imported functions automatically?
How to automatically run everything imported from a file? In order not to write this construction manually:
import {Body} from "../../components/body/body";
new Body(); // Нужно чтобы new Body() Автоматом работала
Answer the question
In order to leave comments, you need to log in
1) This is not correct in terms of writing and organizing code. Because it is not clear where this function came from in the context of the file. There can be 100,500 such functions, from which there is no clear understanding, from where it does not give an understanding, and what functions exist at all. + there can be 2 or more identical functions, but from different files, solving the same tasks, but in the context of their class or object, it doesn't matter! How are you going to deal with this moment? And how can others avoid such things after that? In short, there will be serious problems with naming!!!
2) You are killing the very essence of webpack as a module builder, because you initially import everything you have when you don't need it. webpack, as it were, loads the necessary chunks when they are needed, otherwise there is no sense in it. And you want to kill it all.
On business:
1) Components can be connected globally, just create a file in which import all the components you need, connect them. Then just import this file into the root executable.
2) You can write your own generator that will go through the directory you need and connect all the necessary modules wherever you want.
PS what's wrong? Are you so good at writing this? All languages work this way!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question