diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-25 20:03:05 +0000 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-25 20:03:05 +0000 |
| commit | 1062478e81a49f19537c2610d8f1b25e2054d6fa (patch) | |
| tree | d093b3092b1a453913cada45ae2a93f56851ff5d /loader.js | |
| parent | 7a9ef1f9704fe724409f4d9002474049ca0776d0 (diff) | |
pirc-extension 0.1.9-dev+69800ee67711
Diffstat (limited to 'loader.js')
| -rw-r--r-- | loader.js | 15 |
1 files changed, 15 insertions, 0 deletions
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); +} |
