boardzilla / boardzilla-core

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

0.2.9 and 0.2.10 throwing errors on npm #54

Open cvxluo opened 3 months ago

cvxluo commented 3 months ago

Default projects created with 0.2.9 and 0.2.10 throw errors relating to index.css when run.

Replication

Creating a new game with bz new

$ bz new
What is the name of your game? bz-test-game
What would you like the short name to be? btg
What would you like the name of the directory to be? bz-test-game
What would you like the class name to be? BzTestGame
Which template would you like to use? Simple Token game
Which template would you like to use? npm
Getting latest release for boardzilla-starter-game from https://github.com/boardzilla/boardzilla-starter-game/releases/latest/ ✅
Downloading template from https://github.com/boardzilla/boardzilla-starter-game/archive/refs/tags/v0.2.0.zip ✅
...
🎉 Success!

Now you can go to bz-test-game and run npm run dev to start developing

Running the game, however, throws errors relating to @boardzilla/core/index.css:

$ cd bz-test-game
$ npm run dev
...
> btg@1.0.0 typecheck
> tsc --noEmit

✘ [ERROR] Could not resolve "@boardzilla/core/index.css"

    src/ui/index.tsx:6:7:
      6 │ import '@boardzilla/core/index.css';
        ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The path "./index.css" is not exported by package "@boardzilla/core:

    node_modules/@boardzilla/core/package.json:22:13:
      22 │   "exports": {
         ╵              ^

  You can mark the path "@boardzilla/core/index.css" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

[...]/bz-test-game/node_modules/esbuild/lib/main.js:1651
  let error = new Error(text);
              ^

Error: Build failed with 1 error:
src/ui/index.tsx:6:7: ERROR: Could not resolve "@boardzilla/core/index.css"
    at failureErrorWithLog ([...]bz-test-game/node_modules/esbuild/lib/main.js:1651:15)
    at [...]/bz-test-game/node_modules/esbuild/lib/main.js:1059:25
    at runOnEndCallbacks ([...]/bz-test-game/node_modules/esbuild/lib/main.js:1486:45)
    at buildResponseToResult ([...]/bz-test-game/node_modules/esbuild/lib/main.js:1057:7)
    at [...]/bz-test-game/node_modules/esbuild/lib/main.js:1086:16
    at responseCallbacks.<computed> ([...]/bz-test-game/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket ([...]/bz-test-game/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout [...]/bz-test-game/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:545:12) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}

Node.js v20.10.0

...

sending build error!2024/05/23 01:35:49 "GET http://localhost:8080/game.html HTTP/1.1" from [::1]:57864 - 200 1932B in 15.917µs
2024/05/23 01:35:49 "GET http://localhost:8080/ui.html?bootstrap=%7B%22host%22%3Atrue%2C%22userID%22%3A%220%22%2C%22minPlayers%22%3A1%2C%22maxPlayers%22%3A4%2C%22defaultPlayers%22%3A1%2C%22dev%22%3Atrue%7D HTTP/1.1" from [::1]:57863 - 200 1004B in 991.084µs
npm run typecheck encountered an error: signal: killed
Running cmd npm run typecheck finished in 1.021977417s
2024/05/23 01:35:49 "GET http://localhost:8080/game.js HTTP/1.1" from [::1]:57863 - 200 323069B in 282.083µs

Package Versions

$ brew info boardzilla-devtools
==> boardzilla/tap/boardzilla-devtools: stable 0.2.6
...

$ node --version
v20.10.0

Fix

Adding the index.css export that was removed in baab90e7ce85f15ea8ecc22eefee47c49a73d3d2 back to the package.json fixed the issue:

  "exports": {
    ".": "./entry/index.js",
    "./index.css": "./entry/ui/assets/index.css",  <-- added here
    "./components": "./entry/components/index.js"
  },

Things still run, but downgrading to 0.2.8 got rid of the errors, so I'm using 0.2.8 for now.