For anyone else trying to use ESBuild with a build script, just note that attempting to run the build script using ESBuild will not work. Instead, you need to run it with Node:

# Wrong
$ esbuild ./build-script.mjs

# Right
$ node ./build-script.mjs