Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The problem isn't the .mjs extension, but the unfortunate ability to import CommonJS modules, when that can already be done via require().

Dependency edges out of module land should be explicit, because those aren't going to work on the web, and the web matters more than node.



I think this decision is also short-sighted since ES Modules are now JS and CommonJS should be phased out over time, but now CommonJS is the default and holds the .js extension just complicating everything for short-term ease of use.

They should have left requiring for CJS modules and let things be crappy for a while as requires and CJS are phased out. Eventually only ESM would remain except for in some abandoned packages, which could still be required.

But now CJS is going to live forever because it's the default and ESM is opt in.


I asked about the import syntax[0] and got an answer on GitHub.

[0]: https://github.com/nodejs/node/pull/14369#issuecomment-32903...




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: