
Paige, Jack, Paul, and Noel dig into the biggest shifts reshaping web development right now, from OpenClaw’s foundation move to AI-powered browsers and the growing mental load of agent-driven workflows.

Discover five practical ways to scale knowledge sharing across engineering teams and reduce onboarding time, bottlenecks, and lost context.

Check out alternatives to the Headless UI library to find unstyled components to optimize your website’s performance without compromising your design.

A practical guide to building a fully local RAG system using small language models for secure, privacy-first enterprise AI without relying on cloud services.
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up now
5 Replies to "ES modules in Node.js 12, from experimental to release"
Thank you for clarification! And one question is still not covered: why .mjs? Does it mean we should have both identical. js and mjs files in a package for browsers/babel and node?
From what I understand, NodeJS developers considered several options for being able to suppor ES modules alongside existing CommonJS modules including not using the .mjs extension. At the end of the day, I believe the decision was made to use the .mjs extension because it was a simply way to identify an ES module over plain JavaScript or CommonJS modules. It also sort of fits in the JavaScript community with other frameworks and tools using file extensions as meta-data (ex. typescript uses .ts, react has .jsx, etc.). Here’s a great write up on other options that were considered: https://2ality.com/2017/05/es-module-specifiers.html.
Browsers will be able to load modules from .mjs files as well but the .mjs extension will not identify that a script contains an ES module. In the browser, you’ll need to include the type=”module” attribute on your script tags, for example:
http://./script.mjs
Probably the most noticeable change in Node 12’s new modules implementation was supporting ES modules syntax in .js files, via `”type”: “module”` in `package.json`. It’s explained in the announcement blog post: https://github.com/nodejs/modules/blob/master/doc/announcement.md#import-and-export-syntax-in-js-files
Thank you for that!
I’ve added an example using with Typescript if someone needs it: https://github.com/Urigo/typescript-node-es-modules-example
Now nodev12 is in stable, but we still need experimental-modules to enable esm/:(