node-api-dotnet 0.7.13 → 0.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/init.js CHANGED
@@ -41,11 +41,35 @@ function initialize(targetFramework) {
41
41
  targetFramework = defaultTargetFramework;
42
42
  }
43
43
 
44
+ /**
45
+ * Build tools like webpack are not able to package up dynamic includes like the default case.
46
+ * The switch supports the currently packaged DLLs to work with build tools while maintaining
47
+ * potential backwards and future compatibility utilizing the default case.
48
+ */
44
49
  const assemblyName = 'Microsoft.JavaScript.NodeApi';
45
- const nativeHostPath = __dirname + `/${rid}/${assemblyName}.node`;
46
- const managedHostPath = __dirname + `/${targetFramework}/${assemblyName}.DotNetHost.dll`
50
+ let nativeHost;
51
+ switch(rid) {
52
+ case 'win-x64':
53
+ nativeHost = require(`./win-x64/${assemblyName}.node`);
54
+ break;
55
+ case 'win-arm64':
56
+ nativeHost = require(`./win-arm64/${assemblyName}.node`);
57
+ break;
58
+ case 'osx-x64':
59
+ nativeHost = require(`./osx-x64/${assemblyName}.node`);
60
+ break;
61
+ case 'osx-arm64':
62
+ nativeHost = require(`./osx-arm64/${assemblyName}.node`);
63
+ break;
64
+ case 'linux-x64':
65
+ nativeHost = require(`./linux-x64/${assemblyName}.node`);
66
+ break;
67
+ default:
68
+ // Handle unknown platform (Likely will not work with build tools e.g. webpack)
69
+ nativeHost = require(__dirname + `/${rid}/${assemblyName}.node`);
70
+ }
47
71
 
48
- const nativeHost = require(nativeHostPath);
72
+ const managedHostPath = __dirname + `/${targetFramework}/${assemblyName}.DotNetHost.dll`
49
73
 
50
74
  // Pass require() and import() functions to the host initialize() method.
51
75
  // Since `import` is a keyword and not a function it has to be wrapped in a function value.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-api-dotnet",
3
- "version": "0.7.13",
3
+ "version": "0.7.16",
4
4
  "description": "Node-API bindings for .Net",
5
5
  "license": "MIT",
6
6
  "author": "Microsoft",