Skip to content

Commit 65be198

Browse files
committed
refactor: robust peer dependency isolation tests
1 parent ebd52aa commit 65be198

4 files changed

Lines changed: 29 additions & 62 deletions

File tree

.github/workflows/build-tests.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
# Ensures no accidential Node.js API usage in browser and Edge compatible entrypoints.
1+
# Ensures no accidential Node.js API usage in browser and Edge compatible
2+
# entrypoints, and that gRPC-only helpers stay isolated from the pb-free
3+
# entrypoints. The two `test-build:*` steps run in DIFFERENT environments:
4+
# 1. workers-safe: no @grpc/grpc-js, no @bufbuild/protobuf installed.
5+
# esbuild fails natively if any Workers-safe entry pulls them in.
6+
# Mirrors what a real Workers / REST-only consumer gets.
7+
# 2. grpc: pb + grpc-js reinstalled; the gRPC entrypoint must resolve.
28

39
name: Run Build Tests
410

511
on:
612
push:
7-
branches: [ "main", "epic/**" ]
13+
branches: ['main', 'epic/**']
814
pull_request:
9-
branches: [ "main", "epic/**" ]
15+
branches: ['main', 'epic/**']
1016
paths-ignore:
1117
- '**.md'
1218
- 'LICENSE'
@@ -15,16 +21,22 @@ on:
1521

1622
jobs:
1723
test:
18-
1924
runs-on: ubuntu-latest
2025

2126
steps:
22-
- uses: actions/checkout@v4
23-
- uses: actions/setup-node@v4
24-
with:
25-
node-version: 20
26-
registry-url: 'https://registry.npmjs.org'
27-
cache: 'npm'
28-
- run: npm ci
29-
- run: npm run build
30-
- run: npm run test-build
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
registry-url: 'https://registry.npmjs.org'
32+
cache: 'npm'
33+
- run: npm ci
34+
- run: npm run build
35+
# Strip the optional peer deps so esbuild sees the same module graph
36+
# a non-gRPC consumer would. Any Workers-safe entrypoint that leaks
37+
# a gRPC / pb import fails to resolve here.
38+
- run: npm uninstall --no-save @grpc/grpc-js @bufbuild/protobuf
39+
- run: npm run test-build:workers-safe
40+
# Reinstall the peer deps and verify the gRPC entrypoint still bundles.
41+
- run: npm install --no-save @grpc/grpc-js @bufbuild/protobuf
42+
- run: npm run test-build:grpc

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@
170170
"coverage": "vitest run --coverage",
171171
"generate": "curl https://raw.githubusercontent.com/google-a2a/A2A/refs/heads/main/specification/json/a2a.json > spec.json && node scripts/generateTypes.js && rm spec.json",
172172
"generate:compat": "curl https://raw.githubusercontent.com/a2aproject/A2A/v0.3.0/specification/json/a2a.json > compat_spec.json && node scripts/generateCompatTypes.js && rm compat_spec.json",
173-
"test-build": "esbuild ./dist/client/index.js ./dist/server/index.js ./dist/index.js ./dist/errors/index.js ./dist/errors/grpc/index.js ./dist/compat/v0_3/index.js ./dist/compat/v0_3/client/index.js ./dist/compat/v0_3/server/index.js --bundle --platform=neutral --outdir=dist/tmp-checks --outbase=./dist && node scripts/checkWorkersSafeBundles.js",
173+
"test-build:workers-safe": "esbuild ./dist/index.js ./dist/errors/index.js ./dist/client/index.js ./dist/server/index.js ./dist/compat/v0_3/index.js ./dist/compat/v0_3/client/index.js ./dist/compat/v0_3/server/index.js --bundle --platform=neutral --outdir=dist/tmp-checks --outbase=./dist",
174+
"test-build:grpc": "esbuild ./dist/errors/grpc/index.js --bundle --platform=neutral --outdir=dist/tmp-checks --outbase=./dist",
175+
"test-build": "npm run test-build:workers-safe && npm run test-build:grpc",
174176
"itk-agent": "tsx itk/itk_agent.ts"
175177
},
176178
"dependencies": {

scripts/checkWorkersSafeBundles.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export default defineConfig({
2121
format: ['esm', 'cjs'],
2222
dts: true,
2323
clean: true,
24+
splitting: false,
2425
});

0 commit comments

Comments
 (0)