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
|
|
@ -3,7 +3,7 @@
|
|||
* Provides cache coherence across multiple Brainy instances
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import { EventEmitter } from 'node:events'
|
||||
|
||||
export interface CacheSyncConfig {
|
||||
nodeId: string
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
* Provides leader election, consensus, and coordination for distributed instances
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { NetworkTransport, NetworkMessage } from './networkTransport.js'
|
||||
import { createHash } from 'crypto'
|
||||
import { createHash } from 'node:crypto'
|
||||
|
||||
export interface NodeInfo {
|
||||
id: string
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
* REAL PRODUCTION CODE - Handles millions of operations
|
||||
*/
|
||||
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
import { EventEmitter } from 'events'
|
||||
import * as net from 'net'
|
||||
import { URL } from 'url'
|
||||
import * as http from 'node:http'
|
||||
import * as https from 'node:https'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import * as net from 'node:net'
|
||||
import { URL } from 'node:url'
|
||||
|
||||
export interface TransportMessage {
|
||||
id: string
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
* Uses WebSocket + HTTP for maximum compatibility
|
||||
*/
|
||||
|
||||
import * as http from 'http'
|
||||
import { EventEmitter } from 'events'
|
||||
import * as http from 'node:http'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { WebSocket } from 'ws'
|
||||
|
||||
// Use dynamic imports for Node.js specific modules
|
||||
|
|
@ -378,7 +378,7 @@ export class NetworkTransport extends EventEmitter {
|
|||
|
||||
try {
|
||||
// Query Kubernetes API for pod endpoints
|
||||
const https = await import('https')
|
||||
const https = await import('node:https')
|
||||
const response = await new Promise<any>((resolve, reject) => {
|
||||
https.get(
|
||||
`${apiServer}/api/v1/namespaces/${namespace}/endpoints/${serviceName}`,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Implements primary-replica architecture for scalable reads
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { DistributedCoordinator } from './coordinator.js'
|
||||
import { ShardManager } from './shardManager.js'
|
||||
import { CacheSync } from './cacheSync.js'
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
* Implements consistent hashing for data distribution across shards
|
||||
*/
|
||||
|
||||
import { createHash } from 'crypto'
|
||||
import { EventEmitter } from 'events'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { EventEmitter } from 'node:events'
|
||||
|
||||
export interface ShardConfig {
|
||||
shardCount?: number
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Uses streaming for efficient transfer of large datasets
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import type { StorageAdapter } from '../coreTypes.js'
|
||||
import type { ShardManager } from './shardManager.js'
|
||||
import type { HTTPTransport } from './httpTransport.js'
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
* REAL PRODUCTION CODE - No mocks, no stubs!
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import * as os from 'os'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import * as os from 'node:os'
|
||||
import { StorageAdapter } from '../coreTypes.js'
|
||||
|
||||
export interface NodeInfo {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue