aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-08-10 11:57:37 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-10 11:57:37 -0700
commit68ac8c12c20cafc92467485abc5c2d5c052a11e0 (patch)
treedcf99dbac6bded997e976bf3daff2c47eba61e77
parent28d1676d505b1180b9fe1fa9b7a7bf30ad13e547 (diff)
downloadbun-68ac8c12c20cafc92467485abc5c2d5c052a11e0.tar.gz
bun-68ac8c12c20cafc92467485abc5c2d5c052a11e0.tar.zst
bun-68ac8c12c20cafc92467485abc5c2d5c052a11e0.zip
remove non-node node-fallbacks (#4082)
* remove non-node node-fallbacks. * organize the imports
Diffstat (limited to '')
-rw-r--r--src/bun.js/module_loader.zig129
-rw-r--r--src/js/out/InternalModuleRegistryConstants.h6
-rw-r--r--src/node-fallbacks/@vercel_fetch.js32
-rw-r--r--src/node-fallbacks/isomorphic-fetch.js8
-rw-r--r--src/node-fallbacks/node-fetch.js92
-rw-r--r--src/node-fallbacks/supports-color.js43
-rw-r--r--src/node_fallbacks.zig78
7 files changed, 67 insertions, 321 deletions
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 3932736fc..ccee5208d 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -2365,53 +2365,34 @@ pub const HardcodedModule = enum {
pub const Aliases = bun.ComptimeStringMap(
Alias,
.{
- .{ "assert", .{ .path = "node:assert" } },
- .{ "assert/strict", .{ .path = "node:assert/strict" } },
- .{ "async_hooks", .{ .path = "node:async_hooks" } },
- .{ "buffer", .{ .path = "node:buffer" } },
.{ "bun", .{ .path = "bun", .tag = .bun } },
.{ "bun:ffi", .{ .path = "bun:ffi" } },
.{ "bun:jsc", .{ .path = "bun:jsc" } },
.{ "bun:sqlite", .{ .path = "bun:sqlite" } },
.{ "bun:wrap", .{ .path = "bun:wrap" } },
- .{ "child_process", .{ .path = "node:child_process" } },
- .{ "constants", .{ .path = "node:constants" } },
- .{ "crypto", .{ .path = "node:crypto" } },
- .{ "detect-libc", .{ .path = "detect-libc" } },
- .{ "detect-libc/lib/detect-libc.js", .{ .path = "detect-libc" } },
- .{ "dns", .{ .path = "node:dns" } },
- .{ "dns/promises", .{ .path = "node:dns/promises" } },
- .{ "events", .{ .path = "node:events" } },
.{ "ffi", .{ .path = "bun:ffi" } },
- .{ "fs", .{ .path = "node:fs" } },
- .{ "fs/promises", .{ .path = "node:fs/promises" } },
- .{ "http", .{ .path = "node:http" } },
- .{ "https", .{ .path = "node:https" } },
- .{ "module", .{ .path = "node:module" } },
- .{ "net", .{ .path = "node:net" } },
+
.{ "node:assert", .{ .path = "node:assert" } },
.{ "node:assert/strict", .{ .path = "node:assert/strict" } },
.{ "node:async_hooks", .{ .path = "node:async_hooks" } },
.{ "node:buffer", .{ .path = "node:buffer" } },
.{ "node:child_process", .{ .path = "node:child_process" } },
- .{ "node:constants", .{ .path = "node:constants" } },
+ .{ "node:cluster", .{ .path = "node:cluster" } },
.{ "node:console", .{ .path = "node:console" } },
- .{ "console", .{ .path = "node:console" } },
- .{ "node:querystring", .{ .path = "node:querystring" } },
- .{ "querystring", .{ .path = "node:querystring" } },
- .{ "node:domain", .{ .path = "node:domain" } },
- .{ "domain", .{ .path = "node:domain" } },
- .{ "@vercel/fetch", .{ .path = "@vercel/fetch" } },
- .{ "node:punycode", .{ .path = "node:punycode" } },
- .{ "punycode", .{ .path = "node:punycode" } },
+ .{ "node:constants", .{ .path = "node:constants" } },
.{ "node:crypto", .{ .path = "node:crypto" } },
+ .{ "node:dgram", .{ .path = "node:dgram" } },
+ .{ "node:diagnostics_channel", .{ .path = "node:diagnostics_channel" } },
.{ "node:dns", .{ .path = "node:dns" } },
.{ "node:dns/promises", .{ .path = "node:dns/promises" } },
+ .{ "node:domain", .{ .path = "node:domain" } },
.{ "node:events", .{ .path = "node:events" } },
.{ "node:fs", .{ .path = "node:fs" } },
.{ "node:fs/promises", .{ .path = "node:fs/promises" } },
.{ "node:http", .{ .path = "node:http" } },
+ .{ "node:http2", .{ .path = "node:http2" } },
.{ "node:https", .{ .path = "node:https" } },
+ .{ "node:inspector", .{ .path = "node:inspector" } },
.{ "node:module", .{ .path = "node:module" } },
.{ "node:net", .{ .path = "node:net" } },
.{ "node:os", .{ .path = "node:os" } },
@@ -2420,8 +2401,11 @@ pub const HardcodedModule = enum {
.{ "node:path/win32", .{ .path = "node:path/win32" } },
.{ "node:perf_hooks", .{ .path = "node:perf_hooks" } },
.{ "node:process", .{ .path = "node:process" } },
+ .{ "node:punycode", .{ .path = "node:punycode" } },
+ .{ "node:querystring", .{ .path = "node:querystring" } },
.{ "node:readline", .{ .path = "node:readline" } },
.{ "node:readline/promises", .{ .path = "node:readline/promises" } },
+ .{ "node:repl", .{ .path = "node:repl" } },
.{ "node:stream", .{ .path = "node:stream" } },
.{ "node:stream/consumers", .{ .path = "node:stream/consumers" } },
.{ "node:stream/promises", .{ .path = "node:stream/promises" } },
@@ -2430,21 +2414,51 @@ pub const HardcodedModule = enum {
.{ "node:timers", .{ .path = "node:timers" } },
.{ "node:timers/promises", .{ .path = "node:timers/promises" } },
.{ "node:tls", .{ .path = "node:tls" } },
+ .{ "node:trace_events", .{ .path = "node:trace_events" } },
.{ "node:tty", .{ .path = "node:tty" } },
.{ "node:url", .{ .path = "node:url" } },
.{ "node:util", .{ .path = "node:util" } },
.{ "node:util/types", .{ .path = "node:util/types" } },
+ .{ "node:v8", .{ .path = "node:v8" } },
+ .{ "node:vm", .{ .path = "node:vm" } },
.{ "node:wasi", .{ .path = "node:wasi" } },
.{ "node:worker_threads", .{ .path = "node:worker_threads" } },
.{ "node:zlib", .{ .path = "node:zlib" } },
+
+ .{ "assert", .{ .path = "node:assert" } },
+ .{ "assert/strict", .{ .path = "node:assert/strict" } },
+ .{ "async_hooks", .{ .path = "node:async_hooks" } },
+ .{ "buffer", .{ .path = "node:buffer" } },
+ .{ "child_process", .{ .path = "node:child_process" } },
+ .{ "cluster", .{ .path = "node:cluster" } },
+ .{ "console", .{ .path = "node:console" } },
+ .{ "constants", .{ .path = "node:constants" } },
+ .{ "crypto", .{ .path = "node:crypto" } },
+ .{ "dgram", .{ .path = "node:dgram" } },
+ .{ "diagnostics_channel", .{ .path = "node:diagnostics_channel" } },
+ .{ "dns", .{ .path = "node:dns" } },
+ .{ "dns/promises", .{ .path = "node:dns/promises" } },
+ .{ "domain", .{ .path = "node:domain" } },
+ .{ "events", .{ .path = "node:events" } },
+ .{ "fs", .{ .path = "node:fs" } },
+ .{ "fs/promises", .{ .path = "node:fs/promises" } },
+ .{ "http", .{ .path = "node:http" } },
+ .{ "http2", .{ .path = "node:http2" } },
+ .{ "https", .{ .path = "node:https" } },
+ .{ "inspector", .{ .path = "node:inspector" } },
+ .{ "module", .{ .path = "node:module" } },
+ .{ "net", .{ .path = "node:net" } },
.{ "os", .{ .path = "node:os" } },
.{ "path", .{ .path = "node:path" } },
.{ "path/posix", .{ .path = "node:path/posix" } },
.{ "path/win32", .{ .path = "node:path/win32" } },
.{ "perf_hooks", .{ .path = "node:perf_hooks" } },
.{ "process", .{ .path = "node:process" } },
+ .{ "punycode", .{ .path = "node:punycode" } },
+ .{ "querystring", .{ .path = "node:querystring" } },
.{ "readline", .{ .path = "node:readline" } },
.{ "readline/promises", .{ .path = "node:readline/promises" } },
+ .{ "repl", .{ .path = "node:repl" } },
.{ "stream", .{ .path = "node:stream" } },
.{ "stream/consumers", .{ .path = "node:stream/consumers" } },
.{ "stream/promises", .{ .path = "node:stream/promises" } },
@@ -2453,22 +2467,22 @@ pub const HardcodedModule = enum {
.{ "timers", .{ .path = "node:timers" } },
.{ "timers/promises", .{ .path = "node:timers/promises" } },
.{ "tls", .{ .path = "node:tls" } },
+ .{ "trace_events", .{ .path = "node:trace_events" } },
.{ "tty", .{ .path = "node:tty" } },
- .{ "undici", .{ .path = "undici" } },
.{ "url", .{ .path = "node:url" } },
.{ "util", .{ .path = "node:util" } },
.{ "util/types", .{ .path = "node:util/types" } },
+ .{ "v8", .{ .path = "node:v8" } },
+ .{ "vm", .{ .path = "node:vm" } },
.{ "wasi", .{ .path = "node:wasi" } },
.{ "worker_threads", .{ .path = "node:worker_threads" } },
- .{ "ws", .{ .path = "ws" } },
- .{ "ws/lib/websocket", .{ .path = "ws" } },
- .{ "utf-8-validate", .{ .path = "utf-8-validate" } },
.{ "zlib", .{ .path = "node:zlib" } },
- // .{ "readable-stream", .{ .path = "node:stream" } },
- // .{ "readable-stream/consumer", .{ .path = "node:stream/consumers" } },
- // .{ "readable-stream/web", .{ .path = "node:stream/web" } },
- // Older versions of `readable-stream` is incompatible with latest
- // version of Node.js Stream API, which `bun` implements
+
+ // It implements the same interface
+ .{ "sys", .{ .path = "node:util" } },
+ .{ "node:sys", .{ .path = "node:util" } },
+ .{ "inspector/promises", .{ .path = "node:inspector" } },
+ .{ "node:inspector/promises", .{ .path = "node:inspector" } },
// These are returned in builtinModules, but probably not many packages use them
// so we will just alias them.
@@ -2487,37 +2501,22 @@ pub const HardcodedModule = enum {
.{ "_tls_wrap", .{ .path = "node:tls" } },
.{ "_tls_common", .{ .path = "node:tls" } },
- // These are not actually implemented, they are stubbed out
- .{ "cluster", .{ .path = "node:cluster" } },
- .{ "dgram", .{ .path = "node:dgram" } },
- .{ "diagnostics_channel", .{ .path = "node:diagnostics_channel" } },
- .{ "http2", .{ .path = "node:http2" } },
- .{ "inspector", .{ .path = "node:inspector" } },
- .{ "repl", .{ .path = "node:repl" } },
- .{ "trace_events", .{ .path = "node:trace_events" } },
- .{ "v8", .{ .path = "node:v8" } },
- .{ "vm", .{ .path = "node:vm" } },
-
- // It implements the same interface
- .{ "inspector/promises", .{ .path = "node:inspector" } },
- .{ "node:inspector/promises", .{ .path = "node:inspector" } },
-
- .{ "node:cluster", .{ .path = "node:cluster" } },
- .{ "node:dgram", .{ .path = "node:dgram" } },
- .{ "node:diagnostics_channel", .{ .path = "node:diagnostics_channel" } },
- .{ "node:http2", .{ .path = "node:http2" } },
- .{ "node:inspector", .{ .path = "node:inspector" } },
- .{ "node:repl", .{ .path = "node:repl" } },
- .{ "node:trace_events", .{ .path = "node:trace_events" } },
- .{ "node:v8", .{ .path = "node:v8" } },
- .{ "node:vm", .{ .path = "node:vm" } },
-
- .{ "node:sys", .{ .path = "node:util" } },
- .{ "sys", .{ .path = "node:util" } },
+ // Older versions of `readable-stream` is incompatible with latest
+ // version of Node.js Stream API, which `bun` implements
+ // .{ "readable-stream", .{ .path = "node:stream" } },
+ // .{ "readable-stream/consumer", .{ .path = "node:stream/consumers" } },
+ // .{ "readable-stream/web", .{ .path = "node:stream/web" } },
- .{ "node-fetch", .{ .path = "node-fetch" } },
- .{ "isomorphic-fetch", .{ .path = "isomorphic-fetch" } },
+ // Thirdparty packages we override
.{ "@vercel/fetch", .{ .path = "@vercel/fetch" } },
+ .{ "detect-libc", .{ .path = "detect-libc" } },
+ .{ "detect-libc/lib/detect-libc.js", .{ .path = "detect-libc" } },
+ .{ "isomorphic-fetch", .{ .path = "isomorphic-fetch" } },
+ .{ "node-fetch", .{ .path = "node-fetch" } },
+ .{ "undici", .{ .path = "undici" } },
+ .{ "utf-8-validate", .{ .path = "utf-8-validate" } },
+ .{ "ws", .{ .path = "ws" } },
+ .{ "ws/lib/websocket", .{ .path = "ws" } },
},
);
};
diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h
index 99140663d..2cc902671 100644
--- a/src/js/out/InternalModuleRegistryConstants.h
+++ b/src/js/out/InternalModuleRegistryConstants.h
@@ -189,7 +189,7 @@ static constexpr ASCIILiteral NodeWasiCode = "(function (){\"use strict\";const
//
//
-static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),{MessageChannel,BroadcastChannel,Worker:WebWorker}=globalThis,SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\");const emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort;let resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}let parentPort=isMainThread\?null:fakeParentPort();function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throwNotImplemented(\"worker_threads.markAsUntransferable\")}function moveMessagePortToContext(){throwNotImplemented(\"worker_threads.moveMessagePortToContext\")}const unsupportedOptions=[\"eval\",\"argv\",\"execArgv\",\"stdin\",\"stdout\",\"stderr\",\"trackedUnmanagedFds\",\"resourceLimits\"];class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();for(let key of unsupportedOptions)if(key in options)emitWarning(\"option.\"+key,`worker_threads.Worker option \"${key}\" is not implemented.`);this.#worker=new WebWorker(filename,options),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return emitWarning(\"performance\",\"worker_threads.Worker.performance is not implemented.\"),{idle:0,active:0,utilization:0}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.once(\"exit\",(code)=>{resolve(code)}),this.#worker.terminate(),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(e){console.log(\"worker closed\",e),this.#onExitPromise=e.code,this.emit(\"exit\",e.code)}#onError(event){this.emit(\"error\",event.error)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error\?\?event.data\?\?event)}#onOpen(){this.emit(\"online\")}async getHeapSnapshot(){throwNotImplemented(\"worker_threads.Worker.getHeapSnapshot\")}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s;
+static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),{MessageChannel,BroadcastChannel,Worker:WebWorker}=globalThis,SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\");const emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort;let resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}let parentPort=isMainThread\?null:fakeParentPort();function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throwNotImplemented(\"worker_threads.markAsUntransferable\")}function moveMessagePortToContext(){throwNotImplemented(\"worker_threads.moveMessagePortToContext\")}const unsupportedOptions=[\"eval\",\"argv\",\"execArgv\",\"stdin\",\"stdout\",\"stderr\",\"trackedUnmanagedFds\",\"resourceLimits\"];class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();for(let key of unsupportedOptions)if(key in options)emitWarning(\"option.\"+key,`worker_threads.Worker option \"${key}\" is not implemented.`);this.#worker=new WebWorker(filename,options),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return emitWarning(\"performance\",\"worker_threads.Worker.performance is not implemented.\"),{idle:0,active:0,utilization:0}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.#worker.addEventListener(\"close\",(event)=>{resolve(event.code)},{once:!0}),this.#worker.terminate(),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(e){this.#onExitPromise=e.code,this.emit(\"exit\",e.code)}#onError(event){this.emit(\"error\",event.error)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error\?\?event.data\?\?event)}#onOpen(){this.emit(\"online\")}async getHeapSnapshot(){throwNotImplemented(\"worker_threads.Worker.getHeapSnapshot\")}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s;
//
//
@@ -414,7 +414,7 @@ static constexpr ASCIILiteral NodeWasiCode = "(function (){\"use strict\";const
//
//
-static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),{MessageChannel,BroadcastChannel,Worker:WebWorker}=globalThis,SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\");const emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort;let resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}let parentPort=isMainThread\?null:fakeParentPort();function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throwNotImplemented(\"worker_threads.markAsUntransferable\")}function moveMessagePortToContext(){throwNotImplemented(\"worker_threads.moveMessagePortToContext\")}const unsupportedOptions=[\"eval\",\"argv\",\"execArgv\",\"stdin\",\"stdout\",\"stderr\",\"trackedUnmanagedFds\",\"resourceLimits\"];class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();for(let key of unsupportedOptions)if(key in options)emitWarning(\"option.\"+key,`worker_threads.Worker option \"${key}\" is not implemented.`);this.#worker=new WebWorker(filename,options),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return emitWarning(\"performance\",\"worker_threads.Worker.performance is not implemented.\"),{idle:0,active:0,utilization:0}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.once(\"exit\",(code)=>{resolve(code)}),this.#worker.terminate(),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(e){console.log(\"worker closed\",e),this.#onExitPromise=e.code,this.emit(\"exit\",e.code)}#onError(event){this.emit(\"error\",event.error)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error\?\?event.data\?\?event)}#onOpen(){this.emit(\"online\")}async getHeapSnapshot(){throwNotImplemented(\"worker_threads.Worker.getHeapSnapshot\")}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s;
+static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),{MessageChannel,BroadcastChannel,Worker:WebWorker}=globalThis,SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\");const emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort;let resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}let parentPort=isMainThread\?null:fakeParentPort();function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throwNotImplemented(\"worker_threads.markAsUntransferable\")}function moveMessagePortToContext(){throwNotImplemented(\"worker_threads.moveMessagePortToContext\")}const unsupportedOptions=[\"eval\",\"argv\",\"execArgv\",\"stdin\",\"stdout\",\"stderr\",\"trackedUnmanagedFds\",\"resourceLimits\"];class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();for(let key of unsupportedOptions)if(key in options)emitWarning(\"option.\"+key,`worker_threads.Worker option \"${key}\" is not implemented.`);this.#worker=new WebWorker(filename,options),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return emitWarning(\"performance\",\"worker_threads.Worker.performance is not implemented.\"),{idle:0,active:0,utilization:0}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.#worker.addEventListener(\"close\",(event)=>{resolve(event.code)},{once:!0}),this.#worker.terminate(),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(e){this.#onExitPromise=e.code,this.emit(\"exit\",e.code)}#onError(event){this.emit(\"error\",event.error)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error\?\?event.data\?\?event)}#onOpen(){this.emit(\"online\")}async getHeapSnapshot(){throwNotImplemented(\"worker_threads.Worker.getHeapSnapshot\")}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s;
//
//
@@ -640,7 +640,7 @@ static constexpr ASCIILiteral NodeWasiCode = "(function (){\"use strict\";const
//
//
-static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),{MessageChannel,BroadcastChannel,Worker:WebWorker}=globalThis,SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\");const emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort;let resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}let parentPort=isMainThread\?null:fakeParentPort();function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throwNotImplemented(\"worker_threads.markAsUntransferable\")}function moveMessagePortToContext(){throwNotImplemented(\"worker_threads.moveMessagePortToContext\")}const unsupportedOptions=[\"eval\",\"argv\",\"execArgv\",\"stdin\",\"stdout\",\"stderr\",\"trackedUnmanagedFds\",\"resourceLimits\"];class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();for(let key of unsupportedOptions)if(key in options)emitWarning(\"option.\"+key,`worker_threads.Worker option \"${key}\" is not implemented.`);this.#worker=new WebWorker(filename,options),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return emitWarning(\"performance\",\"worker_threads.Worker.performance is not implemented.\"),{idle:0,active:0,utilization:0}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.once(\"exit\",(code)=>{resolve(code)}),this.#worker.terminate(),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(e){console.log(\"worker closed\",e),this.#onExitPromise=e.code,this.emit(\"exit\",e.code)}#onError(event){this.emit(\"error\",event.error)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error\?\?event.data\?\?event)}#onOpen(){this.emit(\"online\")}async getHeapSnapshot(){throwNotImplemented(\"worker_threads.Worker.getHeapSnapshot\")}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s;
+static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),{MessageChannel,BroadcastChannel,Worker:WebWorker}=globalThis,SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\");const emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort;let resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}let parentPort=isMainThread\?null:fakeParentPort();function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throwNotImplemented(\"worker_threads.markAsUntransferable\")}function moveMessagePortToContext(){throwNotImplemented(\"worker_threads.moveMessagePortToContext\")}const unsupportedOptions=[\"eval\",\"argv\",\"execArgv\",\"stdin\",\"stdout\",\"stderr\",\"trackedUnmanagedFds\",\"resourceLimits\"];class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();for(let key of unsupportedOptions)if(key in options)emitWarning(\"option.\"+key,`worker_threads.Worker option \"${key}\" is not implemented.`);this.#worker=new WebWorker(filename,options),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return emitWarning(\"performance\",\"worker_threads.Worker.performance is not implemented.\"),{idle:0,active:0,utilization:0}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.#worker.addEventListener(\"close\",(event)=>{resolve(event.code)},{once:!0}),this.#worker.terminate(),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(e){this.#onExitPromise=e.code,this.emit(\"exit\",e.code)}#onError(event){this.emit(\"error\",event.error)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error\?\?event.data\?\?event)}#onOpen(){this.emit(\"online\")}async getHeapSnapshot(){throwNotImplemented(\"worker_threads.Worker.getHeapSnapshot\")}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s;
//
//
diff --git a/src/node-fallbacks/@vercel_fetch.js b/src/node-fallbacks/@vercel_fetch.js
deleted file mode 100644
index 276b4bc9f..000000000
--- a/src/node-fallbacks/@vercel_fetch.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// This is just a no-op. Intent is to prevent importing a bunch of stuff that isn't relevant.
-export default (wrapper = "Bun" in globalThis ? Bun.fetch : globalThis.fetch) => {
- async function vercelFetch(url, opts = {}) {
- // Convert Object bodies to JSON if they are JS objects
- if (
- opts.body &&
- typeof opts.body === "object" &&
- (!("buffer" in opts.body) || typeof opts.body.buffer !== "object" || !(opts.body.buffer instanceof ArrayBuffer))
- ) {
- opts.body = JSON.stringify(opts.body);
- // Content length will automatically be set
- if (!opts.headers) opts.headers = new Headers();
-
- opts.headers.set("Content-Type", "application/json");
- }
-
- try {
- return await wrapper(url, opts);
- } catch (err) {
- if (typeof err === "string") {
- err = new Error(err);
- }
-
- err.url = url;
- err.opts = opts;
- throw err;
- }
- }
-
- vercelFetch.default = vercelFetch;
- return vercelFetch;
-};
diff --git a/src/node-fallbacks/isomorphic-fetch.js b/src/node-fallbacks/isomorphic-fetch.js
deleted file mode 100644
index 4e5e96bdd..000000000
--- a/src/node-fallbacks/isomorphic-fetch.js
+++ /dev/null
@@ -1,8 +0,0 @@
-var fetchHandler = globalThis.fetch;
-
-if ("Bun" in globalThis) {
- fetchHandler = Bun.fetch;
-}
-
-export default fetchHandler;
-export { fetchHandler as fetch };
diff --git a/src/node-fallbacks/node-fetch.js b/src/node-fallbacks/node-fetch.js
deleted file mode 100644
index e02089623..000000000
--- a/src/node-fallbacks/node-fetch.js
+++ /dev/null
@@ -1,92 +0,0 @@
-var { Headers, Request, Response, Blob, File = Blob, FormData, fetch: realFetch } = globalThis;
-
-if ("Bun" in globalThis) {
- realFetch = Bun.fetch;
-}
-
-function fetch(...args) {
- // require("node-fetch") returns the default export which means we need to
- // repeat the ESM exports onto it.
- //
- // We don't want to copy that onto the global fetch object, so we wrap it.
- return realFetch(...args);
-}
-
-class AbortError extends DOMException {
- constructor(message) {
- super(message, "AbortError");
- }
-}
-
-class FetchBaseError extends Error {
- constructor(message, type) {
- super(message);
- this.type = type;
- }
-}
-
-class FetchError extends FetchBaseError {
- constructor(message, type, systemError) {
- super(message, type);
- this.code = systemError?.code;
- }
-}
-
-function blobFrom(path, options) {
- if ("Bun" in globalThis) {
- return Promise.resolve(Bun.file(data));
- }
-
- return fetch(path, options).then(response => response.blob());
-}
-
-function blobFromSync(path, options) {
- if ("Bun" in globalThis) {
- return Bun.file(data);
- }
-
- return fetch(path, options).then(response => response.blob());
-}
-
-var fileFrom = blobFrom;
-var fileFromSync = blobFromSync;
-
-function isRedirect(code) {
- return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
-}
-
-export default Object.assign(fetch, {
- AbortError,
- Blob,
- FetchBaseError,
- FetchError,
- File,
- FormData,
- Headers,
- Request,
- Response,
- blobFrom,
- blobFromSync,
- fileFrom,
- fileFromSync,
- isRedirect,
- default: fetch,
-});
-
-export {
- AbortError,
- Blob,
- FetchBaseError,
- FetchError,
- File,
- FormData,
- Headers,
- Request,
- Response,
- blobFrom,
- blobFromSync,
- fileFrom,
- fileFromSync,
- isRedirect,
- fetch,
-};
diff --git a/src/node-fallbacks/supports-color.js b/src/node-fallbacks/supports-color.js
deleted file mode 100644
index a7e748232..000000000
--- a/src/node-fallbacks/supports-color.js
+++ /dev/null
@@ -1,43 +0,0 @@
-var supportsColor;
-
-if ("Bun" in globalThis) {
- if (Bun.enableANSIColors) {
- const colors = {
- level: 2,
- hasBasic: true,
- has256: true,
- has16m: false,
- };
-
- supportsColor = {
- stdout: colors,
- stderr: colors,
- };
- } else {
- supportsColor = {
- stdout: false,
- stderr: false,
- };
- }
-} else {
- const isBlinkBasedBrowser = /\b(Chrome|Chromium)\//.test(navigator.userAgent);
-
- const colorSupport = isBlinkBasedBrowser
- ? {
- level: 1,
- hasBasic: true,
- has256: false,
- has16m: false,
- }
- : false;
-
- supportsColor = {
- stdout: colorSupport,
- stderr: colorSupport,
- };
-}
-
-export default supportsColor;
-export const stdout = supportsColor.stdout;
-export const stderr = supportsColor.stderr;
-export { supportsColor };
diff --git a/src/node_fallbacks.zig b/src/node_fallbacks.zig
index a8f125943..00af75885 100644
--- a/src/node_fallbacks.zig
+++ b/src/node_fallbacks.zig
@@ -29,11 +29,6 @@ const tty_code: string = @embedFile("./node-fallbacks/out/tty.js");
const url_code: string = @embedFile("./node-fallbacks/out/url.js");
const util_code: string = @embedFile("./node-fallbacks/out/util.js");
const zlib_code: string = @embedFile("./node-fallbacks/out/zlib.js");
-const supports_color_code: string = @embedFile("./node-fallbacks/out/supports-color.js");
-
-const node_fetch_code: string = @embedFile("./node-fallbacks/out/node-fetch.js");
-const isomorphic_fetch_code: string = @embedFile("./node-fallbacks/out/isomorphic-fetch.js");
-const vercel_fetch_code: string = @embedFile("./node-fallbacks/out/@vercel_fetch.js");
const assert_import_path = "/bun-vfs/node_modules/assert/index.js";
const buffer_import_path = "/bun-vfs/node_modules/buffer/index.js";
@@ -58,11 +53,6 @@ const tty_import_path = "/bun-vfs/node_modules/tty/index.js";
const url_import_path = "/bun-vfs/node_modules/url/index.js";
const util_import_path = "/bun-vfs/node_modules/util/index.js";
const zlib_import_path = "/bun-vfs/node_modules/zlib/index.js";
-const supports_color_import_path = "/bun-vfs/node_modules/supports-color/index.js";
-
-const node_fetch_import_path = "/bun-vfs/node_modules/node-fetch/index.js";
-const isomorphic_fetch_import_path = "/bun-vfs/node_modules/isomorphic-fetch/index.js";
-const vercel_fetch_import_path = "/bun-vfs/node_modules/@vercel/fetch/index.js";
const assert_package_json = PackageJSON{
.name = "assert",
@@ -277,44 +267,6 @@ const zlib_package_json = PackageJSON{
.source = logger.Source.initPathString("/bun-vfs/node_modules/zlib/package.json", ""),
};
-const node_fetch_package_json = PackageJSON{
- .name = "node-fetch",
- .version = "0.0.0-polyfill",
- .module_type = .esm,
- .hash = @as(u32, @truncate(bun.hash("node-fetch@0.0.0-polyfill"))),
- .main_fields = undefined,
- .browser_map = undefined,
- .source = logger.Source.initPathString("/bun-vfs/node_modules/node-fetch/package.json", ""),
-};
-const isomorphic_fetch_package_json = PackageJSON{
- .name = "isomorphic-fetch",
- .version = "0.0.0-polyfill",
- .module_type = .esm,
- .hash = @as(u32, @truncate(bun.hash("isomorphic-fetch@0.0.0-polyfill"))),
- .main_fields = undefined,
- .browser_map = undefined,
- .source = logger.Source.initPathString("/bun-vfs/node_modules/isomorphic-fetch/package.json", ""),
-};
-const supports_color_package_json = PackageJSON{
- .name = "supports-color",
- .version = "0.0.0-polyfill",
- .module_type = .esm,
- .hash = @as(u32, @truncate(bun.hash("supports-color@0.0.0-polyfill"))),
- .main_fields = undefined,
- .browser_map = undefined,
- .source = logger.Source.initPathString("/bun-vfs/node_modules/supports-color/package.json", ""),
-};
-
-const vercel_fetch_package_json = PackageJSON{
- .name = "@vercel/fetch",
- .version = "0.0.0-polyfill",
- .module_type = .esm,
- .hash = @as(u32, @truncate(bun.hash("@vercel/fetch@0.0.0-polyfill"))),
- .main_fields = undefined,
- .browser_map = undefined,
- .source = logger.Source.initPathString("/bun-vfs/node_modules/@vercel/fetch/package.json", ""),
-};
-
pub const FallbackModule = struct {
path: Fs.Path,
code: string,
@@ -435,30 +387,6 @@ pub const FallbackModule = struct {
.code = zlib_code,
.package_json = &zlib_package_json,
};
-
- pub const @"node-fetch" = FallbackModule{
- .path = Fs.Path.initWithNamespaceVirtual(node_fetch_import_path, "node", "node-fetch"),
- .code = node_fetch_code,
- .package_json = &node_fetch_package_json,
- };
-
- pub const @"isomorphic-fetch" = FallbackModule{
- .path = Fs.Path.initWithNamespaceVirtual(isomorphic_fetch_import_path, "node", "isomorphic-fetch"),
- .code = isomorphic_fetch_code,
- .package_json = &isomorphic_fetch_package_json,
- };
-
- pub const @"@vercel/fetch" = FallbackModule{
- .path = Fs.Path.initWithNamespaceVirtual(vercel_fetch_import_path, "node", "@vercel/fetch"),
- .code = vercel_fetch_code,
- .package_json = &vercel_fetch_package_json,
- };
-
- pub const @"supports-color" = FallbackModule{
- .path = Fs.Path.initWithNamespaceVirtual(supports_color_import_path, "node", "supports-color"),
- .code = supports_color_code,
- .package_json = &supports_color_package_json,
- };
};
pub const Map = ComptimeStringMap(FallbackModule, .{
@@ -485,12 +413,6 @@ pub const Map = ComptimeStringMap(FallbackModule, .{
&.{ "url", FallbackModule.url },
&.{ "util", FallbackModule.util },
&.{ "zlib", FallbackModule.zlib },
-
- &.{ "supports-color", FallbackModule.@"supports-color" },
-
- &.{ "node-fetch", FallbackModule.@"node-fetch" },
- &.{ "isomorphic-fetch", FallbackModule.@"isomorphic-fetch" },
- &.{ "@vercel/fetch", FallbackModule.@"@vercel/fetch" },
});
pub fn contentsFromPath(path: string) ?string {