Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use import { Buffer } from 'buffer/' to be compatible with Bun #486

Merged
merged 2 commits into from
Oct 20, 2024

Conversation

lht102
Copy link
Contributor

@lht102 lht102 commented Oct 19, 2024

currently, the node-casbin is not compatible with Bun when running bun build

$ bun build src/index.ts --outdir ./build
28 | import { Buffer } from 'buffer';
              ^
error: No matching export in "node:buffer" for import "Buffer"
    at /.../node_modules/casbin/lib/esm/util/ip.js:28:10
error: script "build" exited with code 1

there is a open issue about buffer import with Bun: oven-sh/bun#8683

according to feross/buffer docs

To require this module explicitly, use require('buffer/') which tells the node.js module lookup algorithm (also used by browserify) to use the npm module named buffer instead of the node.js core module named buffer!

by adding trailing slash, this will use the feross/buffer module explicitly which works with Bun.

@casbin-bot
Copy link
Member

@nodece @Shivansh-yadav13 please review

@CLAassistant
Copy link

CLAassistant commented Oct 19, 2024

CLA assistant check
All committers have signed the CLA.

@hsluoyz
Copy link
Member

hsluoyz commented Oct 19, 2024

@lht102 fix CI:

image

@hsluoyz hsluoyz changed the title fix: import buffer module with trailing slash feat: use import { Buffer } from 'buffer/' to be compatible with Bun Oct 20, 2024
@hsluoyz hsluoyz merged commit 738b2b6 into casbin:master Oct 20, 2024
10 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 20, 2024
# [5.32.0](v5.31.0...v5.32.0) (2024-10-20)

### Features

* use `import { Buffer } from 'buffer/'` to be compatible with Bun ([#486](#486)) ([738b2b6](738b2b6))
Copy link

🎉 This PR is included in version 5.32.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants