Build: ship Matrix crypto WASM pkg

This commit is contained in:
Gustavo Madeira Santana
2026-03-29 12:38:49 -04:00
parent 82f04ced27
commit 1769d76e81
5 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { removePathIfExists } from "./runtime-postbuild-shared.mjs";
/**
* @param {{
* cwd?: string;
* repoRoot?: string;
* }} [params]
*/
export function copyMatrixCryptoWasmPkg(params = {}) {
const repoRoot = params.cwd ?? params.repoRoot ?? process.cwd();
const sourcePkgDir = path.join(
repoRoot,
"node_modules",
"@matrix-org",
"matrix-sdk-crypto-wasm",
"pkg",
);
const targetPkgDir = path.join(repoRoot, "dist", "pkg");
removePathIfExists(targetPkgDir);
if (!fs.existsSync(sourcePkgDir)) {
return;
}
fs.mkdirSync(path.dirname(targetPkgDir), { recursive: true });
fs.cpSync(sourcePkgDir, targetPkgDir, { force: true, recursive: true });
}
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
copyMatrixCryptoWasmPkg();
}

View File

@@ -28,6 +28,7 @@ const requiredPathGroups = [
"dist/build-info.json",
"dist/channel-catalog.json",
"dist/control-ui/index.html",
"dist/pkg/matrix_sdk_crypto_wasm_bg.wasm",
];
const forbiddenPrefixes = ["dist-runtime/", "dist/OpenClaw.app/"];
// 2026.3.12 ballooned to ~213.6 MiB unpacked and correlated with low-memory

View File

@@ -1,5 +1,6 @@
import { pathToFileURL } from "node:url";
import { copyBundledPluginMetadata } from "./copy-bundled-plugin-metadata.mjs";
import { copyMatrixCryptoWasmPkg } from "./copy-matrix-crypto-wasm-pkg.mjs";
import { copyPluginSdkRootAlias } from "./copy-plugin-sdk-root-alias.mjs";
import { stageBundledPluginRuntimeDeps } from "./stage-bundled-plugin-runtime-deps.mjs";
import { stageBundledPluginRuntime } from "./stage-bundled-plugin-runtime.mjs";
@@ -8,6 +9,7 @@ import { writeOfficialChannelCatalog } from "./write-official-channel-catalog.mj
export function runRuntimePostBuild(params = {}) {
copyPluginSdkRootAlias(params);
copyBundledPluginMetadata(params);
copyMatrixCryptoWasmPkg(params);
writeOfficialChannelCatalog(params);
stageBundledPluginRuntimeDeps(params);
stageBundledPluginRuntime(params);