<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CommonJS on cloudmato.com</title><link>https://cloudmato.com/tags/commonjs/</link><description>Recent content in CommonJS on cloudmato.com</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>cloudmato.com</managingEditor><webMaster>cloudmato.com</webMaster><lastBuildDate>Mon, 01 Jun 2026 16:37:22 +0530</lastBuildDate><atom:link href="https://cloudmato.com/tags/commonjs/index.xml" rel="self" type="application/rss+xml"/><item><title>JavaScript Module Systems: require, import, .mjs &amp; More</title><link>https://cloudmato.com/posts/javascript-module-systems-require-import-mjs/</link><pubDate>Mon, 01 Jun 2026 16:37:22 +0530</pubDate><author>cloudmato.com</author><guid>https://cloudmato.com/posts/javascript-module-systems-require-import-mjs/</guid><description>&lt;p&gt;JavaScript once had no built-in way to split code across files — a limitation that spawned an entire ecosystem of competing module formats. Today, developers encounter &lt;code&gt;require()&lt;/code&gt;, &lt;code&gt;import&lt;/code&gt;, &lt;code&gt;.mjs&lt;/code&gt;, &lt;code&gt;.cjs&lt;/code&gt;, AMD, and UMD, often all in the same project. This guide demystifies every module system, explains when to use each, and maps out the clear path forward.&lt;/p&gt;
&lt;h2 class="header-anchor-wrapper"&gt;Why JavaScript Needed Module Systems
&lt;a href="#why-javascript-needed-module-systems" class="header-anchor-link"&gt;
&lt;svg
xmlns="http://www.w3.org/2000/svg"
width="1rem" height="1rem" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"&gt;
&lt;line x1="4" y1="9" x2="20" y2="9"&gt;&lt;/line&gt;&lt;line x1="4" y1="15" x2="20" y2="15"&gt;&lt;/line&gt;&lt;line x1="10" y1="3" x2="8" y2="21"&gt;&lt;/line&gt;&lt;line x1="16" y1="3" x2="14" y2="21"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In the early days of the web, JavaScript was a scripting language meant for simple page interactions. As applications grew, developers stuffed everything into global variables — leading to naming collisions and unmaintainable &amp;ldquo;spaghetti&amp;rdquo; code [1]. The community responded by inventing module patterns outside the language itself: first Immediately Invoked Function Expressions (IIFEs) to create private scopes, then formal module specifications like AMD and CommonJS. Only in 2015 did JavaScript finally gain a native module system via the ES6 specification [6].&lt;/p&gt;</description></item></channel></rss>