From 88b9fd197a6ef50eee6741e610cd78660e9da8ac Mon Sep 17 00:00:00 2001 From: Folyd Date: Sun, 26 May 2024 16:09:45 -0700 Subject: [PATCH] Fix crates export --- rust/src/tasks/books.rs | 2 +- rust/src/tasks/crates.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rust/src/tasks/books.rs b/rust/src/tasks/books.rs index bfe0268..5fc591f 100644 --- a/rust/src/tasks/books.rs +++ b/rust/src/tasks/books.rs @@ -155,7 +155,7 @@ impl BooksTask { Ok(result) => { let books: Vec<_> = result.into_iter().filter(|book| !book.is_empty()).collect(); let contents = format!( - "let N=null;const booksIndex={};export default booksIndex;", + "var N=null;const booksIndex={};export default booksIndex;", serde_json::to_string(&books)? ); let path = Path::new(&self.dest_path); diff --git a/rust/src/tasks/crates.rs b/rust/src/tasks/crates.rs index 0a11a62..ca1fc98 100644 --- a/rust/src/tasks/crates.rs +++ b/rust/src/tasks/crates.rs @@ -110,7 +110,7 @@ fn generate_javascript_crates_index(crates: &[Crate], minifier: &Minifier) -> St }) .collect(); let crate_index = format!( - "const crateIndex={};export default crateIndex;", + "const crateIndex={};", serde_json::to_string(&crates_map).unwrap() ); contents.push_str(&Minifier::minify_js(&crate_index)); @@ -179,6 +179,7 @@ impl Task for CratesTask { serde_json::to_string(&mapping)? ); contents.push_str(&generate_javascript_crates_index(&crates, &minifier)); + contents.push_str("export {mapping,crateIndex};"); let path = Path::new(&self.dest_path); fs::write(path, &contents)?; println!("\nGenerate javascript crates index successful!");