@kjerneverk/execution-openai 1.0.8-dev.20260212012315.eb02292 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUGFIX.md +74 -0
- package/dist/index.js +23 -23681
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/BUGFIX.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Bug Fix: Bundling Error in @kjerneverk/execution-openai v1.0.7
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
The published v1.0.7 package had a critical bundling error where two different Node.js built-in modules (`diagnostics_channel` and `util`) were incorrectly aliased to the same variable (`require$$0`), causing runtime failures:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
TypeError: util2.debuglog is not a function
|
|
9
|
+
at requireDiagnostics (node_modules/@kjerneverk/execution-openai/dist/index.js:1849:32)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Root Cause
|
|
13
|
+
|
|
14
|
+
The `undici` package was being bundled into the distribution file instead of being treated as an external dependency. When Vite bundled `undici`, it encountered Node.js built-in modules that weren't marked as external, causing the bundler to:
|
|
15
|
+
|
|
16
|
+
1. Replace them with browser shims (`__viteBrowserExternal`)
|
|
17
|
+
2. Incorrectly deduplicate different built-ins into the same variable
|
|
18
|
+
3. Create a 23,924-line bundle with broken module references
|
|
19
|
+
|
|
20
|
+
## Solution
|
|
21
|
+
|
|
22
|
+
Added `undici` to the `external` array in `vite.config.ts`:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
rollupOptions: {
|
|
26
|
+
external: [
|
|
27
|
+
"openai",
|
|
28
|
+
"tiktoken",
|
|
29
|
+
"undici", // ← Added this
|
|
30
|
+
"execution",
|
|
31
|
+
"@utilarium/offrecord",
|
|
32
|
+
"@utilarium/spotclean",
|
|
33
|
+
"node:crypto",
|
|
34
|
+
],
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Results
|
|
39
|
+
|
|
40
|
+
- Bundle size reduced from 23,924 lines to 265 lines
|
|
41
|
+
- `undici` is now imported as an external dependency (as it should be)
|
|
42
|
+
- No more `require$$0` variable conflicts
|
|
43
|
+
- Package imports successfully without errors
|
|
44
|
+
- All tests pass
|
|
45
|
+
|
|
46
|
+
## Testing
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Build the package
|
|
50
|
+
npm run clean && npm run build
|
|
51
|
+
|
|
52
|
+
# Test import
|
|
53
|
+
node -e "import('./dist/index.js').then(() => console.log('✓ Import successful'))"
|
|
54
|
+
# Output: ✓ Import successful
|
|
55
|
+
|
|
56
|
+
# Run tests
|
|
57
|
+
npm test
|
|
58
|
+
# Output: All 18 tests passed
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Next Steps
|
|
62
|
+
|
|
63
|
+
1. Commit the fix
|
|
64
|
+
2. Publish v1.0.8 to npm
|
|
65
|
+
3. Update dependent packages (@grunnverk/ai-service, kodrdriv, etc.)
|
|
66
|
+
|
|
67
|
+
## Why This Fix Works
|
|
68
|
+
|
|
69
|
+
`undici` is a Node.js-specific networking library that:
|
|
70
|
+
- Uses Node.js built-in modules (`util`, `diagnostics_channel`, `stream`, etc.)
|
|
71
|
+
- Should not be bundled for Node.js environments
|
|
72
|
+
- Is already a dependency in package.json
|
|
73
|
+
|
|
74
|
+
By externalizing it, we let consuming packages resolve it from `node_modules` at runtime, avoiding the bundling issues entirely.
|