minor fixes

This commit is contained in:
Ilya Kantor 2021-05-24 11:33:37 +03:00
parent 3dbe9d13fb
commit 2fc7cb2d42

View file

@ -175,12 +175,14 @@ import {admin} from './admin.js';
alert(admin.name); // Pete
*!*
// Both 1.js and 2.js imported the same object
// Both 1.js and 2.js reference the same admin object
// Changes made in 1.js are visible in 2.js
*/!*
```
So, let's reiterate -- the module is executed only once. Exports are generated, and then they are shared between importers, so if something changes the `admin` object, other modules will see that.
As you can see, when `1.js` changes the `name` property in the imported `admin`, then `2.js` can see the new `admin.name`.
That's exactly because the module is executed only once. Exports are generated, and then they are shared between importers, so if something changes the `admin` object, other modules will see that.
Such behavior allows us to *configure* modules on first import. We can setup its properties once, and then in further imports it's ready.