Skip to content

Commit 4a31cdc

Browse files
agviegasclaude
andcommitted
fix(cli/run): make engine globals optional in the local runner
The 'thatopen run' execution wrapper hard-required @thatopen/components, so a cloud component that doesn't touch the 3D engine (e.g. the scaffold, which only uses thatOpenServices) crashed at module load before main() ran. Under --beta the package is installed as @thatopen-platform/components-beta, so the literal require could never resolve. Each engine global (OBC/THREE/web-ifc) is now best-effort via tryRequire, and @thatopen/components also resolves the beta package name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e9db447 commit 4a31cdc

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/cli/lib/engine-script.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ export function buildEngineScript(
1616
return `/* eslint-disable */
1717
const { EngineServicesClient } = require('@thatopen/services');
1818
19-
const OBC = require('@thatopen/components');
20-
const THREE = require('three');
21-
let WEBIFC; try { WEBIFC = require('web-ifc'); } catch {}
19+
// Engine globals are BEST-EFFORT: a cloud component that doesn't touch the 3D
20+
// engine (e.g. one that only uses thatOpenServices) must still run. Each is
21+
// optional, and @thatopen/components also resolves the beta package — under
22+
// --beta the dep is installed as @thatopen-platform/components-beta, so a hard
23+
// require('@thatopen/components') would throw before main() runs.
24+
const tryRequire = (...names) => { for (const n of names) { try { return require(n); } catch {} } return undefined; };
25+
const OBC = tryRequire('@thatopen/components', '@thatopen-platform/components-beta');
26+
const THREE = tryRequire('three');
27+
const WEBIFC = tryRequire('web-ifc');
2228
const fs = require('fs');
2329
2430
const executionReporter = {

0 commit comments

Comments
 (0)