mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 11:37:49 +00:00
Some checks are pending
CI / preflight (push) Waiting to run
CI / security-fast (push) Waiting to run
CI / build-artifacts (push) Blocked by required conditions
CI / (push) Blocked by required conditions
CI / -1 (push) Blocked by required conditions
CI / checks-node-extensions (push) Blocked by required conditions
CI / -2 (push) Blocked by required conditions
CI / -3 (push) Blocked by required conditions
CI / checks-node-core (push) Blocked by required conditions
CI / extension-fast (push) Blocked by required conditions
CI / check (push) Blocked by required conditions
CI / check-additional (push) Blocked by required conditions
CI / build-smoke (push) Blocked by required conditions
CI / check-docs (push) Blocked by required conditions
CI / skills-python (push) Blocked by required conditions
CI / -4 (push) Blocked by required conditions
CI / -5 (push) Blocked by required conditions
CI / macos-swift (push) Blocked by required conditions
CI / -6 (push) Blocked by required conditions
Docs Sync Publish Repo / sync-publish-repo (push) Waiting to run
Install Smoke / preflight (push) Waiting to run
Install Smoke / install-smoke (push) Blocked by required conditions
Plugin NPM Release / preview_plugins_npm (push) Waiting to run
Plugin NPM Release / preview_plugin_pack (push) Blocked by required conditions
Plugin NPM Release / publish_plugins_npm (push) Blocked by required conditions
Workflow Sanity / no-tabs (push) Waiting to run
Workflow Sanity / actionlint (push) Waiting to run
Workflow Sanity / generated-doc-baselines (push) Waiting to run
31 lines
997 B
TypeScript
31 lines
997 B
TypeScript
import type { PluginJitiLoaderCache } from "./jiti-loader-cache.js";
|
|
import { getCachedPluginJitiLoader } from "./jiti-loader-cache.js";
|
|
|
|
export type PluginSourceLoader = (modulePath: string) => unknown;
|
|
|
|
function shouldProfilePluginSourceLoader(): boolean {
|
|
return process.env.OPENCLAW_PLUGIN_LOAD_PROFILE === "1";
|
|
}
|
|
|
|
export function createPluginSourceLoader(): PluginSourceLoader {
|
|
const loaders: PluginJitiLoaderCache = new Map();
|
|
return (modulePath) => {
|
|
const jiti = getCachedPluginJitiLoader({
|
|
cache: loaders,
|
|
modulePath,
|
|
importerUrl: import.meta.url,
|
|
jitiFilename: import.meta.url,
|
|
});
|
|
if (!shouldProfilePluginSourceLoader()) {
|
|
return jiti(modulePath);
|
|
}
|
|
const startMs = performance.now();
|
|
try {
|
|
return jiti(modulePath);
|
|
} finally {
|
|
console.error(
|
|
`[plugin-load-profile] phase=source-loader plugin=(direct) elapsedMs=${(performance.now() - startMs).toFixed(1)} source=${modulePath}`,
|
|
);
|
|
}
|
|
};
|
|
}
|