mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-09 05:19:32 +08:00
fix(docker): support .mjs entrypoints in images and e2e
This commit is contained in:
21
openclaw.mjs
21
openclaw.mjs
@@ -11,4 +11,23 @@ if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
|
||||
}
|
||||
}
|
||||
|
||||
await import("./dist/entry.js");
|
||||
const tryImport = async (specifier) => {
|
||||
try {
|
||||
await import(specifier);
|
||||
return true;
|
||||
} catch (err) {
|
||||
// Only swallow missing-module errors; rethrow real runtime errors.
|
||||
if (err && typeof err === "object" && "code" in err && err.code === "ERR_MODULE_NOT_FOUND") {
|
||||
return false;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
if (await tryImport("./dist/entry.js")) {
|
||||
// OK
|
||||
} else if (await tryImport("./dist/entry.mjs")) {
|
||||
// OK
|
||||
} else {
|
||||
throw new Error("openclaw: missing dist/entry.(m)js (build output).");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user