hathora / builder

Multiplayer game framework
https://docs.hathora.dev/#/builder/
MIT License
553 stars 35 forks source link

Dependencies within monorepo are not loaded #453

Open philihp opened 1 year ago

philihp commented 1 year ago

Hathora is not loading installing dependencies from packages within the monorepo

Demo repo: https://github.com/philihp/hathora-et-labora/tree/69b1a8dfe3828544a1580d35ff0eef46c679057f

The package has a dependency declared at https://github.com/philihp/hathora-et-labora/blob/69b1a8dfe3828544a1580d35ff0eef46c679057f/game/package.json and loaded at https://github.com/philihp/hathora-et-labora/blob/69b1a8dfe3828544a1580d35ff0eef46c679057f/game/src/commands/start.ts

file:///Users/philihp/work/hathora-et-labora/game/src/commands/start.ts:34
  const shuffledColors = fastShuffle(playerOrderSeed, colors)
                         ^
TypeError: fastShuffle is not a function
    at start (file:///Users/philihp/work/hathora-et-labora/game/src/commands/start.ts:34:26)
    at handler (file:///Users/philihp/work/hathora-et-labora/game/src/reducer.ts:101:7)
    at n.run (file:///Users/philihp/work/hathora-et-labora/game/node_modules/ts-pattern/src/match.ts:162:12)
    at n.e.otherwise (file:///Users/philihp/work/hathora-et-labora/game/node_modules/ts-pattern/src/match.ts:131:7)
    at reducer (file:///Users/philihp/work/hathora-et-labora/game/src/reducer.ts:106:6)
    at Impl.start (file:///Users/philihp/work/hathora-et-labora/server/impl.ts:88:22)
    at ImplWrapper._getResult (file:///Users/philihp/work/hathora-et-labora/server/.hathora/wrapper.ts:50:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async ImplWrapper.getResult (file:///Users/philihp/work/hathora-et-labora/server/.hathora/wrapper.ts:29:17)
    at async Store.onMessage (file:///Users/philihp/work/hathora-et-labora/server/.hathora/store.ts:106:22)

Specifically for this case, I could dependency-inject a chance.js from impl, but the problem will still exist for other dependencies.

Could you advise what the correct way to include dependencies in a game is? Should game logic be kept as external dependencies?