detect-libc icon indicating copy to clipboard operation
detect-libc copied to clipboard

Node.JS workers compatibility

Open AmeerArsala opened this issue 1 year ago • 10 comments

Here's the updated PR! This one fully has the changes you want!!

AmeerArsala avatar Aug 25 '24 19:08 AmeerArsala

Hi, thanks for the PR, did you see https://github.com/lovell/detect-libc/issues/25 and the need to use some form of safe-require-with-fallback approach?

lovell avatar Aug 26 '24 07:08 lovell

There! I did it. I tried opening a new PR but it took me here. added safeRequire with fallbacks.

AmeerArsala avatar Aug 27 '24 23:08 AmeerArsala

Thanks for the updates, as I mentioned in #25 I think the safeRequire function should return null when all options are exhausted (rather than throw), and consumers need to guard against this. Are you able to update the logic to match this behaviour?

Please can you also remove the formatting changes to ensure semistandard will pass, as well as keeping the diff cleaner.

lovell avatar Aug 28 '24 11:08 lovell

Done! My bad, I didn't realize my editor automatically made the formatting changes. It returns null now

AmeerArsala avatar Aug 28 '24 19:08 AmeerArsala

Any update on this?

AmeerArsala avatar Sep 04 '24 01:09 AmeerArsala

Given that safeRequire() can return null, consumers need to guard against this, e.g. childProcess might be null. Are you able to update the logic to match this behaviour?

lovell avatar Sep 04 '24 06:09 lovell

Alright, updated! Sorry for the long wait, I just saw this

AmeerArsala avatar Sep 27 '24 20:09 AmeerArsala

Ok so from my inspection I saw that the for loop I made was the issue. I changed it from being a foreach loop to just a regular for loop in case some versions of Node don't play nice with it in this context.

AmeerArsala avatar Sep 28 '24 14:09 AmeerArsala

@lovell Any plans to merge this? Or would you be open to another PR with a different approach? I'm facing similar issues in using Bun build with the browser as target.

eigilsagafos avatar Sep 25 '25 14:09 eigilsagafos

@eigilsagafos Please can you open a new issue about this with steps to reproduce as there may be alternatives that could help.

lovell avatar Sep 25 '25 15:09 lovell