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

utf-8-validate doesn't work with bun install due to not running postinstall script #3497

Closed
pdenapo opened this issue Jul 2, 2023 · 2 comments · Fixed by #3516
Closed

utf-8-validate doesn't work with bun install due to not running postinstall script #3497

pdenapo opened this issue Jul 2, 2023 · 2 comments · Fixed by #3516
Labels
bug Something isn't working

Comments

@pdenapo
Copy link

pdenapo commented Jul 2, 2023

What version of Bun is running?

0.6.12

What platform is your computer?

Linux 5.15.0-76-generic x86_64 x86_64

What steps can reproduce the bug?

I have found this issue while trying to use the package

https://www.npmjs.com/package/utf-8-validate

After installing the package (with bun install utf-8-validate), just copy the example code there
in a file validate.js

'use strict';

const isValidUTF8 = require('utf-8-validate');

const buf = Buffer.from([0xf0, 0x90, 0x80, 0x80]);

console.log(isValidUTF8(buf));
// => true

and run it with bun validate.js

What is the expected behavior?

Under node (tested with version16.20-1) it prints "true" as documented in that page.

What do you see instead?

7 | console.log(isValidUTF8(buf));
^
TypeError: isValidUTF8 is not a function. (In 'isValidUTF8(buf)', 'isValidUTF8' is an instance of Object)

Additional information

Adding a console.log(isValidUTF8)
shows it is an anonymous function

[Function (anonymous)]

@pdenapo pdenapo added the bug Something isn't working label Jul 2, 2023
@Jarred-Sumner
Copy link
Collaborator

This is due to #3288. This package depends on a native module and we aren't running postinstall for that right now

@Jarred-Sumner Jarred-Sumner changed the title node modules exporting a single anonymous function does not work in bun utf-8-validate package doesn't work with bun install due to not running postinstall script Jul 2, 2023
@Jarred-Sumner Jarred-Sumner changed the title utf-8-validate package doesn't work with bun install due to not running postinstall script utf-8-validate doesn't work with bun install due to not running postinstall script Jul 2, 2023
@Jarred-Sumner
Copy link
Collaborator

After #3498 lands, you can use this to validate utf8:

import {isUtf8} from 'node:buffer'

Electroid added a commit that referenced this issue Jul 4, 2023
@Electroid Electroid linked a pull request Jul 4, 2023 that will close this issue
Electroid added a commit that referenced this issue Jul 10, 2023
paperclover added a commit that referenced this issue Aug 3, 2023
paperclover pushed a commit that referenced this issue Aug 3, 2023
Jarred-Sumner added a commit that referenced this issue Aug 3, 2023
* Fix #3497

* Fix #3497

* Run prettier

* Fix package.json

* remove this too

* yeah

* Fix missing tests

* Use native for utf-8-validate

* Add module ID names to builtins

* Defer evaluation of ESM & CJS modules until link time

* Use builtin name for exports in plugins

* Add module IDs to builtins

* Update JSC build with new flag

* WebKit upgrade fixes

* Update WebKit

* prettier

* Upgrade WebKit

* bump

* Update once again

* Add visitAdditionalChildren, remove .fill() usage

* Update process.test.js

* Update fs.test.ts

---------

Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
trnxdev pushed a commit to trnxdev/bun that referenced this issue Aug 9, 2023
* Fix oven-sh#3497

* Fix oven-sh#3497

* Run prettier

* Fix package.json

* remove this too

* yeah

* Fix missing tests

* Use native for utf-8-validate

* Add module ID names to builtins

* Defer evaluation of ESM & CJS modules until link time

* Use builtin name for exports in plugins

* Add module IDs to builtins

* Update JSC build with new flag

* WebKit upgrade fixes

* Update WebKit

* prettier

* Upgrade WebKit

* bump

* Update once again

* Add visitAdditionalChildren, remove .fill() usage

* Update process.test.js

* Update fs.test.ts

---------

Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants