mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
fix(es/minifier): Fix infinite loop (#6300)
**Related issue:** - https://github.com/vercel/next.js/issues/42171.
This commit is contained in:
parent
00457b5275
commit
655f6744c5
@ -6,6 +6,8 @@ export UPDATE=1
|
||||
export SWC_CHECK=0
|
||||
export SWC_RUN=0
|
||||
|
||||
touch tests/compress.rs
|
||||
|
||||
cargo test -q -p swc_ecma_minifier -p swc --no-fail-fast --test projects --test tsc --test compress --test mangle --features concurrent $@
|
||||
|
||||
# find ../swc/tests/ -type f -empty -delete
|
@ -38,12 +38,7 @@
|
||||
#![allow(clippy::match_like_matches_macro)]
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use swc_common::{
|
||||
comments::Comments,
|
||||
pass::{Repeat, Repeated},
|
||||
sync::Lrc,
|
||||
SourceMap, SyntaxContext,
|
||||
};
|
||||
use swc_common::{comments::Comments, pass::Repeated, sync::Lrc, SourceMap, SyntaxContext};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms_optimization::debug_assert_valid;
|
||||
use swc_ecma_visit::VisitMutWith;
|
||||
@ -230,17 +225,27 @@ pub fn optimize(
|
||||
let _timer = timer!("postcompress");
|
||||
|
||||
m.visit_mut_with(&mut postcompress_optimizer(options));
|
||||
m.visit_mut_with(&mut Repeat::new(pure_optimizer(
|
||||
options,
|
||||
None,
|
||||
marks,
|
||||
PureOptimizerConfig {
|
||||
force_str_for_tpl: Minification::force_str_for_tpl(),
|
||||
enable_join_vars: true,
|
||||
#[cfg(feature = "debug")]
|
||||
debug_infinite_loop: false,
|
||||
},
|
||||
)));
|
||||
|
||||
let mut pass = 0;
|
||||
loop {
|
||||
pass += 1;
|
||||
|
||||
let mut v = pure_optimizer(
|
||||
options,
|
||||
None,
|
||||
marks,
|
||||
PureOptimizerConfig {
|
||||
force_str_for_tpl: Minification::force_str_for_tpl(),
|
||||
enable_join_vars: true,
|
||||
#[cfg(feature = "debug")]
|
||||
debug_infinite_loop: false,
|
||||
},
|
||||
);
|
||||
m.visit_mut_with(&mut v);
|
||||
if !v.changed() || options.passes <= pass {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref mut _t) = timings {
|
||||
|
@ -440,7 +440,7 @@
|
||||
}
|
||||
}
|
||||
function internalRemoveData(elem, name1, pvt) {
|
||||
if (jQuery.acceptData(elem)) {
|
||||
if (!!jQuery.acceptData(elem)) {
|
||||
var i, l, thisCache, isNode = elem.nodeType, cache = isNode ? jQuery.cache : elem, id = isNode ? elem[jQuery.expando] : jQuery.expando;
|
||||
if (cache[id]) {
|
||||
if (name1 && (thisCache = pvt ? cache[id] : cache[id].data)) {
|
||||
|
Loading…
Reference in New Issue
Block a user