Skip to content

Commit

Permalink
remove old swc code, no js minification for now
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Jul 9, 2024
1 parent c11a938 commit 59f8eae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ pulldown-cmark = { version = "0.9.2", git = "https://github.com/SergioBenitez/pu
emojis = "0.5.2"
cached = "0.42.0"
serde_yaml = "0.9.17"
# swc = "0.273.23"
# swc_common = "0.34.4"
anyhow = "1.0.68"
minify-html = "0.15.0"
lightningcss = "1.0.0-alpha.57"
Expand Down
41 changes: 3 additions & 38 deletions src/html/process.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use lightningcss::stylesheet::{ParserOptions, PrinterOptions};
// use swc::{try_with_handler, HandlerOpts, config::{JsMinifyOptions, Options}, BoolOrDataConfig};
// use swc_common::{SourceMap, GLOBALS, FileName};

pub fn minify_html(input: String) -> Result<String, String> {
String::from_utf8(minify_html::minify(
Expand All @@ -13,42 +11,9 @@ pub fn minify_html(input: String) -> Result<String, String> {
}

pub fn minify_js(input: String) -> Result<String, String> {
// minify
return Ok(input);
// let cm = Arc::<SourceMap>::default();
// let c = swc::Compiler::new(cm.clone());

// GLOBALS.set(&Default::default(), || {
// try_with_handler(
// cm.clone(),
// HandlerOpts {
// ..Default::default()
// },
// |handler| {
// let mut fm = cm.new_source_file(FileName::Anon, input);
// let output = c.process_js_file(
// fm.clone(),
// handler,
// &Options {
// ..Default::default()
// }
// )?;
// // idk if there's a better way to do this lol
// fm = cm.new_source_file(FileName::Anon, output.code);
// c.minify(
// fm,
// handler,
// &JsMinifyOptions {
// compress: BoolOrDataConfig::from_bool(true),
// mangle: BoolOrDataConfig::from_bool(true),
// ..Default::default()
// },
// )
// }
// )
// })
// .map(|o| o.code)
// .map_err(|e| format!("{e}"))
// TODO: implement this
// swc is a stupidly big dependency, and minify_js fails with an assertion
Ok(input)
}

pub fn minify_css(input: String) -> Result<String, String> {
Expand Down

0 comments on commit 59f8eae

Please sign in to comment.