Just learned something interesting - with a minor ...
# typescript
l
Just learned something interesting - with a minor patch to the Pulumi JS package, Bun actually works when compiled into a single-file provider executable. No idea how stable it is though.
The patch `patches/@pulumi%2Fpulumi@3.141.0.patch`:
Copy code
diff --git a/proto/status_pb.js b/proto/status_pb.js
index 417ea6fac76d3353fc76dc41a5163a25d9aa15ec..b6dbb754a20e963b674cfb94c51989a1fe10f5f9 100644
--- a/proto/status_pb.js
+++ b/proto/status_pb.js
@@ -13,7 +13,7 @@
 
 var jspb = require('google-protobuf');
 var goog = jspb;
-var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);
+var global = (function() { return this || global || self || Function('return this')(); }).call(null);
 
 var google_protobuf_any_pb = require('google-protobuf/google/protobuf/any_pb.js');
 goog.object.extend(proto, google_protobuf_any_pb);
diff --git a/runtime/closure/v8.js b/runtime/closure/v8.js
index 511ed9ec75cedc4b1c0da945eb57683165adb8cd..5d8e83c22e5e9057934cec0df268325946c312ca 100644
--- a/runtime/closure/v8.js
+++ b/runtime/closure/v8.js
@@ -37,7 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 // As a side-effect of importing this file, we must enable the --allow-natives-syntax V8 flag. This
 // is because we are using V8 intrinsics in order to implement this module.
 const v8 = __importStar(require("v8"));
-v8.setFlagsFromString("--allow-natives-syntax");
+// v8.setFlagsFromString("--allow-natives-syntax");
 const util = __importStar(require("util"));
 const vm = __importStar(require("vm"));
 const v8Hooks = __importStar(require("./v8Hooks"));
diff --git a/runtime/closure/v8Hooks.js b/runtime/closure/v8Hooks.js
index 748aa56a1542d49bde4ef31adf3063e4b3e5acd3..c8c25641e852990f7cd11c66b6785e66e172ce8d 100644
--- a/runtime/closure/v8Hooks.js
+++ b/runtime/closure/v8Hooks.js
@@ -34,7 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
 // Otherwise, information may not be known when needed.  This module is only intended for use on
 // Node v11 and higher.
 const v8 = __importStar(require("v8"));
-v8.setFlagsFromString("--allow-natives-syntax");
+// v8.setFlagsFromString("--allow-natives-syntax");
 let session = undefined;
 function getSession() {
     if (session !== undefined) {
Sadly I still don't think there's a good way to have Pulumi use a different JS runtime when invoking a TS pulumi program, but bun does make putting together component providers a lot more convenient (I did try some symlink shenanigans but it does some weirdness that I didn't have time to troubleshoot)
l
More bun please! Submit patch!
l
I very much doubt other parts of Pulumi will work in bun, especially the closure callback stuff. It also only works when being used as a provider (ie over grpc) - it doesn't work when ran directly as a program with pulumi. I'd be curious to see if I can get the tests for an existing TS-based Pulumi component provider working though. Maybe the EKS one
l
That closure callback stuff is best avoided. I've had so many difficulties with it. I'm happy to have a big warning on that doc page saying it works only with ts-node. I compile my lambdas outside of Pulumi and just use the .zip.
l
I know from experience it works with tsx - all of my projects replace ts-node with tsx to make module support tolerable. Really wish they'd just bundle it tbh
But yeah the callback stuff has always felt like abusing the inner-workings of v8 in some disgusting ways 😛
c
@late-balloon-24601 It would be great to post your findings in https://github.com/pulumi/pulumi/issues/13904!
l
Sure - Have posted a comment. Good place to make sure the patch doesn't get lost 🙂