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