Building from a fresh install currently fails since #7797
The problem is that `require('sucrase')` needs to be done _after_
sucrase is installed, which is a lot harder than it sounds.
simulate-battle now has a new option: --spectate.
As a recap:
-D --debug: simulate in debug mode
-R --replay: output only the omniscient (debug) replay, rather than the
full stream
-S --spectate: output only the spectator replay, rather than the full
stream
We were previously using `type Foo = import('bar').Foo` which works
actually equally well, because sucrase didn't support `import type`,
but now it does!
We try to feature-detect for dependencies, but this one is hard and
I don't want to actually do an actual sucrase compile to check if it's
up to date, hence digging through its version number. Too bad they
added a major feature in a minor version, complicating the check. :/
`node tools/set-import [version]` can be run to create a
`@pokemon-showdown/sets` package containing sets from Smogon, usage
stats and third party sources. Some notes:
- The build is set up so that `tools/set-import/importer.ts` is
compiled to `tools/set-import/importer.js` - creating a
`.tools-dist/set-import` directory for the sole artifact was
deemed to be overkill
- The sets package is generated such that it can be used easily on
Node or in a browser (where the large set JSON can be loaded
asynchronously)
- Supported tiers/formats are mostly arbitrary - those popular
enough to have a signficant playerbase or analyses on Smogon have
been included, but additional formats can be added based on demand
- Some set information is redundant for ease of use by downstream
users: certain formes are split out and information that could
theoretically be inferred like level/ability/HP IVs are included
to simplify parsing logic and make the sets more immediately
available. This results in what should mostly be negligible
size overhead.
- In a similar vein, display versions of effect names instead of IDs
are used (name -> ID is trivial, ID -> name requires data lookup)
- All sets pass validation, provided certain simple transformations
are applied (eg. reverting `battleOnly` formes like Megas)
This tool has primarily been tested to run on Linux - running on
other platforms is not guaranteed to result in error-free output.
- Refactor dev-tools/harness.js and dev-tools/smokes.js to separate
out the script/CLI code and implementation code into separate
files.
- Rename 'smoke' to 'exhaustive' ('multi' mode can also be used
for "smoke testing") to better describe its behavior.
- Rewrite the runners in Typescript for type safety.
- Refactor common build utilities into dev-tools/build.js and
introduce the notion of a 'full' build analogous to 'full' tests.
(This error wasn't caught because it still works without installing
the dependency, but makes the build script far slower because
`npx replace` would reinstall `replace` every time it's used.)
The modern `__esModule` fallback isn't compatible with Node, and also
entirely unnecessary in practice.
The approach of disabling all the fallback code allows us to once again
`import * as fs`.
Hotpatching and running `./pokemon-showdown` now automatically run
`./build`. There should now mostly not be any reason you'd want to
manually run `./build`, except if you're invoking tests directly.
In addition, a lot of redundant code has been removed.
I'm not 100% sure this works on Windows, but I'm sure I'll get reports
if anything breaks.