What is modules in JS?

Welcome. Continue to grasp the modern capabilities of JavaScript(which the browser) and I can not understand what modules are. I usually used that there is a main script that connects to the page and it registers all logic and by necessity loaded all the necessary scripts, separated for ease of support. These scripts I would call modules. Now, try to use import/export in my main script, I found that nothing works. If you believe the manuals, you need to assign type="module" even the main script. It slightly breaks my logic. It turns out the entire modern js's module and type="module" it's just an indication that I want to use import/export within the script?
April 7th 20 at 11:03
2 answers
April 7th 20 at 11:05
Solution
Here you can read
ie just accept that
A module is simply a file. One script is a single module.

and more questions asked? - dallin.Yundt5 commented on April 7th 20 at 11:08
Well, if very rough, Yes. The modules can encapsulate, i.e., to isolate the back from the front-end parts. In addition, the isolated names of variables, functions, ie, the same names can be reused in your code, and they in no way overlap with the names in the modules. Additionally, you can change to assign aliases to the names of exported functions
import { foo as bar } from 'rxjs';
bar(); // runs foo with a new name bar
- makenzie_Wilkinson commented on April 7th 20 at 11:11
@elnora.Schu, thanks, I generally know what modules I am confused by exactly what had to designate the module as the main script, i.e. point of entry into the program only for import/export. If you think that the entry point can be called the very page to which connects the script, then it makes more sense. It turns out that if I don't use any collector to collect all in single file, always it is necessary to designate a plug-in scripts as modules to get access to all the buns? - dallin.Yundt5 commented on April 7th 20 at 11:14
@Oral.Crist, Yes, it seems so. - makenzie_Wilkinson commented on April 7th 20 at 11:17
April 7th 20 at 11:07
Look at the difference and understand: includeHTML is also the loader js-scripts: sort of the same modules, but easier to use and their code is always executed, if there was a real demand download.
I usually used that there is a main script that connects to the page and it registers all logic and by necessity loaded all the necessary scripts, separated for ease of support. These scripts I would call modules.
here is all is well!

However, it's not the modules, which are described here.

PS: Libo wrote for himself.
The reason is the same: too labor-intensive, each script writing/perepisyvat and debug under set requirements.
But it is not a replacement for each the complexity of the project - there is always your tool.

Find more questions by tags JavaScript