Image missing.
Implementing native Node.js hot modules (technical write up)

created: May 31, 2025, 12:13 p.m. | updated: June 4, 2025, 1:34 p.m.

# HMR natively in Node.js (technical write up)One of the key factors in rapid development is discarding as little state as possible. By adding module hooks using Node's built-in node:module module, it's now possible to implement "hot module" functionality natively. import { FileTree } from "immaculata" import { useTree } from "immaculata/hooks.js" import { registerHooks } from 'node:module' const tree = new FileTree ( 'src' , import . dirname ) registerHooks ( useTree ( tree )) const myModule = await import ( 'src/myModule.js' ) // src/myModule.js is executed const myModule2 = await import ( 'src/myModule.js' ) // src/myModule.js is NOT executed a second time tree . import * as ShikiMd from '@shikijs/markdown-it' import type MarkdownIt from 'markdown-it' import * as Shiki from 'shiki' import { tree } from '../../static.ts' const highlighter = await Shiki .

1 week, 1 day ago: Hacker News