mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:10:45 +00:00
fix: load staged dist-runtime plugins in docker
This commit is contained in:
@@ -636,7 +636,8 @@ function applyBundledPluginRuntimeHotfixes(params = {}) {
|
||||
export function isSourceCheckoutRoot(params) {
|
||||
const pathExists = params.existsSync ?? existsSync;
|
||||
return (
|
||||
pathExists(join(params.packageRoot, ".git")) &&
|
||||
(pathExists(join(params.packageRoot, ".git")) ||
|
||||
pathExists(join(params.packageRoot, "pnpm-workspace.yaml"))) &&
|
||||
pathExists(join(params.packageRoot, "src")) &&
|
||||
pathExists(join(params.packageRoot, "extensions"))
|
||||
);
|
||||
|
||||
@@ -140,15 +140,35 @@ function shouldCopyRuntimeFile(sourcePath) {
|
||||
);
|
||||
}
|
||||
|
||||
function hasDefaultExport(sourcePath) {
|
||||
const text = fs.readFileSync(sourcePath, "utf8");
|
||||
return /\bexport\s+default\b/u.test(text) || /\bas\s+default\b/u.test(text);
|
||||
}
|
||||
|
||||
function writeRuntimeModuleWrapper(sourcePath, targetPath) {
|
||||
const specifier = relativeSymlinkTarget(sourcePath, targetPath).replace(/\\/g, "/");
|
||||
const normalizedSpecifier = specifier.startsWith(".") ? specifier : `./${specifier}`;
|
||||
const defaultForwarder = hasDefaultExport(sourcePath)
|
||||
? [
|
||||
`import defaultModule from ${JSON.stringify(normalizedSpecifier)};`,
|
||||
`let defaultExport = defaultModule;`,
|
||||
`for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {`,
|
||||
` defaultExport = defaultExport.default;`,
|
||||
`}`,
|
||||
]
|
||||
: [
|
||||
`import * as module from ${JSON.stringify(normalizedSpecifier)};`,
|
||||
`let defaultExport = "default" in module ? module.default : module;`,
|
||||
`for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {`,
|
||||
` defaultExport = defaultExport.default;`,
|
||||
`}`,
|
||||
];
|
||||
fs.writeFileSync(
|
||||
targetPath,
|
||||
[
|
||||
`export * from ${JSON.stringify(normalizedSpecifier)};`,
|
||||
`import * as module from ${JSON.stringify(normalizedSpecifier)};`,
|
||||
"export default module.default;",
|
||||
...defaultForwarder,
|
||||
"export { defaultExport as default };",
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
|
||||
Reference in New Issue
Block a user