Fix crates export

This commit is contained in:
Folyd 2024-05-26 16:09:45 -07:00
parent 8b07c6b695
commit 88b9fd197a
2 changed files with 3 additions and 2 deletions

View file

@ -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);

View file

@ -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!");