Commit 22be61c
fix: resolve undici browser compatibility with dynamic imports
Replace static undici import with dynamic import and environment detection
to prevent 'process.versions.node' errors in browser environments.
- Remove static import of undici Agent
- Add dynamic import that only loads undici in Node.js environments
- Implement environment detection using process.versions?.node
- Cache agent instance to prevent multiple imports
- Maintain full backward compatibility for Node.js users
- Enable browser usage without undici import errors
Fixes browser bundling issues while preserving Node.js performance benefits.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 87d1780 commit 22be61c
1 file changed
+34
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
21 | 20 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
26 | 52 | | |
27 | 53 | | |
28 | 54 | | |
| |||
141 | 167 | | |
142 | 168 | | |
143 | 169 | | |
144 | | - | |
| 170 | + | |
145 | 171 | | |
146 | 172 | | |
147 | 173 | | |
| |||
0 commit comments