aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-07-20 16:25:02 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-20 16:25:02 -0700
commite2c11c4856f27ea3f93a9c1d2efb899a39dccb7f (patch)
tree158772d5e9c47e805d1738e3a39a3fbd2e628185
parent9ad330d9176604bddb58972e1cedce7a80009ddc (diff)
downloadbun-e2c11c4856f27ea3f93a9c1d2efb899a39dccb7f.tar.gz
bun-e2c11c4856f27ea3f93a9c1d2efb899a39dccb7f.tar.zst
bun-e2c11c4856f27ea3f93a9c1d2efb899a39dccb7f.zip
fix process.binding (#3711)
-rw-r--r--src/js/builtins/codegen/index.ts7
-rw-r--r--src/js/out/WebCoreJSBuiltins.cpp20
2 files changed, 13 insertions, 14 deletions
diff --git a/src/js/builtins/codegen/index.ts b/src/js/builtins/codegen/index.ts
index 4171533b2..2984599fd 100644
--- a/src/js/builtins/codegen/index.ts
+++ b/src/js/builtins/codegen/index.ts
@@ -39,7 +39,7 @@ console.log("Bundling Bun builtins...");
const MINIFY = process.argv.includes("--minify") || process.argv.includes("-m");
const PARALLEL = process.argv.includes("--parallel") || process.argv.includes("-p");
-const KEEP_TMP = process.argv.includes("--keep-tmp") || process.argv.includes("-k");
+const KEEP_TMP = process.argv.includes("--keep-tmp") || process.argv.includes("-k") || true;
const SRC_DIR = path.join(import.meta.dir, "../");
const OUT_DIR = path.join(SRC_DIR, "../out");
@@ -52,7 +52,6 @@ const define = {
"process.env.NODE_ENV": "development",
"process.platform": process.platform,
"process.arch": process.arch,
- "$lazy": "___BUN_LAZY___",
};
for (const name in enums) {
@@ -230,8 +229,8 @@ $$capture_start$$(${fn.async ? "async " : ""}${
const finalReplacement =
(fn.directives.sloppy ? captured : captured.replace(/function\s*\(.*?\)\s*{/, '$&"use strict";'))
.replace(/^\((async )?function\(/, "($1function (")
- .replace(/__intrinsic__/g, "@")
- .replace(/___BUN_LAZY___/g, "globalThis[globalThis.Symbol.for('Bun.lazy')]") + "\n";
+ .replace(/__intrinsic__lazy/g, "globalThis[globalThis.Symbol.for('Bun.lazy')]")
+ .replace(/__intrinsic__/g, "@") + "\n";
bundledFunctions.push({
name: fn.name,
diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp
index 8dc4abf50..07dbf0a05 100644
--- a/src/js/out/WebCoreJSBuiltins.cpp
+++ b/src/js/out/WebCoreJSBuiltins.cpp
@@ -638,9 +638,9 @@ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
const JSC::ConstructAbility s_processObjectInternalsBindingCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_processObjectInternalsBindingCodeLength = 433;
+const int s_processObjectInternalsBindingCodeLength = 473;
static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic;
-const char* const s_processObjectInternalsBindingCode = "(function (u){\"use strict\";if(u!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var p=globalThis.Symbol.for(\"process.bindings.constants\"),r=globalThis[p];if(!r){const{constants:I}=@lazy(\"createImportMeta\",\"node:process\").require(\"node:fs\");r={fs:I,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[p]=r}return r})\n";
+const char* const s_processObjectInternalsBindingCode = "(function (u){\"use strict\";if(u!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var p=globalThis.Symbol.for(\"process.bindings.constants\"),r=globalThis[p];if(!r){const{constants:I}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"createImportMeta\",\"node:process\").require(\"node:fs\");r={fs:I,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[p]=r}return r})\n";
// getStdioWriteStream
const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
@@ -1818,9 +1818,9 @@ const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanClo
const JSC::ConstructAbility s_readableStreamInternalsLazyLoadStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_readableStreamInternalsLazyLoadStreamCodeLength = 1589;
+const int s_readableStreamInternalsLazyLoadStreamCodeLength = 1709;
static const JSC::Intrinsic s_readableStreamInternalsLazyLoadStreamCodeIntrinsic = JSC::NoIntrinsic;
-const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=@lazyLoad(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},@lazyStreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n";
+const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=globalThis[globalThis.Symbol.for('Bun.lazy')]StreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=globalThis[globalThis.Symbol.for('Bun.lazy')]Load(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},globalThis[globalThis.Symbol.for('Bun.lazy')]StreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n";
// readableStreamIntoArray
const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
@@ -2464,9 +2464,9 @@ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATO
const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public;
-const int s_readableStreamInitializeReadableStreamCodeLength = 2143;
+const int s_readableStreamInitializeReadableStreamCodeLength = 2263;
static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
-const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,v){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(v===@undefined)v={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(v!==@undefined&&!@isObject(v))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0),@putByIdDirectPrivate(this,\"asyncContext\",@getInternalField(@asyncContext,0));const B=_.type===\"direct\",R=!!_.@lazy,P=B||R;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!P){const m=@getByIdDirectPrivate(v,\"size\"),f=@getByIdDirectPrivate(v,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,m,f!==@undefined\?f:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,v));else if(P){const m=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",m||@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const f=@lazyLoadStream(this,m);if(f)@createReadableStreamController(this,f,v)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,v);return this})\n";
+const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,v){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,globalThis[globalThis.Symbol.for('Bun.lazy')]:!1};if(v===@undefined)v={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(v!==@undefined&&!@isObject(v))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0),@putByIdDirectPrivate(this,\"asyncContext\",@getInternalField(@asyncContext,0));const B=_.type===\"direct\",R=!!_.globalThis[globalThis.Symbol.for('Bun.lazy')],P=B||R;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!P){const m=@getByIdDirectPrivate(v,\"size\"),f=@getByIdDirectPrivate(v,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,m,f!==@undefined\?f:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,v));else if(P){const m=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",m||@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const f=globalThis[globalThis.Symbol.for('Bun.lazy')]LoadStream(this,m);if(f)@createReadableStreamController(this,f,v)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,v);return this})\n";
// readableStreamToArray
const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
@@ -2520,9 +2520,9 @@ const char* const s_readableStreamReadableStreamToBlobCode = "(function (n){\"us
const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private;
-const int s_readableStreamConsumeReadableStreamCodeLength = 1563;
+const int s_readableStreamConsumeReadableStreamCodeLength = 1603;
static const JSC::Intrinsic s_readableStreamConsumeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
-const char* const s_readableStreamConsumeReadableStreamCode = "(function (G,q,A){\"use strict\";const B=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var k=globalThis[B];if(!k)k=globalThis[B]=[];var w=k[q];if(w===@undefined){var[L,H,I,J,N,D]=@lazy(q);w=class K{handleError;handleClosed;processResult;constructor(_,j){this.#$=j,this.#j=_,this.#_=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),_.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#_)return;this.#_=!0;var _=this.#$;this.#$=0,J(_),D(_)}_handleError(_){if(this.#_)return;this.#_=!0;var j=this.#$;this.#$=0,H(j,_),D(j)}#$;#_=!1;#j;_handleReadMany({value:_,done:j,size:x}){if(j){this.handleClosed();return}if(this.#_)return;I(this.#$,_,j,x)}read(){if(!this.#$)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#j.read())}_processResult(_){if(_&&@isPromise(_)){if(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateFulfilled){const x=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(x)_=x}}if(_&&@isPromise(_))return _.then(this.processResult,this.handleError),null;if(_.done)return this.handleClosed(),0;else if(_.value)return _.value;else return-1}readMany(){if(!this.#$)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#j.readMany())}};const F=q+1;if(k.length<F)k.length=F;@putByValDirect(k,q,w)}if(@isReadableStreamLocked(A))@throwTypeError(\"Cannot start reading from a locked stream\");return new w(A.getReader(),G)})\n";
+const char* const s_readableStreamConsumeReadableStreamCode = "(function (G,q,A){\"use strict\";const B=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var k=globalThis[B];if(!k)k=globalThis[B]=[];var w=k[q];if(w===@undefined){var[L,H,I,J,N,D]=globalThis[globalThis.Symbol.for('Bun.lazy')](q);w=class K{handleError;handleClosed;processResult;constructor(_,j){this.#$=j,this.#j=_,this.#_=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),_.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#_)return;this.#_=!0;var _=this.#$;this.#$=0,J(_),D(_)}_handleError(_){if(this.#_)return;this.#_=!0;var j=this.#$;this.#$=0,H(j,_),D(j)}#$;#_=!1;#j;_handleReadMany({value:_,done:j,size:x}){if(j){this.handleClosed();return}if(this.#_)return;I(this.#$,_,j,x)}read(){if(!this.#$)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#j.read())}_processResult(_){if(_&&@isPromise(_)){if(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateFulfilled){const x=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(x)_=x}}if(_&&@isPromise(_))return _.then(this.processResult,this.handleError),null;if(_.done)return this.handleClosed(),0;else if(_.value)return _.value;else return-1}readMany(){if(!this.#$)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#j.readMany())}};const F=q+1;if(k.length<F)k.length=F;@putByValDirect(k,q,w)}if(@isReadableStreamLocked(A))@throwTypeError(\"Cannot start reading from a locked stream\");return new w(A.getReader(),G)})\n";
// createEmptyReadableStream
const JSC::ConstructAbility s_readableStreamCreateEmptyReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
@@ -2536,9 +2536,9 @@ const char* const s_readableStreamCreateEmptyReadableStreamCode = "(function (){
const JSC::ConstructAbility s_readableStreamCreateNativeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const JSC::ConstructorKind s_readableStreamCreateNativeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
const JSC::ImplementationVisibility s_readableStreamCreateNativeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private;
-const int s_readableStreamCreateNativeReadableStreamCodeLength = 129;
+const int s_readableStreamCreateNativeReadableStreamCodeLength = 169;
static const JSC::Intrinsic s_readableStreamCreateNativeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
-const char* const s_readableStreamCreateNativeReadableStreamCode = "(function (d,m,r){\"use strict\";return new @ReadableStream({@lazy:!0,@bunNativeType:m,@bunNativePtr:d,autoAllocateChunkSize:r})})\n";
+const char* const s_readableStreamCreateNativeReadableStreamCode = "(function (d,m,r){\"use strict\";return new @ReadableStream({globalThis[globalThis.Symbol.for('Bun.lazy')]:!0,@bunNativeType:m,@bunNativePtr:d,autoAllocateChunkSize:r})})\n";
// cancel
const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;