boardzilla / boardzilla-core

Boardzilla core library
GNU Affero General Public License v3.0
179 stars 3 forks source link

BZ 0.2 broke JS compatibility #45

Open rizen opened 5 months ago

rizen commented 5 months ago

in 0.1 you could just rename all the .ts files in src/game to .js and all the .tsx files in src/ui to .jsx and everything worked. However, now in 0.2 it no longer works because it can't find game-interface.ts

err: ✘ [ERROR] Could not resolve "src/game/game-interface.ts"

/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:1651
  let error = new Error(text);
              ^

Error: Build failed with 1 error:
error: Could not resolve "src/game/game-interface.ts"
    at failureErrorWithLog (/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:1059:25
    at runOnEndCallbacks (/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:1486:45)
    at buildResponseToResult (/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:1057:7)
    at /Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:1086:16
    at responseCallbacks.<computed> (/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/Users/jtsmith/boardzilla/sevenjs/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:559:12) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v20.11.0
rizen commented 5 months ago

Looks like this is due to an entryPoint in esbuild.game.mjs

rizen commented 5 months ago

Yup, changing that fixed it. So now I'm on to seeing if there is a different default the entry point could have, or if that just needs to be added to the cookbook.

rizen commented 5 months ago

Ok, spoke with Moxy about this and removing entryPoints worked for me as well as changing entryPoints to:

entryPoints: ['src/game/game-interface.js'],

Also worked for me.

But rather than documenting that, he would like to investigate something called allowJS which supposedly keeps the guardrails of Typescript working inside of JS.

Here's the start of that conversation in discord: https://discord.com/channels/@me/1186428321471402085/1222248673380012154