Skip to content

Commit

Permalink
More compatibility fixes for bun
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed May 18, 2022
1 parent d0b34e3 commit 32a15e4
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import EventEmitter from 'events';
import { EventEmitter } from 'events';
import { setExternals, setNativeFunctions, Dbi } from './native.js';
import { arch, tmpdir, platform } from 'os';
import fs from 'fs';
import { Encoder as MsgpackrEncoder } from 'msgpackr';
import { WeakLRUCache } from 'weak-lru-cache';
import * as orderedBinary from 'ordered-binary';


orderedBinary.enableNullTermination();
setExternals({
arch, fs, tmpdir, MsgpackrEncoder, WeakLRUCache, orderedBinary,
Expand Down
1 change: 0 additions & 1 deletion native.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ path = pathModule;
let dirName = (typeof __dirname == 'string' ? __dirname : // for bun, which doesn't have fileURLToPath
dirname(fileURLToPath(import.meta.url))).replace(/dist$/, ''); // for node, which doesn't have __dirname in ESM
export let nativeAddon = loadNAPI(dirName);
console.log('nativeAddon.getByBinaryPtr', nativeAddon.getByBinaryPtr)
if (process.isBun) {
const { linkSymbols, FFIType } = require('bun:ffi');
console.log(FFIType);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"prebuild-libc-expanded": "prebuildify --tag-libc --target 16.14.0 && prebuildify --tag-libc --target 14.19.1 && prebuildify --tag-libc --target 17.9.0 && prebuildify --tag-libc --target 18.0.0 && ENABLE_V8_FUNCTIONS=false prebuildify --tag-libc --napi --optional-packages --target 16.14.0",
"prebuild-libc": "prebuildify --tag-libc --target 17.9.0 && prebuildify --tag-libc --target 18.0.0 && prebuildify --napi --optional-packages --tag-libc --target 16.14.2",
"prebuildify": "prebuildify --target 16.14.2",
"prepare": "rollup -c",
"full-publish": "cd prebuilds/win32-x64 && npm publish --otp %OTP% && cd ../darwin-x64 && npm publish --otp %OTP% && cd ../darwin-arm64 && npm publish --otp %OTP% && cd ../linux-x64 && npm publish --otp %OTP% && cd ../linux-arm64 && npm publish --otp %OTP% && cd ../linux-arm && npm publish --otp %OTP% && cd ../.. && npm publish",
"recompile": "node-gyp clean && node-gyp configure && node-gyp build",
"test": "mocha test/**.test.js --recursive && npm run test:types",
Expand Down
2 changes: 1 addition & 1 deletion write.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ABORT = {};
export const IF_EXISTS = 3.542694326329068e-103;
const CALLBACK_THREW = {};
const LocalSharedArrayBuffer = typeof Deno != 'undefined' ? ArrayBuffer : SharedArrayBuffer; // Deno can't handle SharedArrayBuffer as an FFI argument due to https://github.com/denoland/deno/issues/12678
const ByteArray = typeof Buffer != 'undefined' ? Buffer.from : Uint8Array;
const ByteArray = typeof Buffer != 'undefined' ? Buffer : Uint8Array; // TODO: Once Buffer.from is fixed in bun, use that
const queueTask = typeof setImmediate != 'undefined' ? setImmediate : setTimeout; // TODO: Or queueMicrotask?
//let debugLog = []
const WRITE_BUFFER_SIZE = 0x10000;
Expand Down

0 comments on commit 32a15e4

Please sign in to comment.