From 864bdefbe0012ddbe93075c70f0b2b44577a5424 Mon Sep 17 00:00:00 2001 From: Rene B Date: Fri, 28 Jul 2023 07:57:31 +0200 Subject: [PATCH] refactor(es/parser): Make `stacker` an optional dependency (#7720) --- crates/swc_ecma_parser/Cargo.toml | 4 ++-- crates/swc_ecma_parser/src/lib.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/swc_ecma_parser/Cargo.toml b/crates/swc_ecma_parser/Cargo.toml index e3123cc3ce33..7828b47c7938 100644 --- a/crates/swc_ecma_parser/Cargo.toml +++ b/crates/swc_ecma_parser/Cargo.toml @@ -19,7 +19,7 @@ bench = false [features] # Used for debugging debug = [] -default = ["typescript"] +default = ["typescript", "stacker"] typescript = [] verify = ["swc_ecma_visit"] @@ -39,7 +39,7 @@ swc_ecma_ast = { version = "0.107.2", path = "../swc_ecma_ast" } swc_ecma_visit = { version = "0.93.2", path = "../swc_ecma_visit", optional = true } [target.'cfg(not(any(target_arch = "wasm32", target_arch = "arm")))'.dependencies] -stacker = "0.1.15" +stacker = { version = "0.1.15", optional = true } [dev-dependencies] criterion = "0.5" diff --git a/crates/swc_ecma_parser/src/lib.rs b/crates/swc_ecma_parser/src/lib.rs index e6be163368a9..fe50ea65dc64 100644 --- a/crates/swc_ecma_parser/src/lib.rs +++ b/crates/swc_ecma_parser/src/lib.rs @@ -490,13 +490,16 @@ expose!(parse_file_as_script, Script, |p| { p.parse_script() }); expose!(parse_file_as_program, Program, |p| { p.parse_program() }); #[inline(always)] -#[cfg(any(target_arch = "wasm32", target_arch = "arm"))] +#[cfg(any(target_arch = "wasm32", target_arch = "arm", not(feature = "stacker")))] fn maybe_grow R>(_red_zone: usize, _stack_size: usize, callback: F) -> R { callback() } #[inline(always)] -#[cfg(not(any(target_arch = "wasm32", target_arch = "arm")))] +#[cfg(all( + not(any(target_arch = "wasm32", target_arch = "arm")), + feature = "stacker" +))] fn maybe_grow R>(red_zone: usize, stack_size: usize, callback: F) -> R { stacker::maybe_grow(red_zone, stack_size, callback) }