use crate::err::ProcessingResult; use crate::proc::MatchAction::*; use crate::proc::MatchMode::*; use crate::proc::Processor; #[cfg(feature = "js-esbuild")] use crate::proc::JsMinSection; use crate::cfg::Cfg; #[cfg(feature = "js-esbuild")] use crate::proc::checkpoint::Checkpoint; #[cfg(feature = "js-esbuild")] use esbuild_rs::{TransformOptionsBuilder, TransformOptions}; #[cfg(feature = "js-esbuild")] use std::sync::Arc; #[cfg(feature = "js-esbuild")] use lazy_static::lazy_static; #[cfg(feature = "js-esbuild")] lazy_static! { static ref TRANSFORM_OPTIONS: Arc = { let mut builder = TransformOptionsBuilder::new(); builder.minify_identifiers = true; builder.minify_syntax = true; builder.minify_whitespace = true; builder.build() }; } pub fn process_script(proc: &mut Processor, cfg: &Cfg) -> ProcessingResult<()> { #[cfg(feature = "js-esbuild")] let start = Checkpoint::new(proc); loop { proc.require_not_at_end()?; // Use fast memchr. Unfortunately all characters in "" are common in JS code. proc.m(WhileNotChar(b'<'), Keep); // `process_tag` will require closing tag. if proc.m(IsSeq(b"