Generated entry JS file for AOT thinks I'm not using AOT
@jasongin ci sta già lavorando.
Dal 14/3/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
I'm building an AOT module with the following .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<PublishNodeModule>true</PublishNodeModule>
<PublishDir>bin</PublishDir>
<PackNpmPackage>true</PackNpmPackage>
<PackageOutputPath>pkg</PackageOutputPath>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.9.5" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.5" />
</ItemGroup>
</Project>
After dotnet publish, I get a valid AOT .dll file with the following .js entry file generated:
// Generated for: NativeModule 1.0.0.0
// Generated by: Microsoft.JavaScript.NodeApi.Generator 0.9.0.0
/* eslint-disable */
const dotnet = require('node-api-dotnet/net8.0');
const path = require('node:path');
// @ts-ignore - https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65252
const { dlopen, platform, arch } = require('node:process');
const moduleName = path.basename(__filename, __filename.match(/(\.[cm]?js)?$/)[0]);
module.exports = dotnet ? importDotnetModule(moduleName) : importAotModule(moduleName);
function importDotnetModule(moduleName) {
[...]
}
function importAotModule(moduleName) {
[...]
}
Note the module.exports = dotnet ? importDotnetModule(moduleName) : importAotModule(moduleName); line which is the culprit here - because I'm using AOT, it's supposed to call importAotModule rather than importDotnetModule. However, I'm not sure how this is supposed to work:
- If I have
node-api-dotnetin my dependencies,require('node-api-dotnet/net8.0')works, i.e. it returns a truthy value, soimportDotnetModulegets called (which fails) - If I don't have
node-api-dotnetin my dependencies (as in the example), the require throws and I can't import the module
I feel I'm missing something here, how am I supposed to "tell" the generator or runtime I'm using AOT?
- Lingua principale
- C#
- Stelle
- 783
- Fork
- 80
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/node-api-dotnet
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
microsoft/node-api-dotnet#484 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
microsoft/node-api-dotnet#481 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
microsoft/node-api-dotnet#486 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
microsoft/node-api-dotnet#483 · 1 commento · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
microsoft/node-api-dotnet#479 ·
Tutte le issue di microsoft/node-api-dotnet
Issue simili
-
0 - Backlog Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
BrighterCommand/Brighter#4444 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
area:frontend bug FE P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
klasolsson81/jobbliggaren#1915 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
microsoft/vscode-copilotstudio#431 ·
I maintainer di solito rispondono entro 2 giorni