From 94a1876f619ef8a1a539b985d2e6aebbbf22712a Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 22 Apr 2025 09:27:22 -0700 Subject: [PATCH] Support non-full builds in testclient Non-Preact testclients don't deal well with non-full builds anymore, now that battledata includes data/text.js. This fixes it so that they're usable (although no longer being able to edit battle-dex etc without an initial full build still sucks, it's unavoidable). --- build-tools/update | 32 ++++++++++++---------- play.pokemonshowdown.com/testclient.html | 6 ++-- replay.pokemonshowdown.com/testclient.html | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/build-tools/update b/build-tools/update index f0fa607c4..d76721b33 100755 --- a/build-tools/update +++ b/build-tools/update @@ -107,20 +107,24 @@ compiledFiles += compiler.compileToDir(`replay.pokemonshowdown.com/src`, `replay compiledFiles += compiler.compileToDir(`teams.pokemonshowdown.com/src`, `teams.pokemonshowdown.com/js`, compileOpts); -compiledFiles += compiler.compileToFile( - [ - 'play.pokemonshowdown.com/src/battle-dex.ts', - 'play.pokemonshowdown.com/src/battle-dex-data.ts', - 'play.pokemonshowdown.com/src/battle-log.ts', - 'play.pokemonshowdown.com/src/battle-log-misc.js', - 'caches/pokemon-showdown/server/chat-formatter.ts', - 'play.pokemonshowdown.com/data/text.js', - 'play.pokemonshowdown.com/data/text-afd.js', - 'play.pokemonshowdown.com/src/battle-text-parser.ts', - ], - 'play.pokemonshowdown.com/js/battledata.js', - compileOpts -); +try { + fs.statSync('play.pokemonshowdown.com/data/text.js'); + // text.js exists, we can compile battledata + compiledFiles += compiler.compileToFile( + [ + 'play.pokemonshowdown.com/src/battle-dex.ts', + 'play.pokemonshowdown.com/src/battle-dex-data.ts', + 'play.pokemonshowdown.com/src/battle-log.ts', + 'play.pokemonshowdown.com/src/battle-log-misc.js', + 'caches/pokemon-showdown/server/chat-formatter.ts', + 'play.pokemonshowdown.com/data/text.js', + 'play.pokemonshowdown.com/data/text-afd.js', + 'play.pokemonshowdown.com/src/battle-text-parser.ts', + ], + 'play.pokemonshowdown.com/js/battledata.js', + compileOpts + ); +} catch {} if (!compileOpts.ignore) { compiledFiles += compiler.compileToFile( diff --git a/play.pokemonshowdown.com/testclient.html b/play.pokemonshowdown.com/testclient.html index 2e128b7b5..17f1e02f6 100644 --- a/play.pokemonshowdown.com/testclient.html +++ b/play.pokemonshowdown.com/testclient.html @@ -16,7 +16,7 @@ - + - + diff --git a/replay.pokemonshowdown.com/testclient.html b/replay.pokemonshowdown.com/testclient.html index af510bff6..ddb9f3282 100644 --- a/replay.pokemonshowdown.com/testclient.html +++ b/replay.pokemonshowdown.com/testclient.html @@ -143,7 +143,7 @@ - +