From 1062478e81a49f19537c2610d8f1b25e2054d6fa Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Sun, 25 Oct 2026 20:03:05 +0000 Subject: pirc-extension 0.1.9-dev+69800ee67711 --- loader.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 loader.js (limited to 'loader.js') diff --git a/loader.js b/loader.js new file mode 100644 index 0000000..247724f --- /dev/null +++ b/loader.js @@ -0,0 +1,15 @@ +// The published extension's entry point. pi's /reload imports the +// extension again, but Node keeps every JavaScript module it has imported, +// so a bundle updated in place would not run until pi restarted. This file +// imports the bundle beside it by a URL that changes when the file does, +// so a reload after an update runs the new code, and is the same in every +// version, so that its own copy, which Node keeps, is never stale. Not +// index.js: versions before it had their bundle there, which Node would +// still hold after updating from one of them. +import { statSync } from "node:fs"; + +export default async function (pi) { + const bundle = new URL("./pirc.js", import.meta.url); + const { default: factory } = await import(`${bundle.href}?t=${statSync(bundle).mtimeMs}`); + return factory(pi); +} -- cgit v1.2.3