From 51cfdabeacc13dba0ebc50e75d76b7b556c0ca47 Mon Sep 17 00:00:00 2001 From: FG Logan Date: Sat, 10 Oct 2026 11:45:49 -0400 Subject: [PATCH] Do not brief a default export as module::default The brief maps every export to `::`, so a default export became `app::plugin::default`, an item no Rust module can hold, while `done` already skips default exports. The brief now says a default export has no Rust item of its own and names the two `--map` forms `done` accepts. Adds an end-to-end test. --- src/brief.rs | 13 ++++++++----- tests/porting_workflow.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/brief.rs b/src/brief.rs index 392f7ef..0925c00 100644 --- a/src/brief.rs +++ b/src/brief.rs @@ -97,11 +97,14 @@ pub fn render( _ => snake(&e.name), }; let asyncness = if e.is_async { " (async)" } else { "" }; - let _ = writeln!( - out, - "- `{}` {}{asyncness} → `{module}::{rust_name}`", - e.name, e.kind - ); + // `done` skips default exports, so name what it accepts + // instead of an item no Rust module can hold. + let target = if e.kind == "default" { + "no Rust item of its own; name the one that replaces it with `--map default=`, or `--map default=-`".to_owned() + } else { + format!("`{module}::{rust_name}`") + }; + let _ = writeln!(out, "- `{}` {}{asyncness} → {target}", e.name, e.kind); } } diff --git a/tests/porting_workflow.rs b/tests/porting_workflow.rs index 2f92728..79cc13c 100644 --- a/tests/porting_workflow.rs +++ b/tests/porting_workflow.rs @@ -1893,3 +1893,30 @@ args = ["signal"] text(&out) ); } + +#[test] +fn a_default_export_is_briefed_without_an_invented_rust_item() { + let f = fixture(); + let plugin = "src/ts/app/src/plugin.ts"; + f.write( + plugin, + "export const PLUGIN_ID = \"x\";\nexport default { id: PLUGIN_ID };\n", + ); + + let brief = text(&f.port(&["brief", plugin])); + + // The named export maps to a Rust item; the default export names the + // --map forms `done` accepts instead of `app::plugin::default`. + let exports: Vec<&str> = brief + .lines() + .filter(|line| line.starts_with("- `PLUGIN_ID`") || line.starts_with("- `default`")) + .collect(); + assert_eq!( + exports, + [ + "- `PLUGIN_ID` const → `app::plugin::PLUGIN_ID`", + "- `default` default → no Rust item of its own; name the one that replaces it with `--map default=`, or `--map default=-`", + ], + "{brief}" + ); +}