@@ -1646,14 +1646,32 @@ function addRefreshWrapper(
1646
1646
]
1647
1647
: [ ] ;
1648
1648
return (
1649
- REACT_REFRESH_HEADER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) ) +
1650
- code +
1651
- REACT_REFRESH_FOOTER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) )
1652
- . replaceAll ( "__ACCEPT_EXPORTS__" , JSON . stringify ( acceptExports ) )
1653
- . replaceAll ( "__ROUTE_ID__" , JSON . stringify ( route ?. id ) )
1649
+ "\n\n" +
1650
+ withCommentBoundaries (
1651
+ "REACT REFRESH HEADER" ,
1652
+ REACT_REFRESH_HEADER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) )
1653
+ ) +
1654
+ "\n\n" +
1655
+ withCommentBoundaries ( "REACT REFRESH BODY" , code ) +
1656
+ "\n\n" +
1657
+ withCommentBoundaries (
1658
+ "REACT REFRESH FOOTER" ,
1659
+ REACT_REFRESH_FOOTER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) )
1660
+ . replaceAll ( "__ACCEPT_EXPORTS__" , JSON . stringify ( acceptExports ) )
1661
+ . replaceAll ( "__ROUTE_ID__" , JSON . stringify ( route ?. id ) )
1662
+ ) +
1663
+ "\n"
1654
1664
) ;
1655
1665
}
1656
1666
1667
+ function withCommentBoundaries ( label : string , text : string ) {
1668
+ let begin = `// [BEGIN] ${ label } ` ;
1669
+ begin += "-" . repeat ( 80 - begin . length ) ;
1670
+ let end = `// [END] ${ label } ` ;
1671
+ end += "-" . repeat ( 80 - end . length ) ;
1672
+ return `${ begin } \n${ text } \n${ end } ` ;
1673
+ }
1674
+
1657
1675
const REACT_REFRESH_HEADER = `
1658
1676
import RefreshRuntime from "${ hmrRuntimeId } ";
1659
1677
@@ -1674,7 +1692,7 @@ if (import.meta.hot && !inWebWorker) {
1674
1692
RefreshRuntime.register(type, __SOURCE__ + " " + id)
1675
1693
};
1676
1694
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
1677
- }` . replace ( / \n + / g , "" ) ;
1695
+ }` . trim ( ) ;
1678
1696
1679
1697
const REACT_REFRESH_FOOTER = `
1680
1698
if (import.meta.hot && !inWebWorker) {
@@ -1689,7 +1707,7 @@ if (import.meta.hot && !inWebWorker) {
1689
1707
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
1690
1708
});
1691
1709
});
1692
- }` ;
1710
+ }` . trim ( ) ;
1693
1711
1694
1712
function getRoute (
1695
1713
pluginConfig : ResolvedReactRouterConfig ,
0 commit comments