Live data from Hacker News

(ab?)using Node module hooks to speed up development

immaculata.dev

11–17 of 17 posts

Re: (ab?)using Node module hooks to speed up development

#13
post #3

Earlier quoted context omitted.

Using. But also maybe abusing.

I think he's proposing a fix for the regex in the title. /(ab?)using/ matches: - ausing - abusing while /(ab)?using/ matches: - using - abusing

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

#14

With Typescript you could(prob still can) specify how JSX tags are translated, so you can get the regular data structure without React dependency.

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

#16

This is a reinvention of HMR, no?

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.

Post reply on HN