fix(next-swc): Do not reuse compiler instance (#65602)
### What? Do not reuse `Compiler` instance. ### Why? It exists only to support preserving comments from `print()` API for modules created with `parse()` API, but it causes a problem for `transform()` for very huge apps. ### How? - Closes https://github.com/swc-project/swc/issues/8932 - Fixes #48960 - Fixes #65436
This commit is contained in:
parent
9296434815
commit
fedb675520
1 changed files with 4 additions and 8 deletions
|
@ -44,7 +44,7 @@ use fxhash::FxHashSet;
|
|||
use napi::bindgen_prelude::*;
|
||||
use turbopack_binding::swc::core::{
|
||||
base::{Compiler, TransformOutput},
|
||||
common::{sync::Lazy, FilePathMapping, SourceMap},
|
||||
common::{FilePathMapping, SourceMap},
|
||||
};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
@ -82,12 +82,6 @@ static ALLOC: turbopack_binding::turbo::malloc::TurboMalloc =
|
|||
#[global_allocator]
|
||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||
|
||||
static COMPILER: Lazy<Arc<Compiler>> = Lazy::new(|| {
|
||||
let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
|
||||
Arc::new(Compiler::new(cm))
|
||||
});
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[napi::module_init]
|
||||
fn init() {
|
||||
|
@ -101,7 +95,9 @@ fn init() {
|
|||
|
||||
#[inline]
|
||||
fn get_compiler() -> Arc<Compiler> {
|
||||
COMPILER.clone()
|
||||
let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
|
||||
Arc::new(Compiler::new(cm))
|
||||
}
|
||||
|
||||
pub fn complete_output(
|
||||
|
|
Loading…
Reference in a new issue