Turn on a feature
Goal
Your game declares the characters feature, and the page loads the character bridge (the rig stack behind spawn-character) only because it did.
Files you will edit
src/game.ts
Steps
Declare the feature in the game definition. A feature set to
trueloads with its default options; a feature that is absent orfalseis never loaded and never downloaded.tsimport { defineGame } from 'gameable'; export default defineGame({ // Optional engine features this game opts into; the page resolves each by name. features: { characters: true }, assets: ['char.enemy'], });Run the game. The page reads
featuresfrom your definition, looks each name up in its table (clientFeatures()fromgameable/host/features) and imports only those.shnpm run devTake the line out again, reload, and watch the network tab. With
features: { characters: true }removed the page makes no request for thecharactersmodule, because its loader, a dynamicimport()inside the table, is never called.tsimport { defineGame } from 'gameable'; export default defineGame({ assets: ['char.enemy'], });
Verify
The templates assert their declaration in tests/game.test.ts:
sh
npx vitest run tests/game.test.tsThe declares the characters feature test passes when featuresOf(game) equals { characters: {} }. If you removed the line in step 3, put it back first, or that test fails.
See also
- Features: what a game declares
packages/sdk/README.md—featuresOf- Use the sample character