Have orderkit require its part when it loads

Main resolves computed createRequire specifiers at run time, so a computed
require inside a function no longer makes an island; one in module code
still does.
This commit is contained in:
Malte Ubl
2026-10-26 16:35:52 -07:00
parent b29475cec4
commit 55e7cc20db
+3 -2
View File
@@ -1,5 +1,6 @@
"use strict";
// Loads its part through a computed specifier, so it runs in a Node island.
// Loads its part through a computed specifier when it loads, so it runs in
// a Node island.
const { createRequire } = require("node:module");
const parts = ["./thing"].map((p) => createRequire(__filename)(p));
const parts = [createRequire(__filename)(["./thing"][0])];
exports.make = () => new parts[0].Thing();