Skip to content

Commit 86f6cfa

Browse files
ci: use esbuild to ensure client and root entry points build for browser (#210)
# Description Add an automated test for the issue solved previously in #46 to ensure that client and root entry points build for browsers. Example failure would look like: ``` ✘ [ERROR] Could not resolve "events" dist/server/index.js:27:29: 27 │ import { EventEmitter } from "events"; ╵ ~~~~~~~~ The package "events" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "--platform=node" to do that, which will remove this error. ``` (obtained by running `esbuild ./dist/server/index.js --bundle --platform=browser --outdir=dist/tmp-checks --outbase=./dist`) --------- Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
1 parent 2768ae8 commit 86f6cfa

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.github/workflows/build-tests.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Ensures no accidential Node.js API usage in browser-compatible entrypoints.
2+
3+
name: Run Build Tests
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
jobs:
12+
test:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
registry-url: 'https://registry.npmjs.org'
22+
cache: 'npm'
23+
- run: npm ci
24+
- run: npm run build
25+
- run: npm run test-build:browser

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@types/supertest": "^6.0.3",
5252
"c8": "^10.1.3",
5353
"chai": "^5.2.0",
54+
"esbuild": "^0.27.0",
5455
"eslint": "^9.39.1",
5556
"eslint-config-prettier": "^10.1.8",
5657
"eslint-plugin-prettier": "^5.5.4",
@@ -80,7 +81,8 @@
8081
"a2a:cli": "tsx src/samples/cli.ts",
8182
"agents:movie-agent": "tsx src/samples/agents/movie-agent/index.ts",
8283
"agents:sample-agent": "tsx src/samples/agents/sample-agent/index.ts",
83-
"agents:extension-agent": "tsx src/samples/extensions/index.ts"
84+
"agents:extension-agent": "tsx src/samples/extensions/index.ts",
85+
"test-build:browser": "esbuild ./dist/client/index.js ./dist/index.js --bundle --platform=browser --outdir=dist/tmp-checks --outbase=./dist"
8486
},
8587
"dependencies": {
8688
"uuid": "^11.1.0"

0 commit comments

Comments
 (0)