Live data from Hacker News

Modern Node.js Patterns

kashw1n.com

281–290 of 448 posts

Re: Modern Node.js Patterns

#282
post #130

Perhaps the technology that you are using is loaded with hundreds of foot-guns if you have to spend time on enforcing these patterns. Rather than taking the logical focus on making money, it is wasting time on shuffling around code and being an architecture astronaut with the main focus on details rather than shipping. One of the biggest errors one can make is still using Node.js and Javascript on the server in 2025.

What the f are you even talking about. It literally lists features modern Node.js has, there’s nothing to enforce.

Re: Modern Node.js Patterns

#284
post #41

Nice post! There's a lot of stuff here that I had no idea was in built-in already. I tried making a standalone executable with the command provided, but it produced a .blob which I believe still requires the Node runtime to run. I was able to make a true executable with postject per the Node docs[1], but a simple Hello World resulted in a 110 MB binary. This is probably a drawback worth mentioning. Also, seeing those…

Yeah, many people here are saying this is AI written. Possibly entirely.

It says: "You can now bundle your Node.js application into a single executable file", but doesn't actually provide the command to create the binary. Something like:

    npx postject hello NODE_SEA_BLOB sea-prep.blob \
        --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2

Re: Modern Node.js Patterns

#285
post #242
post #113

Whoa, I didn't know about this: # Run with restricted file system access node --experimental-permission \ --allow-fs-read=./data --allow-fs-write=./logs app.js # Network restrictions node --experimental-permission \ --allow-net=api.example.com app.js Looks like they were inspired by Deno. That's an excellent feature. https://docs.deno.com/runtime/fundamentals/security/#permiss...

I very much dislike such features in a runtime or app. The "proper" place to solve this, is in the OS. Where it has been solved, including all the inevitable corner cases, already. Why reinvent this wheel, adding complexity, bug-surface, maintenance burden and whatnot to your project? What problem dies it solve that hasn't been solved by other people?

How many apps do you think has properly set user and access rights only to what they need? In production? If even that percentage was high, how about developers machines, people that run some node scripts which might import whoever knows what? It is possible to have it running safely, but I doubt it's a high percentage of people. Feature like this can increase that percentage

Re: Modern Node.js Patterns

#286
Hi, regarding streams interoperability I've documented how to handle file streams a while ago, after experimenting with Next.js old system (Node.js based) and new system (web based) : https://www.ericburel.tech/blog/nextjs-stream-files#2024-upd.... It sums up as "const stream = fileHandle.readableWebStream()" to produce a web stream using Node.js fs, rather than creating a Node.js stream.

Re: Modern Node.js Patterns

#288

Earlier quoted context omitted.

I have a blog post[1] and accompanying repo[2] that shows how to use SEA to build a binary (and compares it to bun and deno) and strip it down to 67mb (for me, depends on the size of your local node binary). [1]: https://notes.billmill.org/programming/javascript/Making_a_s... [2]: https://github.com/llimllib/node-esbuild-executable#making-a...

> 67 MB binary I hope you can appreciate how utterly insane this sounds to anyone outside of the JS world. Good on you for reducing the size, but my god…

Considering that you are bundling an entire runtime not meant to be installed independently on other computers, 67mb isn't that bad.

Go binaries weight 20mb for example.

Re: Modern Node.js Patterns

#289
Am I the only one believing common js was super ok and don't like esm? Or put differently I didn't see the necessity of having esm at all in Node. Let alone the browser, imagine loading tons of modules over the wire instead of bundle them

Re: Modern Node.js Patterns

#290

Am I the only one believing common js was super ok and don't like esm? Or put differently I didn't see the necessity of having esm at all in Node. Let alone the browser, imagine loading tons of modules over the wire instead of bundle them

You can still bundle them, maybe you even should. Webpack still does a good job. Can also remove unused parts.
Post reply on HN