From 5e09bc9d996b4f9404515ffbcca5fa7dd0dde4f2 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 12 Jul 2026 00:01:32 -0700 Subject: [PATCH] Revert to single esbuild script and move into scripts directory. --- esbuild/build.mjs | 24 ----------------------- package.json | 12 ++++++------ esbuild/config.mjs => scripts/build.mjs | 26 +++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 esbuild/build.mjs rename esbuild/config.mjs => scripts/build.mjs (70%) diff --git a/esbuild/build.mjs b/esbuild/build.mjs deleted file mode 100644 index 55c40a3..0000000 --- a/esbuild/build.mjs +++ /dev/null @@ -1,24 +0,0 @@ -//! SPDX-FileCopyrightText: 2026 Chris Duncan -//! SPDX-License-Identifier: GPL-3.0-or-later - -import { build } from 'esbuild' -import { bundleOptions, cliOptions } from './config.mjs' - -const prodOptions = { - minify: true, - sourcemap: undefined -} - -if (process.env.NODE_ENV !== 'development') { - build({ - ...bundleOptions, - ...prodOptions - }) - build({ - ...cliOptions, - ...prodOptions - }) -} else { - build(bundleOptions) - build(cliOptions) -} diff --git a/package.json b/package.json index d06a1b3..bb943e1 100644 --- a/package.json +++ b/package.json @@ -43,15 +43,15 @@ "url": "git+https://codecow.com/nano-pow.git" }, "scripts": { - "benchmark": "npm run build && ./dist/bin/nano-pow.sh --benchmark 10 --debug", - "build": "npm run clean && npm run generate && node esbuild/build.mjs && cp -p src/bin/nano-pow.sh dist/bin", + "benchmark": "npm run build && dist/bin/nano-pow.sh --benchmark 10 --debug", + "build": "npm run clean && npm run generate && node scripts/build.mjs && cp -p src/bin/nano-pow.sh dist/bin", "build:dev": "NODE_ENV=development npm run build", "clean": "rm -rf dist types && tsc", - "generate": "node ./scripts/blake2b-gen.js && asc src/lib/generate/wasm/asm/index.ts", + "generate": "node scripts/blake2b-gen.js && asc src/lib/generate/wasm/asm/index.ts", "prepare": "npm run build", - "score": "npm run build && ./dist/bin/nano-pow.sh --effort 4 --benchmark 10 --score 10", - "start": "node --max-http-header-size=1024 --max-old-space-size=256 ./dist/bin/server.js", - "test": "npm run build:dev && ./test/script.sh" + "score": "npm run build && dist/bin/nano-pow.sh --effort 4 --benchmark 10 --score 10", + "start": "node --max-http-header-size=1024 --max-old-space-size=256 dist/bin/server.js", + "test": "npm run build:dev && test/script.sh" }, "devDependencies": { "@types/node": "^26.1.1", diff --git a/esbuild/config.mjs b/scripts/build.mjs similarity index 70% rename from esbuild/config.mjs rename to scripts/build.mjs index f02f40d..082ce3e 100644 --- a/esbuild/config.mjs +++ b/scripts/build.mjs @@ -1,6 +1,7 @@ //! SPDX-FileCopyrightText: 2026 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later +import { build } from 'esbuild' import { glsl } from 'esbuild-plugin-glsl' /** @import { BuildOptions } from 'esbuild' */ @@ -25,7 +26,7 @@ const sharedOptions = { } /** @type BuildOptions */ -export const bundleOptions = { +const bundleOptions = { ...sharedOptions, bundle: true, platform: 'browser', @@ -37,7 +38,7 @@ export const bundleOptions = { } /** @type BuildOptions */ -export const cliOptions = { +const cliOptions = { ...sharedOptions, bundle: false, platform: 'node', @@ -48,3 +49,24 @@ export const cliOptions = { packages: 'external', target: 'node22' } + +/** @type BuildOptions */ +const prodOptions = { + drop: ['debugger'], + minify: true, + sourcemap: undefined +} + +if (process.env.NODE_ENV === 'development') { + build(bundleOptions) + build(cliOptions) +} else { + build({ + ...bundleOptions, + ...prodOptions + }) + build({ + ...cliOptions, + ...prodOptions + }) +} -- 2.52.0