Skip to content

Conversation

@mani3xis
Copy link
Contributor

@mani3xis mani3xis commented Jul 4, 2025

As requested on Discord, here is the cherry picked findNodeAddonForBindings() function (with tests).
It requires an additional change in isNodeApiModule() function, which was cherry-picked as well.

Mariusz Pasinski added 3 commits July 4, 2025 16:41
This small change relaxes the condition for taking the shortcut, as CommonJS modules (in contrast to ESM) do not require developers to explicitly include the file extensions. The Node.js module resolution algorithm (https://nodejs.org/api/modules.html#all-together) in step 4 of LOAD_AS_FILE(X) would try appending the `.node` extension.

In theory, we should make sure that other extensions checked in previous steps are not present, but given that we are implementing it for `requireNodeAddon()`, it should be safe to skip those.

# Conflicts:
#	packages/host/src/node/path-utils.ts
@mani3xis mani3xis self-assigned this Jul 4, 2025
@changeset-bot
Copy link

changeset-bot bot commented Jul 4, 2025

⚠️ No Changeset found

Latest commit: 83d2525

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mani3xis mani3xis requested a review from kraenhansen July 4, 2025 15:17
@mani3xis mani3xis merged commit dce454d into main Jul 4, 2025
6 checks passed
@mani3xis mani3xis deleted the mario/find-node-addons-for-bindings branch July 4, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants