1414//!
1515//! This avoids any manual ESM→CJS string manipulation — rolldown does it all.
1616
17- use std:: path:: { Path , PathBuf } ;
17+ use std:: path:: Path ;
1818
1919use crate :: error:: { Error , Result } ;
2020
@@ -62,7 +62,7 @@ pub fn bundle(entry: &Path) -> Result<Vec<u8>> {
6262/// Pass 1: ESM bundle → single file with only external imports remaining.
6363/// Wrap: Move `await` into an async IIFE so it's no longer top-level.
6464/// Pass 2: CJS bundle → rolldown converts imports, polyfills import.meta, etc.
65- async fn two_pass_bundle ( entry : & str , cwd : & PathBuf ) -> Result < Vec < u8 > > {
65+ async fn two_pass_bundle ( entry : & str , cwd : & Path ) -> Result < Vec < u8 > > {
6666 // Pass 1: Bundle as ESM (TLA is allowed).
6767 let esm_code = try_bundle ( entry, cwd, rolldown:: OutputFormat :: Esm )
6868 . await
@@ -86,7 +86,7 @@ async fn two_pass_bundle(entry: &str, cwd: &PathBuf) -> Result<Vec<u8>> {
8686 // No TLA error because `await` is now inside a function.
8787 let cjs_code = try_bundle (
8888 "./__nodesea_bundle.mjs" ,
89- & tmp_dir. path ( ) . to_path_buf ( ) ,
89+ tmp_dir. path ( ) ,
9090 rolldown:: OutputFormat :: Cjs ,
9191 )
9292 . await
@@ -187,12 +187,12 @@ fn build_define_map() -> rolldown_utils::indexmap::FxIndexMap<String, String> {
187187/// Run rolldown with the given output format and return the entry chunk code.
188188async fn try_bundle (
189189 entry : & str ,
190- cwd : & PathBuf ,
190+ cwd : & Path ,
191191 format : rolldown:: OutputFormat ,
192192) -> std:: result:: Result < Vec < u8 > , String > {
193193 let mut bundler = rolldown:: Bundler :: new ( rolldown:: BundlerOptions {
194194 input : Some ( vec ! [ entry. to_string( ) . into( ) ] ) ,
195- cwd : Some ( cwd. clone ( ) ) ,
195+ cwd : Some ( cwd. to_path_buf ( ) ) ,
196196 platform : Some ( rolldown:: Platform :: Node ) ,
197197 format : Some ( format) ,
198198 code_splitting : Some ( rolldown_common:: CodeSplittingMode :: Bool ( false ) ) ,
0 commit comments