From 9bea00dd1bef2f450c396ff9e7c49fa419629187 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 18 Jul 2025 14:25:18 -0700 Subject: [PATCH] Make adjustments to esbuild for node environment. --- esbuild-common.mjs | 1 - esbuild-dev.mjs | 2 +- esbuild-node.mjs | 4 +++- esbuild-prod.mjs | 2 +- test/GLOBALS.mjs | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/esbuild-common.mjs b/esbuild-common.mjs index 7cb5919..ced85d9 100644 --- a/esbuild-common.mjs +++ b/esbuild-common.mjs @@ -13,7 +13,6 @@ export const options = { loader: { '.d.ts': 'copy' }, - inject: ['./buffer.mjs'], format: 'esm', legalComments: 'inline', outdir: 'dist', diff --git a/esbuild-dev.mjs b/esbuild-dev.mjs index 85e70fa..2a4f1d1 100644 --- a/esbuild-dev.mjs +++ b/esbuild-dev.mjs @@ -4,6 +4,6 @@ import { build } from 'esbuild' import { options } from './esbuild-common.mjs' -options.platform = 'browser' +options.dropLabels = ['NODE'] options.inject = ['./buffer.mjs'] await build(options) diff --git a/esbuild-node.mjs b/esbuild-node.mjs index 9f3142d..59c13ac 100644 --- a/esbuild-node.mjs +++ b/esbuild-node.mjs @@ -4,5 +4,7 @@ import { build } from 'esbuild' import { options } from './esbuild-common.mjs' -options.platform = 'node' +options.dropLabels = ['BROWSER'] +options.inject = ['./node-shims.mjs'] +options.external = ['node:worker_threads'] await build(options) diff --git a/esbuild-prod.mjs b/esbuild-prod.mjs index 5cbb8df..a4b534c 100644 --- a/esbuild-prod.mjs +++ b/esbuild-prod.mjs @@ -4,7 +4,7 @@ import { build } from 'esbuild' import { options } from './esbuild-common.mjs' -options.platform = 'browser' options.drop = ['console', 'debugger'] +options.dropLabels = ['NODE'] options.inject = ['./buffer.mjs'] await build(options) diff --git a/test/GLOBALS.mjs b/test/GLOBALS.mjs index 5435b17..10f5cae 100644 --- a/test/GLOBALS.mjs +++ b/test/GLOBALS.mjs @@ -29,7 +29,7 @@ export async function click (text, fn) { const button = document.createElement('button') const hourglass = document.createTextNode('⏳') button.innerText = text - button.addEventListener('click', async () => { + button.onclick = async () => { button.disabled = true button.innerText = 'Waiting for device...' button.after(hourglass) @@ -42,7 +42,7 @@ export async function click (text, fn) { hourglass.remove() button.remove() } - }) + } document.body.appendChild(button) window?.scrollTo(0, document.body.scrollHeight) }) -- 2.47.3