[DOCS] Document web_register_native_module_id_overrides for web native modules

オープン 初心者向け
#225 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
documentation

調査の方向性

まず docs/docs/core-module.md の web_deps セクションを確認し、次に GenerateWebNativeModulePackageFilesProcessor.swift と既存の coreutils 宣言を調べて、属性のマッピングの意味を確認してください。生成される Web 実装のパス、コンパイル済み Valdi モジュール ID、カンマ区切りのマッピング、担当に関するガイダンス、ts_project と valdi_module を含む完全な例を文書化してください。ガイドで生成されたパッケージブリッジを説明し、Web 開発ドキュメントからリンクしたら完了です。可能であれば、トラブルシューティング項目の追加も提案します。

索引モデルが 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.swift
  • web_register_native_module_id_overrides in valdi_module
  • Existing modules such as coreutils

Suggested changes:

  1. Add web_register_native_module_id_overrides immediately after web_deps in docs/docs/core-module.md.

  2. 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.
  3. Include a complete ts_project plus valdi_module example.

  4. Explain that Valdi generates a package bridge similar to:

    // AUTO-GENERATED by Valdi. Do not edit.
    module.exports = require('../../../native/example/web/ExampleNative.js');
    
  5. 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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Snapchat/Valdi のほかの issue

Snapchat/Valdi の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。