[DOCS] Document web_register_native_module_id_overrides for web native modules
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 docs/docs/core-module.md 中的 web_deps 部分开始,然后检查 GenerateWebNativeModulePackageFilesProcessor.swift 和现有的 coreutils 声明,以确认该属性的映射语义。记录生成的 Web 实现路径、编译后的 Valdi 模块 ID、逗号分隔的映射、归属指导,以及包含 ts_project 和 valdi_module 的完整示例。完成标准是指南解释生成的 package 桥接,并从 Web 开发文档链接到该指南;如果可行,建议添加 troubleshooting 条目。
由索引模型根据 Issue 内容生成。
描述
What documentation needs improvement?
The valdi_module documentation in docs/docs/core-module.md, particularly the section covering web_deps.
The web-development documentation should also link to this information when describing browser-specific implementations.
What's unclear or missing?
web_deps is documented, but web_register_native_module_id_overrides is not.
When a Valdi module declares a native TypeScript API such as:
import { doSomething } from './ExampleNative';
and provides its browser implementation through a ts_project in web_deps, adding the web dependency alone does not make the compiled source import resolve.
The module must also declare the mapping:
valdi_module(
name = "example",
# ...
web_deps = [":example_web"],
web_register_native_module_id_overrides = {
"example/web/ExampleNative.js": "example/src/ExampleNative",
},
)
Without this mapping, the browser implementation may be included under native/, but no package file is generated at the module ID imported by the compiled Valdi source. Consumers then receive a generic bundler error such as:
Module not found: Can't resolve './ExampleNative.js'
This makes the problem look like a webpack or package-collapse bug, even though Valdi already has a supported mechanism for it.
The behavior is implemented by:
GenerateWebNativeModulePackageFilesProcessor.swiftweb_register_native_module_id_overridesinvaldi_module- Existing modules such as
coreutils
Suggested changes:
-
Add
web_register_native_module_id_overridesimmediately afterweb_depsindocs/docs/core-module.md. -
Document that:
- The key is the emitted web implementation path supplied by
web_deps. - The value is the compiled Valdi module ID that imports the native API.
- Multiple module IDs may be supplied as a comma-separated string.
- The mapping should be declared by the module that owns the web implementation, not by each consuming application.
- The key is the emitted web implementation path supplied by
-
Include a complete
ts_projectplusvaldi_moduleexample. -
Explain that Valdi generates a package bridge similar to:
// AUTO-GENERATED by Valdi. Do not edit. module.exports = require('../../../native/example/web/ExampleNative.js'); -
If feasible, add a compiler diagnostic—or at least a troubleshooting entry—for modules that provide a web-native implementation but omit the mapping.
Additional context:
The intended feature already works correctly once the override is declared. The issue is discoverability: the public documentation currently describes web_deps without explaining the companion attribute required for native-module imports.
- 主要语言
- C++
- 星标
- 16.4k
- 派生
- 539
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Snapchat/Valdi 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
相似的 Issue
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialog可能已有人在做 @dpc00 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
throneproj/Throne#2227 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
维护者通常 1 天内回复