microsoft / microsoft/node-api-dotnet
C# AOT compilation not setting "dotnet" to undefined
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 783
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
When compiling the module as AOT module then the resulting js module loaders is incorrect because:
import dotnet from 'node-api-dotnet/net10.0';
should have been:
const dotnet = undefined;
Poking around in the source code the problem is in NodeApi.targets which does:
<Task>
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
<![CDATA[
string js = File.ReadAllText(TargetFile);
js = js.Replace("const dotnet = require('node-api-dotnet');", "const dotnet = undefined;");
js = js.Replace("import dotnet from 'node-api-dotnet';", "const dotnet = undefined;");
if (!IncludeRidSubpath) js = js.Replace("rid, ", "");
File.WriteAllText(TargetFile, js);
]]>
</Code>
</Task>
but it should now replace "node-api-dotnet/netX.X" instead of just "node-api-dotnet"
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in NodeApi.targets and inspect the inline task that rewrites the generated JavaScript loader. Reproduce an AOT compilation and check the resulting loader for the netX.X import form shown in the issue. Done means the AOT output uses const dotnet = undefined; instead of importing node-api-dotnet/netX.X.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100