Skip to content

C# AOT compilation not setting "dotnet" to undefined #484

Description

@daniacedue

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions