Generated entry JS file for AOT thinks I'm not using AOT
@jasongin 已经在做这个了。
开始于 2025年3月14日。
评估
这个 Issue 还没有评估数据。
描述
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?
- 主要语言
- C#
- 星标
- 783
- 派生
- 80
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/node-api-dotnet 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
microsoft/node-api-dotnet#484 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/node-api-dotnet#481 ·
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/node-api-dotnet#486 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/node-api-dotnet#483 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
microsoft/node-api-dotnet#479 ·
查看 microsoft/node-api-dotnet 的全部 Issue
相似的 Issue
-
area-ai untriaged
难度 2/5 1-3 小时 新手友好度 85/100
dotnet/extensions#7790 ·
维护者通常 1 天内回复
-
P2 testing
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
area-Infrastructure-coreclr os-ios os-maccatalyst os-tvos untriaged
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/runtime#134766 · 3 条评论 ·
维护者通常 1 天内回复
-
0 - Backlog Bug
难度 2/5 1-3 小时 新手友好度 88/100
BrighterCommand/Brighter#4444 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复