Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added trailing slash to Buffer import in index.ts (#898)
* Added trailing slash to Buffer import in index.ts As recommended by the [Buffer maintainer](https://github.com/feross/buffer?tab=readme-ov-file#usage): >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! This solves a bug found bundling NSFWJS with Bun. ``` Build failed 1 | import { Buffer } from 'buffer'; ^ error: No matching export in "node:buffer" for import "Buffer" at [path] ``` More information: oven-sh/bun#8683 * Add note about Bun issue --------- Co-authored-by: Jamon Holmgren <[email protected]>
- Loading branch information
93667b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is that pnpm (and I believe yarn) treat the trailing slash as a directory.
Cannot find module 'node_modules/nsfwjs/dist/esm/buffer/index.jsx' imported from node_modules/nsfwjs/dist/esm/index.js
I think what you'll want to do is specify which
Buffer
to use in package.json so that bundlers explicitly pick up the correct one instead of a syntax hack that might work for Bun but breaks others.