mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:10:43 +00:00
fix(plugin-sdk): sort hashed root alias dist chunks
This commit is contained in:
@@ -90,7 +90,9 @@ function getPackageRoot() {
|
||||
function findDistChunkByPrefix(prefix) {
|
||||
const distRoot = path.join(getPackageRoot(), "dist");
|
||||
try {
|
||||
const entries = fs.readdirSync(distRoot, { withFileTypes: true });
|
||||
const entries = fs
|
||||
.readdirSync(distRoot, { withFileTypes: true })
|
||||
.toSorted((left, right) => left.name.localeCompare(right.name));
|
||||
const match = entries.find(
|
||||
(entry) =>
|
||||
entry.isFile() && entry.name.startsWith(`${prefix}-`) && entry.name.endsWith(".js"),
|
||||
|
||||
@@ -331,6 +331,32 @@ describe("plugin-sdk root alias", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("chooses hashed dist diagnostic events chunks deterministically", () => {
|
||||
const packageRoot = createPackageRoot();
|
||||
const distAliasPath = createDistAliasPath();
|
||||
const lazyModule = loadRootAliasWithStubs({
|
||||
aliasPath: distAliasPath,
|
||||
distExists: false,
|
||||
distEntries: ["diagnostic-events-zeta.js", "diagnostic-events-alpha.js"],
|
||||
monolithicExports: {
|
||||
r: (): (() => void) => () => undefined,
|
||||
slowHelper: (): string => "loaded",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
typeof (lazyModule.moduleExports.onDiagnosticEvent as (listener: () => void) => () => void)(
|
||||
() => undefined,
|
||||
),
|
||||
).toBe("function");
|
||||
expect(lazyModule.loadedSpecifiers).toContain(
|
||||
path.join(packageRoot, "dist", "diagnostic-events-alpha.js"),
|
||||
);
|
||||
expect(lazyModule.loadedSpecifiers).not.toContain(
|
||||
path.join(packageRoot, "dist", "diagnostic-events-zeta.js"),
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "forwards delegateCompactionToRuntime through the compat-backed root alias",
|
||||
|
||||
Reference in New Issue
Block a user