ESM (ES Modules)
Native JS module system. import / export syntax. Standardized ES2015 (ES6). Browser support 2018, Node.js stable support 2020. Replaces CommonJS (require) in modern codebases.
Native browser: <script type="module" src="app.js">, browser handles imports without bundler. Node.js: "type": "module" in package.json or .mjs extension. Tree-shaking friendly: static analysis can remove unused imports. Top-level await support. CommonJS interop subtle (default-export confusion). Migration pain: existing CJS codebases (Express, many middleware) not fully ESM-compatible. Bun + Deno are ESM-native runtimes. 2024 trend: all new packages publish both ESM + CJS, "ESM-only" is OK for library authors now.