mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:00:42 +00:00
docs: clarify alias map memoization rationale
This commit is contained in:
@@ -1058,7 +1058,7 @@ export const syntheticRuntimeMarker = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("buildPluginLoaderAliasMap memoization", () => {
|
describe("buildPluginLoaderAliasMap memoization", () => {
|
||||||
it("returns the same object reference for identical inputs (jiti sentinel safety)", () => {
|
it("returns the same object reference for identical effective context", () => {
|
||||||
const fixture = createPluginSdkAliasFixture();
|
const fixture = createPluginSdkAliasFixture();
|
||||||
const sourceRootAlias = path.join(fixture.root, "src", "plugin-sdk", "root-alias.cjs");
|
const sourceRootAlias = path.join(fixture.root, "src", "plugin-sdk", "root-alias.cjs");
|
||||||
fs.writeFileSync(sourceRootAlias, "module.exports = {};\n", "utf-8");
|
fs.writeFileSync(sourceRootAlias, "module.exports = {};\n", "utf-8");
|
||||||
@@ -1070,8 +1070,6 @@ describe("buildPluginLoaderAliasMap memoization", () => {
|
|||||||
const first = buildPluginLoaderAliasMap(sourcePluginEntry);
|
const first = buildPluginLoaderAliasMap(sourcePluginEntry);
|
||||||
const second = buildPluginLoaderAliasMap(sourcePluginEntry);
|
const second = buildPluginLoaderAliasMap(sourcePluginEntry);
|
||||||
|
|
||||||
// Reference identity is critical: jiti's normalizeAliases uses a
|
|
||||||
// reference-identity sentinel to skip O(N²) re-processing.
|
|
||||||
expect(second).toBe(first);
|
expect(second).toBe(first);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -430,11 +430,9 @@ export function resolveExtensionApiAlias(params: LoaderModuleResolveParams = {})
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memoize alias maps by inputs so the same object reference is returned for
|
// Memoize alias maps by effective resolution context so repeated loader setup
|
||||||
// identical parameters. jiti's `normalizeAliases` uses a reference-identity
|
// avoids rebuilding the same filesystem-derived map. Include cwd/env inputs
|
||||||
// sentinel (`if (e[pt]) return e`) to skip its O(N²) normalization — returning
|
// because the fallback root and private QA alias surfaces depend on them.
|
||||||
// the same object lets the sentinel fire on the 2nd+ call instead of repeating
|
|
||||||
// the full cycle every time. See #68983.
|
|
||||||
const aliasMapCache = new Map<string, Record<string, string>>();
|
const aliasMapCache = new Map<string, Record<string, string>>();
|
||||||
|
|
||||||
function buildPluginLoaderAliasMapCacheKey(params: {
|
function buildPluginLoaderAliasMapCacheKey(params: {
|
||||||
|
|||||||
Reference in New Issue
Block a user