News for hackers. Stuff that matters.

sbjs

Re:(ab?)using Node module hooks to speed up development on Wednesday May 07, 2025 @08:51AM (#43914990)
It's a highly optimized and extremely simple yet robust implementation of it, sure. Is that reason to dismiss it?

Consider Vite's node-side HMR implementation. It creates its own module system on top of Node's native module system, using `node:vm`. So its modules are really second class citizens that have to be glued to the native module system.

This library used to do that, but moved to using Node's native module hooks, so that there's nothing magical going on, and you can still use the `import` expression to import your HMR modules, they just auto-update when saving.

Re:(ab?)using Node module hooks to speed up development on Wednesday May 07, 2025 @08:19AM (#43914713)
That's orthogonal, and in fact you probably would use TypeScript to translate JSX to JS when using this library. What this does is (a) provide a Node.js module hook to call your transpile function when it encounters TSX/JSX files, and (b) provide a Node.js module that lets you remap imports, including "react/jsx-runtime" if you want a different JSX implementation.
Re:(ab?)using Node module hooks to speed up development on Wednesday May 07, 2025 @08:10AM (#43914654)
It's English, it just looks like regex. In English, the ? belongs inside the parens in this case.
Re:(ab?)using Node module hooks to speed up development on Wednesday May 07, 2025 @07:58AM (#43914551)
Just updated the text to be hopefully much clearer.
Re:(ab?)using Node module hooks to speed up development on Wednesday May 07, 2025 @07:41AM (#43914421)
Oh no, I must have mis-explained it.

The file `site/myfile.js` does exist. All FileTree does is recursively load all files in a dir into memory.

The `useTree` module hook does two things:

* Pulls the file from memory when loading it instead of from disk

* Adds a cache busting query string when resolving it for invalidation

Combined with tree.watch(), this essentially allows you to add a very lightweight but extremely accurate hot module replacement system into Node.js

1. const tree = new FileTree('src', import.meta.url)

2. tree.watch().on('filesUpdated', () => import(tree.root + '/myfile.js'))

3. registerHooks(useTree(tree))

4. Save src/myfile.js and see it re-executed

Re:(ab?)using Node module hooks to speed up development on Wednesday May 07, 2025 @07:36AM (#43914387)
Just added some code samples, thanks for the suggestion.

Show HN: Mid-level Node.js helpers for building a front-end website

https://immaculata.dev/

Hi HN. I can't stop trying new ways to write my websites, and the web world is ever evolving. For both reasons, I stopped trying to write a build tool for developing front-ends, and wrote some helpers for Node.js that ideally would be part of any front-end build tool. They're high-enough level that you could use them directly, and low-enough level that you could build a framework on top of them...

( Read More... | no comments | on HN )
Re:Why I ever wrote Clojure on Saturday May 03, 2025 @07:09PM (#43883094)
Can't remember, was like 10 years ago. But basically after I finished mastering the last feature I needed to, probably macros.
Re:Why I ever wrote Clojure on Saturday May 03, 2025 @04:56PM (#43882240)
To clarify, I don't mean that Rich didn't also have extremely good reasons to make Clojure, given he was using Java (and maybe C++) in 2007. They're not the best languages now, but they were so broken back then that they practically caused the language revolution that caused Clojure and Go and Node etc to flourish.
Re:Why I ever wrote Clojure on Saturday May 03, 2025 @04:47PM (#43882174)
I thought it was self explanatory. It had new idioms I had not yet learned and internalized, so I fully absorbed it. When that was finished, I needed something else to do the same thing with. It's like listening to a song on repeat 10-100 times (depending on the song) when you first hear it. You get everything you can out of it and move on when it's empty.
Re:Why I ever wrote Clojure on Saturday May 03, 2025 @04:45PM (#43882159)
I guess that confirms my theory.
Re:Immaculata on Monday April 28, 2025 @06:17PM (#43826719)
Thanks, yeah it sounds like we have similar goals. Where's your project so I can take a look?
Re:A 10x Faster TypeScript on Tuesday March 11, 2025 @11:17AM (#43333326)
Your patience with Michael Saboff is incredible.
Re:I can't delete my framework on Saturday February 08, 2025 @01:53PM (#42985186)
Infeasible not because it's difficult but because you have more awareness of your limited time that you have to prioritize, and maintaining software falls lower and lower on the list of things you should do.

Show HN: A new way to create universal/ssr TypeScript apps with JSX

https://github.com/sdegutis/immaculatalibrary.com

Hi everyone. This is a project I've been evolving slowly for almost 4 years now. I'm finally happy with the technical solutions. It hasn't been extracted into a lib yet bc there was no demand for it. There's no readme because it's been changing so drastically, so here's a few notable points:1. The core is a node app under src/ that's 290 lines of typescript, which uses chokidar for...

( Read More... | no comments | on HN )
Re:Fairly sure I just made something better than React on Monday November 06, 2023 @12:40PM (#38165818)
Yes.
Re:Fairly sure I just made something better than React on Sunday November 05, 2023 @09:38PM (#38158142)
I posted an example in the thread.
Re:Fairly sure I just made something better than React on Sunday November 05, 2023 @09:06PM (#38157959)
Hi everyone. I know that's a bold statement you'd expect from a new coder and not an experienced guy unless it's the real deal. And I've got so many decades of experience that I'm really looking forward to hearing feedback :)

Older »