@@ -27,16 +27,20 @@ const compileWithReactRefresh = (
2727 callback : CompilationCallback ,
2828) => {
2929 let dist = path . join ( fixturePath , 'dist' ) ;
30+ let cjsEntry = path . join ( fixturePath , 'index.js' ) ;
31+ let mjsEntry = path . join ( fixturePath , 'index.mjs' ) ;
32+ let entry = fs . existsSync ( cjsEntry ) ? cjsEntry : mjsEntry ;
3033 rspack (
3134 {
3235 mode : 'development' ,
3336 context : fixturePath ,
3437 entry : {
35- fixture : path . join ( fixturePath , 'index.js' ) ,
38+ fixture : entry ,
3639 } ,
3740 output : {
3841 path : dist ,
3942 uniqueName,
43+ assetModuleFilename : '[name][ext]' ,
4044 } ,
4145 plugins : [ new ReactRefreshPlugin ( refreshOptions ) ] ,
4246 optimization : {
@@ -164,6 +168,22 @@ describe('react-refresh-rspack-plugin', () => {
164168 ) ;
165169 } ) ;
166170
171+ it ( 'should exclude url dependency when compiling' , ( done ) => {
172+ compileWithReactRefresh (
173+ path . join ( __dirname , 'fixtures/url' ) ,
174+ { } ,
175+ ( _ , stats ) => {
176+ const json = stats ! . toJson ( { all : false , outputPath : true } ) ;
177+ const asset = fs . readFileSync (
178+ path . resolve ( json . outputPath ! , 'sdk.js' ) ,
179+ 'utf-8' ,
180+ ) ;
181+ expect ( asset ) . not . toContain ( 'function $RefreshReg$' ) ;
182+ done ( ) ;
183+ } ,
184+ ) ;
185+ } ) ;
186+
167187 it ( 'should allow custom inject loader when compiling' , ( done ) => {
168188 expect ( ReactRefreshPlugin . loader ) . toBe ( 'builtin:react-refresh-loader' ) ;
169189 compileWithReactRefresh (
0 commit comments