feat: add node: protocol to all Node.js built-in imports for bundler compatibility
- Updated all fs, path, crypto, os, url, util, events, http, https, net, child_process, stream, and zlib imports
- Changed both static imports and dynamic imports to use node: protocol
- This makes Brainy more bundler-friendly by explicitly marking Node.js built-ins
- Prevents bundlers from attempting to polyfill or bundle these modules
- Reduces bundle size for web applications using Brainy
- Improves tree-shaking and dead code elimination
Benefits for external bundlers:
- Clear distinction between Node.js built-ins and external dependencies
- No ambiguity about what needs polyfilling
- Smaller bundles for browser builds
- Better compatibility with modern bundlers (Webpack 5, Vite, Rollup, esbuild)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1b32870e43
commit
fcb7197fb0
40 changed files with 165 additions and 77 deletions
|
|
@ -11,10 +11,10 @@
|
|||
* 4. System MUST fail fast if model unavailable in production
|
||||
*/
|
||||
|
||||
import { existsSync } from 'fs'
|
||||
import { readFile, mkdir, writeFile, stat } from 'fs/promises'
|
||||
import { join, dirname } from 'path'
|
||||
import { createHash } from 'crypto'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { readFile, mkdir, writeFile, stat } from 'node:fs/promises'
|
||||
import { join, dirname } from 'node:path'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { env } from '@huggingface/transformers'
|
||||
|
||||
// CRITICAL: These values MUST NEVER CHANGE
|
||||
|
|
@ -207,8 +207,8 @@ export class ModelGuardian {
|
|||
*/
|
||||
private async computeFileHash(filePath: string): Promise<string> {
|
||||
try {
|
||||
const { readFile } = await import('fs/promises')
|
||||
const { createHash } = await import('crypto')
|
||||
const { readFile } = await import('node:fs/promises')
|
||||
const { createHash } = await import('node:crypto')
|
||||
const fileBuffer = await readFile(filePath)
|
||||
const hash = createHash('sha256').update(fileBuffer).digest('hex')
|
||||
return hash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue