Files
openclaw/scripts/lib/dist-runtime-artifact-resolver-hook.mjs
2026-08-01 17:27:01 +00:00

29 lines
916 B
JavaScript

import { registerHooks } from "node:module";
import { resolveDistRuntimeArtifactWorkspaceImport } from "./workspace-bootstrap-smoke.mjs";
const artifactRoot = process.env.OPENCLAW_ARTIFACT_ROOT;
if (!artifactRoot) {
throw new Error("OPENCLAW_ARTIFACT_ROOT is required for the runtime artifact smoke");
}
const workspacePackagesJson = process.env.OPENCLAW_ARTIFACT_WORKSPACE_PACKAGES;
if (!workspacePackagesJson) {
throw new Error(
"OPENCLAW_ARTIFACT_WORKSPACE_PACKAGES is required for the runtime artifact smoke",
);
}
const workspacePackageNames = new Set(JSON.parse(workspacePackagesJson));
registerHooks({
resolve(specifier, context, nextResolve) {
const url = resolveDistRuntimeArtifactWorkspaceImport({
artifactRoot,
specifier,
workspacePackageNames,
});
if (url) {
return { shortCircuit: true, url };
}
return nextResolve(specifier, context);
},
});