Node.js Loader Hooks for Fun and Profit
summary
Shows the experimental Node.js loader hook API (Node 12, ES modules only, run with --experimental-modules and --experimental-loader) and three concrete builds that actually run: on-the-fly TypeScript transpile via typescript.transpileModule (reads .ts, writes .mjs, returns the JS URL), remote HTTP module fetch to /tmp then load (downloads a URL synchronously and resolves it), and proxy-based dependency injection exposing handlers (wraps exports with proxies and dynamicInstantiate to modify behavior); demos work but note experimental, synchronous, and not production-ready.
AI-written summary · about
chapters (9)
- 0:00Start
- 0:54Detecting loaded modules
- 1:15Check require.cache
- 2:27Monkeypatch Module._load
- 3:47Loader hooks
- 4:44loader.mjs
- 7:18TypeScript loader
- 11:29Remote loader
- 12:01index.mjs
related talks
30mESM Loaders: Enhancing Module Loading in Node.js
45mLoading Modules Everywhere!
32mPlease Wait... Loading: A Talk of Two Loaders
22mESM Loaders: Enhancing Module Loading in Node.js
47mNative JavaScript Modules: import {Browsers, Node.js}; export {production};
22mPlease wait... loading: a tale of two loaders
19mModule Frontiers
40mNode.js: Where are we now, where are we going?
