bun runtime doesnt work with SKD ably javascript starting v2.0.0

13 views Asked by At

This question is about the new update of the ably SKD javascript library

Hey, Is there anything Im missing out? - my typescript code stop working with the new ably version library. Things to consider: -Ably Version 1.2.50 -Bun installed -Keep reading for package.json

import * as Ably from 'ably';
// const Ably = require('ably')
// For the full code sample see here: https://github.com/ably/quickstart-js
const ably = new Ably.Realtime(process.env.ABLY_API_KEY);
await ably.connection.once('connected');
console.log('Connected to Ably!');
const to_rec = ably.channels.get('TEST')

await to_rec.subscribe((message) => {
    console.log('inside subscribe')
    console.log('message received for event ' + message.name);
    console.log('message data:' + message.data);
  });
    
import * as Ably from 'ably';
// const Ably = require('ably')
// For the full code sample see here: https://github.com/ably/quickstart-js
const ably = new Ably.Realtime(process.env.ABLY_API_KEY);

await ably.connection.once('connected');
console.log('Connected to Ably!');
const to_test = ably.channels.get('TEST')
await to_test.publish('greeting', 'hello!');

This same code works if run in node and ably version ^2.0.0

{
  "name": "DOES NOT WORK",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "ably": "^2.0.1",
    "hono": "^4.1.3",
    "pm2": "^5.3.1",
    "redis": "^4.6.13"
  }
}
{
  "name": "DOES WORK!",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "@flydotio/dockerfile": "latest",
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@cloudamqp/amqp-client": "^3.1.1",
    "ably": "1.2.50",
    "axios": "^1.6.8",
    "hono": "^4.1.3",
    "redis": "^4.6.13"
  }
}

I had run the sample file (sub_ex.mjs and pub_ex.mjs) codes with other extension files and runtimes. So far I have tried with .mjs, .ts, .js. and with node runtime, bun runtime v1.2.50 works with all extensions and both runtimes v2.0.0 // v2.0.1 only works with .mjs and node

0

There are 0 answers