File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
crates/rspack_plugin_rstest/src Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -183,14 +183,9 @@ impl RstestParserPlugin {
183183
184184 fn calc_mocked_target ( & self , value : & str ) -> Utf8PathBuf {
185185 // node:foo will be mocked to `__mocks__/foo`.
186- let path_buf = Utf8PathBuf :: from (
187- value
188- . to_string ( )
189- . strip_prefix ( "node:" )
190- . unwrap_or ( value. as_ref ( ) )
191- . to_string ( ) ,
192- ) ;
193- let is_relative_request = path_buf. to_string ( ) . starts_with ( "." ) ; // TODO: consider alias?
186+ let stripped = value. strip_prefix ( "node:" ) . unwrap_or ( value) ;
187+ let path_buf = Utf8PathBuf :: from ( stripped) ;
188+ let is_relative_request = stripped. starts_with ( '.' ) ; // TODO: consider alias?
194189
195190 if is_relative_request {
196191 // Mock relative request to alongside `__mocks__` directory.
Original file line number Diff line number Diff line change @@ -163,13 +163,14 @@ struct MockFlagPos {
163163
164164#[ plugin_hook( CompilationProcessAssets for RstestPlugin , stage = Compilation :: PROCESS_ASSETS_STAGE_ADDITIONAL ) ]
165165async fn mock_hoist_process_assets ( & self , compilation : & mut Compilation ) -> Result < ( ) > {
166- let mut files = vec ! [ ] ;
166+ let mut files = Vec :: with_capacity ( compilation . chunk_by_ukey . len ( ) ) ;
167167
168168 for chunk in compilation. chunk_by_ukey . values ( ) {
169169 for file in chunk. files ( ) {
170170 files. push ( file. clone ( ) ) ;
171171 }
172172 }
173+
173174 let regex = regex:: Regex :: new ( r"\/\* RSTEST:(MOCK|UNMOCK|MOCKREQUIRE|HOISTED)_(.*?):(.*?) \*\/" )
174175 . expect ( "should initialize `Regex`" ) ;
175176
You can’t perform that action at this time.
0 commit comments