@@ -1701,32 +1701,14 @@ function addRefreshWrapper(
1701
1701
]
1702
1702
: [ ] ;
1703
1703
return (
1704
- "\n\n" +
1705
- withCommentBoundaries (
1706
- "REACT REFRESH HEADER" ,
1707
- REACT_REFRESH_HEADER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) )
1708
- ) +
1709
- "\n\n" +
1710
- withCommentBoundaries ( "REACT REFRESH BODY" , code ) +
1711
- "\n\n" +
1712
- withCommentBoundaries (
1713
- "REACT REFRESH FOOTER" ,
1714
- REACT_REFRESH_FOOTER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) )
1715
- . replaceAll ( "__ACCEPT_EXPORTS__" , JSON . stringify ( acceptExports ) )
1716
- . replaceAll ( "__ROUTE_ID__" , JSON . stringify ( route ?. id ) )
1717
- ) +
1718
- "\n"
1704
+ REACT_REFRESH_HEADER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) ) +
1705
+ code +
1706
+ REACT_REFRESH_FOOTER . replaceAll ( "__SOURCE__" , JSON . stringify ( id ) )
1707
+ . replaceAll ( "__ACCEPT_EXPORTS__" , JSON . stringify ( acceptExports ) )
1708
+ . replaceAll ( "__ROUTE_ID__" , JSON . stringify ( route ?. id ) )
1719
1709
) ;
1720
1710
}
1721
1711
1722
- function withCommentBoundaries ( label : string , text : string ) {
1723
- let begin = `// [BEGIN] ${ label } ` ;
1724
- begin += "-" . repeat ( 80 - begin . length ) ;
1725
- let end = `// [END] ${ label } ` ;
1726
- end += "-" . repeat ( 80 - end . length ) ;
1727
- return `${ begin } \n${ text } \n${ end } ` ;
1728
- }
1729
-
1730
1712
const REACT_REFRESH_HEADER = `
1731
1713
import RefreshRuntime from "${ virtualHmrRuntime . id } ";
1732
1714
@@ -1747,7 +1729,7 @@ if (import.meta.hot && !inWebWorker) {
1747
1729
RefreshRuntime.register(type, __SOURCE__ + " " + id)
1748
1730
};
1749
1731
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
1750
- }` . trim ( ) ;
1732
+ }` . replaceAll ( "\n" , "" ) ; // Header is all on one line so source maps aren't affected
1751
1733
1752
1734
const REACT_REFRESH_FOOTER = `
1753
1735
if (import.meta.hot && !inWebWorker) {
@@ -1762,7 +1744,7 @@ if (import.meta.hot && !inWebWorker) {
1762
1744
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
1763
1745
});
1764
1746
});
1765
- }` . trim ( ) ;
1747
+ }` ;
1766
1748
1767
1749
function getRoute (
1768
1750
pluginConfig : ResolvedReactRouterConfig ,
0 commit comments