mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:40:44 +00:00
build: fix bundled plugin runtime mirror guard
This commit is contained in:
@@ -2,11 +2,6 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const JS_EXTENSIONS = new Set([".cjs", ".js", ".mjs"]);
|
||||
const CURATED_ROOT_RUNTIME_MIRRORS = new Set([
|
||||
"@matrix-org/matrix-sdk-crypto-nodejs",
|
||||
"@matrix-org/matrix-sdk-crypto-wasm",
|
||||
]);
|
||||
|
||||
export function collectRuntimeDependencySpecs(packageJson = {}) {
|
||||
return new Map(
|
||||
[
|
||||
@@ -151,8 +146,12 @@ function extractModuleSpecifiers(source) {
|
||||
return specifiers;
|
||||
}
|
||||
|
||||
function isPluginOwnedDistImporter(relativePath, pluginIds) {
|
||||
return pluginIds.some((pluginId) => relativePath.startsWith(`extensions/${pluginId}/`));
|
||||
function isPluginOwnedDistImporter(relativePath, source, pluginIds) {
|
||||
return pluginIds.some(
|
||||
(pluginId) =>
|
||||
relativePath.startsWith(`extensions/${pluginId}/`) ||
|
||||
source.includes(`//#region extensions/${pluginId}/`),
|
||||
);
|
||||
}
|
||||
|
||||
export function collectRootDistBundledRuntimeMirrors(params) {
|
||||
@@ -160,18 +159,6 @@ export function collectRootDistBundledRuntimeMirrors(params) {
|
||||
const bundledSpecs = params.bundledRuntimeDependencySpecs;
|
||||
const mirrors = new Map();
|
||||
|
||||
for (const dependencyName of CURATED_ROOT_RUNTIME_MIRRORS) {
|
||||
const bundledSpec = bundledSpecs.get(dependencyName);
|
||||
if (!bundledSpec) {
|
||||
continue;
|
||||
}
|
||||
mirrors.set(dependencyName, {
|
||||
importers: new Set(["<curated root runtime surface>"]),
|
||||
pluginIds: bundledSpec.pluginIds,
|
||||
spec: bundledSpec.spec,
|
||||
});
|
||||
}
|
||||
|
||||
for (const filePath of walkJavaScriptFiles(distDir)) {
|
||||
const source = fs.readFileSync(filePath, "utf8");
|
||||
const relativePath = path.relative(distDir, filePath).replaceAll(path.sep, "/");
|
||||
@@ -181,7 +168,7 @@ export function collectRootDistBundledRuntimeMirrors(params) {
|
||||
continue;
|
||||
}
|
||||
const bundledSpec = bundledSpecs.get(dependencyName);
|
||||
if (isPluginOwnedDistImporter(relativePath, bundledSpec.pluginIds)) {
|
||||
if (isPluginOwnedDistImporter(relativePath, source, bundledSpec.pluginIds)) {
|
||||
continue;
|
||||
}
|
||||
const existing = mirrors.get(dependencyName);
|
||||
|
||||
Reference in New Issue
Block a user