@@ -272,18 +272,35 @@ impl PublishArgs {
272272 [ path] => path,
273273 paths => {
274274 let ( overlay, tmp_dir) = wasm_pkg_client:: local:: LocalBackend :: temp_dir ( ) ?;
275+ let local_backend = wasm_pkg_client:: local:: LocalConfig {
276+ root : tmp_dir. path ( ) . to_path_buf ( ) ,
277+ } ;
278+ let mut reg_config = RegistryConfig :: default ( ) ;
279+ reg_config. set_default_backend ( Some ( "local" . to_owned ( ) ) ) ;
280+ reg_config. set_backend_config ( "local" , & local_backend) ?;
281+
275282 let plan = PublishPlan :: from_paths ( paths) ?;
276283 let mut lock_file = LockFile :: load ( true ) . await ?;
277- for spec in plan. iter_edges ( ) {
278- let mut reg_config = RegistryConfig :: default ( ) ;
279- reg_config. set_default_backend ( Some ( "local" . to_owned ( ) ) ) ;
280- reg_config. set_backend_config (
281- "local" ,
282- wasm_pkg_client:: local:: LocalConfig {
283- root : tmp_dir. path ( ) . to_path_buf ( ) ,
284- } ,
284+
285+ // Route every package in the plan to the local overlay registry
286+ // backed by `reg_config`, so the client used in `build_wit_dir`
287+ // resolves these packages against the local overlay instead of
288+ // an upstream remote.
289+ let mut config = self . common . load_config ( ) . await ?;
290+ let local_registry: Registry = "local" . parse ( ) ?;
291+ config
292+ . get_or_insert_registry_config_mut ( & local_registry)
293+ . merge ( reg_config) ;
294+ for spec in plan. iter ( ) {
295+ config. set_package_registry_override (
296+ spec. package . clone ( ) ,
297+ RegistryMapping :: Registry ( local_registry. clone ( ) ) ,
285298 ) ;
286- let client = client. client . as_mut ( ) . unwrap ( ) ;
299+ }
300+ let cache = self . common . load_cache ( ) . await ?;
301+ let client = CachingClient :: new ( Some ( Client :: new ( config) ) , cache) ;
302+
303+ for spec in plan. iter_edges ( ) {
287304 let path = plan. get_path ( & spec. package ) . unwrap ( ) ;
288305 let ( publish_path, _tmp) = if path. is_dir ( ) {
289306 let _prev_lock_ref = ( lock_file. version , lock_file. packages . clone ( ) ) ;
0 commit comments