File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
packages/host/src/node/babel-plugin Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,14 @@ import path from "node:path";
44import type { PluginObj , NodePath } from "@babel/core" ;
55import * as t from "@babel/types" ;
66
7- import { getLibraryName , isNodeApiModule , NamingStrategy } from "../path-utils" ;
7+ import {
8+ getLibraryName ,
9+ isNodeApiModule ,
10+ findNodeAddonForBindings ,
11+ NamingStrategy ,
12+ } from "../path-utils" ;
813
9- type PluginOptions = {
14+ export type PluginOptions = {
1015 stripPathSuffix ?: boolean ;
1116} ;
1217
@@ -64,10 +69,9 @@ export function plugin(): PluginObj {
6469 const [ argument ] = p . parent . arguments ;
6570 if ( argument . type === "StringLiteral" ) {
6671 const id = argument . value ;
67- const relativePath = path . join ( from , id ) ;
68- // TODO: Support traversing the filesystem to find the Node-API module
69- if ( isNodeApiModule ( relativePath ) ) {
70- replaceWithRequireNodeAddon ( p . parentPath , relativePath , {
72+ const resolvedPath = findNodeAddonForBindings ( id , from ) ;
73+ if ( typeof resolvedPath === "string" ) {
74+ replaceWithRequireNodeAddon ( p . parentPath , resolvedPath , {
7175 stripPathSuffix,
7276 } ) ;
7377 }
You can’t perform that action at this time.
0 commit comments