From 3e9851a2c9126b8b98d4341b4de97152790d1ec3 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Sat, 5 Jul 2025 17:48:19 -0300 Subject: [PATCH] Configures ESBuild --- esbuild.config.mjs | 12 ++++++++++++ package.json | 4 +++- rollup.config.js | 32 -------------------------------- 3 files changed, 15 insertions(+), 33 deletions(-) create mode 100644 esbuild.config.mjs delete mode 100644 rollup.config.js diff --git a/esbuild.config.mjs b/esbuild.config.mjs new file mode 100644 index 0000000..e8ab925 --- /dev/null +++ b/esbuild.config.mjs @@ -0,0 +1,12 @@ +import { build } from 'esbuild'; + +build({ + entryPoints: ['src/main.ts'], + bundle: true, + target: 'es2018', // Screeps supports ES2018 well + platform: 'node', + format: 'cjs', + outdir: 'dist', + sourcemap: true, + logLevel: 'info', +}).catch(() => process.exit(1)); diff --git a/package.json b/package.json index 39aaf74..99d08bd 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "3.0.0", "description": "", "scripts": { - "format": "prettier --config .prettierrc 'src/**/*.ts' --write && eslint --fix src/" + "format": "prettier --config .prettierrc 'src/**/*.ts' --write && eslint --fix src/", + "build": "node esbuild.config.mjs" }, "repository": { "type": "git", @@ -31,6 +32,7 @@ "@typescript-eslint/parser": "^8.35.1", "@typescript-eslint/typescript-estree": "^8.35.1", "chai": "^5.2.0", + "esbuild": "^0.25.5", "eslint": "^9.30.1", "eslint-config-prettier": "^10.1.5", "eslint-import-resolver-typescript": "^4.4.4", diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 70da24d..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; - -import clear from 'rollup-plugin-clear'; -import resolve from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; -import typescript from 'rollup-plugin-typescript2'; -import screeps from 'rollup-plugin-screeps'; - -let cfg; -const dest = process.env.DEST; -if (!dest) { - console.log("No destination specified - code will be compiled but not uploaded"); -} else if ((cfg = require("./screeps.json")[dest]) == null) { - throw new Error("Invalid upload destination"); -} - -export default { - input: "src/main.ts", - output: { - file: "dist/main.js", - format: "cjs", - sourcemap: true - }, - - plugins: [ - clear({ targets: ["dist"] }), - resolve({ rootDir: "src" }), - commonjs(), - typescript({tsconfig: "./tsconfig.json"}), - screeps({config: cfg, dryRun: cfg == null}) - ] -}