Boardgame.io: error loading react client

Created on 20 Jul 2020  路  7Comments  路  Source: boardgameio/boardgame.io

after 72ed5913 i cant load the react client:

Error: Function called outside component initialization

which traces back to svelte calling get_current_component after importing svelte in src/client.js

bug

Most helpful comment

767 is available in 0.39.16, so you can try that.

All 7 comments

Thanks for the report! 72ed591 isn鈥檛 included in the latest release; are you installing from GitHub directly?

OK, I can reproduce this using 0.39.15, so I suspect this was actually introduced in 271aecd18bd14aa5a331d615a844762c22b94536, and likely not fixed by 72ed591.

Reproduction: https://codesandbox.io/s/test-bgio-latest-l8obj

OK, I think the bug was caused when we moved svelte from devDependencies to dependencies (to make svelte鈥檚 type declarations available to boardgame.io users). Our Rollup config marks any direct dependency in package.json as external:

https://github.com/boardgameio/boardgame.io/blob/72ed591310bec944cbb3b7eba458726b810b3a1d/rollup.config.js#L20-L21

That led to the bundle including import 'svelte' or require('svelte') statements, which it shouldn鈥檛 (see unpkg for an example). In short import 'svelte' is there for Typescript, not for JS functionality, so shouldn鈥檛 be included in the bundle output. Running a few more local tests, and then I鈥檒l open a PR to fix this.

Oh I got this bug too.

@jakehsiao I鈥檇 recommend downgrading to [email protected] for now. If you鈥檙e using Typescript, you may need to downgrade to 0.39.13 as there were some issues with the types in 0.39.14.

767 is available in 0.39.16, so you can try that.

Thanks @nicolodavis!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amerine picture amerine  路  5Comments

nicolodavis picture nicolodavis  路  4Comments

br0p0p picture br0p0p  路  4Comments

nicolodavis picture nicolodavis  路  7Comments

nicolodavis picture nicolodavis  路  10Comments