Should ESM be the default?
Should ESM be the default in Node.js? We will also cover Platformatic v1 announcements, hung Node.js processes, and the Cloudflare announcements
Hi Folks,
Last week was a big week for me and the team at Platformatic– we finally launched v1.0.0, and I could not be more excited to share it all with you!
This launch is important because it includes features I was desperate to have during my many years as a software consultant. What we released last week would have saved me countless hours, headaches, and deployment errors. While I can’t turn back the clock, I look forward to seeing others in my position have access to Platformatic and avoid these issues. So, what did we ship?
- Breaking Change Detector: Offers a view of a change's impact on the public API level of your microservices ecosystem and which teams it will affect. The detector maps out dependencies and interactions with OpenTelemetry. I recorded a demo showing you how it works We looked at why a tool like this is essential, how it can help enterprise teams, and how it works in more detail here.
- Stackables: Take your configurations, package them into shareable modules, and publish them on your internal npm registry, enabling teams in your organization to access and utilize the same core configuration. Check out the demo I recorded on how to use them or took a look at how Stackables work and how they can benefit your development team.
- Platformatic open source goes 1.0.0, which means no breaking changes for a while.
Lastly, my co-founder Luca and I answered some of the main questions we received in the days after the launch went live. You can check that out here: https://www.youtube.com/watch?v=oOrQm-95TWQ
Should ESM be the default?
Are you still developing commonjs applications, or have you switched to ESM for everything? The team at Node.js has been quite busy, and a new experimental flag appeared: --experimental-default-type=module
. This changes the default module type of js
file extensions from commonjs
to esm
, i.e., .mjs
becomes the default.
This flag changes a few things about how modules are loaded:
-
ESM-only packages, like
node-fetch
: The flip has no effect on either the package author or its consumers. -
CommonJS-only packages, like
fastify
; have no effects for its consumers. Maintainers need to add"type": "commonjs"
topackage.json
.
Take a look at https://github.com/nodejs/TSC/issues/1445 and https://github.com/nodejs/node/pull/49869
More thoughts on Bun / JSParty
JS Party 294: Reports for Node's death are greatly exaggerated – Listen on Changelog.com
Debugging hanging processes
In Node v20.x, we have been seeing many hung processes remaining "hung" and not completely. This concerns Native/V8 Code Coverage integration with Node.js, executing code in process.on('exit')
handlers, FinalizationRegistry
, and possibly a few more cases.
We are discussing this issue in Node.js core at #49344.
I've shipped two "duck tape" fixes in pino and undici to help address this issue, which both disable the FinalizationRegistry
integration:
-
Release v8.15.3 · pinojs/pino · GitHub
What's Changed Disable FinalizationRegistry if node code coverage is active by @mcollina in #1819 Full Changelog: v8.15.2...v8.15.3
-
Release v5.25.3 · nodejs/undici · GitHub
What's Changed perf: improve parse-url implementation by @anonrig in #2286 test: enable websockets inclusion in WPTReport by @panva in #2284 remove npm run test from pre-commit hook by @dancastill...
Tap also shipped a hot fix to reduce the frequency of the problem in #934.
Please let me know if you are experiencing this issue as well.
Releases
- @fastify/multipart v8.0.0 removes deprecated
addToBody
and return files as buffers whenattachFieldsToBody
is set tokeyValues
. - pino v8.15.2 enables named exports in browser.js and exports the LoggerExtras interface in the types.
- @fastify/throttle v2.0.0 allows async
bytePerSecond
functions. - busboy v2.0.0 throws when there is no boundary.
Articles
- Raspberry Pi goes v5, including a massive performance boost. I'm actually genuinely excited for the tiny HW. Could it become a daily driver if paired with a fast SSD?
- Cloudflare announced massive improvements to Workers. The one that I'm most excited about is the new pricing model, that stops you from paying if your process is idle; Another great feat of engineering is hyperdrive, which allows Cloudflare to do connection pooling for you.
- Given that jQuery is the most popular web framework, it's important to know how to use jQuery with Astro
- Read Isaacs notes on Test Assertion Styles in JavaScript.
- NODE_ENV Considered Harmful
- Environment variables and configuration anti patterns in Node.js applications.
- Bun hype. How we learned nothing from Yarn
- Check out Wasmnizer-ts: Toolchain for compiling TypeScript to WasmGC.
- [Linux Foundation Launches OpenTofu: A New Open Source Alternative to Terraform](https://www.linuxfoundation.org/press/announcing-opentofu?utm_content=264841292
- Fastify introduces the new onListen Hook
- Solving the Engineering Strategy crisis.
- Do you think Bun is faster than Node.js at running Fastify?Check out this benchmark. Here is the express one.