@@ -2,7 +2,7 @@ use std::{cell::RefCell, ptr::NonNull};
22
33use napi:: { bindgen_prelude:: ToNapiValue , Either , Env , JsString } ;
44use napi_derive:: napi;
5- use rspack_core:: { Compilation , CompilationId , Dependency , DependencyId } ;
5+ use rspack_core:: { Compilation , CompilationId , CompilerId , Dependency , DependencyId } ;
66use rspack_napi:: OneShotInstanceRef ;
77use rspack_plugin_javascript:: dependency:: {
88 CommonJsExportRequireDependency , ESMExportImportedSpecifierDependency ,
@@ -142,14 +142,14 @@ impl JsDependency {
142142
143143type DependencyInstanceRefs = HashMap < DependencyId , OneShotInstanceRef < JsDependency > > ;
144144
145- type DependencyInstanceRefsByCompilationId =
146- RefCell < HashMap < CompilationId , DependencyInstanceRefs > > ;
145+ type DependencyInstanceRefsByCompilerId = RefCell < HashMap < CompilerId , DependencyInstanceRefs > > ;
147146
148147thread_local ! {
149- static DEPENDENCY_INSTANCE_REFS : DependencyInstanceRefsByCompilationId = Default :: default ( ) ;
148+ static DEPENDENCY_INSTANCE_REFS : DependencyInstanceRefsByCompilerId = Default :: default ( ) ;
150149}
151150
152151pub struct JsDependencyWrapper {
152+ compiler_id : CompilerId ,
153153 dependency_id : DependencyId ,
154154 dependency : NonNull < dyn Dependency > ,
155155 compilation_id : CompilationId ,
@@ -159,6 +159,7 @@ pub struct JsDependencyWrapper {
159159impl JsDependencyWrapper {
160160 pub fn new (
161161 dependency : & dyn Dependency ,
162+ compiler_id : CompilerId ,
162163 compilation_id : CompilationId ,
163164 compilation : Option < & Compilation > ,
164165 ) -> Self {
@@ -168,17 +169,18 @@ impl JsDependencyWrapper {
168169 Self {
169170 dependency_id,
170171 dependency : NonNull :: new ( dependency as * const dyn Dependency as * mut dyn Dependency ) . unwrap ( ) ,
172+ compiler_id,
171173 compilation_id,
172174 compilation : compilation
173175 . map ( |c| NonNull :: new ( c as * const Compilation as * mut Compilation ) . unwrap ( ) ) ,
174176 }
175177 }
176178
177179 pub fn cleanup_last_compilation ( compilation_id : CompilationId ) {
178- DEPENDENCY_INSTANCE_REFS . with ( |refs| {
179- let mut refs_by_compilation_id = refs. borrow_mut ( ) ;
180- refs_by_compilation_id. remove ( & compilation_id)
181- } ) ;
180+ // DEPENDENCY_INSTANCE_REFS.with(|refs| {
181+ // let mut refs_by_compilation_id = refs.borrow_mut();
182+ // refs_by_compilation_id.remove(&compilation_id)
183+ // });
182184 }
183185}
184186
@@ -189,7 +191,7 @@ impl ToNapiValue for JsDependencyWrapper {
189191 ) -> napi:: Result < napi:: sys:: napi_value > {
190192 DEPENDENCY_INSTANCE_REFS . with ( |refs| {
191193 let mut refs_by_compilation_id = refs. borrow_mut ( ) ;
192- let entry = refs_by_compilation_id. entry ( val. compilation_id ) ;
194+ let entry = refs_by_compilation_id. entry ( val. compiler_id ) ;
193195 let refs = match entry {
194196 std:: collections:: hash_map:: Entry :: Occupied ( entry) => entry. into_mut ( ) ,
195197 std:: collections:: hash_map:: Entry :: Vacant ( entry) => {
0 commit comments