Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

A Well-Designed JavaScript Module System is Your First Architecture Decision | CSS-Tricks

CSS-Tricks·Amejimaobari Victor·about 1 month ago
#UPQN9G14
Reading 0:00
15s threshold

Writing large programs in JavaScript without modules would be pretty difficult. Imagine you only have the global scope to work with. This was the situation in JavaScript before modules. Scripts attached to the DOM were prone to overwriting each other and variable name conflicts. With JavaScript modules, you have the ability to create private scopes for your code, and also explicitly state which parts of your code should be globally accessible. JavaScript modules are not just a way of splitting code across files, but mainly a way to design boundaries between parts of your system. Behind every technology, there should be a guide for its use. While JavaScript modules make it easier to write “big” programs, if there are no principles or systems for using them, things could easily become difficult to maintain. How ESM Traded Flexibility For “Analyzability” The two module systems in JavaScript are CommonJS (CJS) and ECMAScript Modules (ESM). The CommonJS module system was the first JavaScript module system.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More