Open History to see the last commit
1import { readFileSync, readdirSync, statSync } from 'node:fs'
2import { join, resolve } from 'node:path'
3
4const bundleDir = resolve(process.argv[2] ?? '.esbuild-smoke-dist')
5
6const forbidden = [
7 '/api/chat',
8 '@anthropic-ai/sdk',
9 '@fal-ai/client',
10 '@google/genai',
11 '@google/generative-ai',
12 '@openrouter/sdk',
13 '@tanstack/ai-react/ui',
14 '@tanstack/react-ai-devtools',
15 '@tanstack/solid-ai-devtools',
16 'elevenlabs',
17 'node:fs',
18 'node:http',
19 'node:https',
20 'node:stream',
21 'ollama',
22 'openai',
23 'react-dom',
24 'solid-js',
25 'svelte',
26 'vue',
27 'zod',
28]
29
30function filesIn(dir: string): Array<string> {
31 return readdirSync(dir).flatMap((entry) => {
32 const full = join(dir, entry)
33 return statSync(full).isDirectory() ? filesIn(full) : [full]
34 })
35}
36
37function containsForbiddenToken(source: string, token: string): boolean {
38 // pnpm peer folders look like `_zod@4.2.1` in esbuild path comments.
39 // That is not a real `zod` import. Match `zod` as its own token only.
40 if (token === 'zod') {
41 return /(?:^|[^A-Za-z0-9_])zod(?:$|[^A-Za-z0-9_])/.test(source)
42 }
43 return source.includes(token)
44}
45
46const failures: Array<string> = []
47let scannedJavaScriptFiles = 0
48
49for (const file of filesIn(bundleDir)) {
50 if (!/\.(js|json|html)$/.test(file)) continue
51 if (/\.js$/.test(file)) scannedJavaScriptFiles += 1
52 const source = readFileSync(file, 'utf8')
53 for (const token of forbidden) {
54 if (containsForbiddenToken(source, token)) {
55 failures.push(`${file} contains forbidden bundle token ${token}`)
56 }
57 }
58}
59
60if (scannedJavaScriptFiles === 0) {
61 failures.push(`${bundleDir} does not contain any JavaScript output files`)
62}
63
64if (failures.length > 0) {
65 console.error(failures.join('\n'))
66 process.exit(1)
67}
68
69console.log('React Native bundle smoke passed.')