Skip to content

Commit

Permalink
Less dynamic runtime includes to better support build tools like Webp…
Browse files Browse the repository at this point in the history
…ack. FIxes microsoft#300
  • Loading branch information
sbowler committed Jun 6, 2024
1 parent 25b5030 commit 7ad685f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/node-api-dotnet/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,28 @@ function initialize(targetFramework) {
}

const assemblyName = 'Microsoft.JavaScript.NodeApi';
const nativeHostPath = __dirname + `/${rid}/${assemblyName}.node`;
const managedHostPath = __dirname + `/${targetFramework}/${assemblyName}.DotNetHost.dll`
let nativeHost;
switch(rid) {
case 'win-x64':
nativeHost = require(`./win-x64/${assemblyName}.node`);
break;
case 'win-arm64':
nativeHost = require(`./win-arm64/${assemblyName}.node`);
break;
case 'osx-x64':
nativeHost = require(`./osx-x64/${assemblyName}.node`);
break;
case 'osx-arm64':
nativeHost = require(`./osx-arm64/${assemblyName}.node`);
break;
case 'linux-x64':
nativeHost = require(`./linux-x64/${assemblyName}.node`);
break;
default:
nativeHost = require(__dirname + `/${rid}/${assemblyName}.node`);
}

const nativeHost = require(nativeHostPath);
const managedHostPath = __dirname + `/${targetFramework}/${assemblyName}.DotNetHost.dll`

// Pass require() and import() functions to the host initialize() method.
// Since `import` is a keyword and not a function it has to be wrapped in a function value.
Expand Down

0 comments on commit 7ad685f

Please sign in to comment.