File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed
packages/vite/src/node/server/environments
playground/rolldown-dev-react/src Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -336,11 +336,12 @@ function reactRefreshPlugin(): rolldown.Plugin {
336
336
} ,
337
337
} ,
338
338
handler ( code , id ) {
339
- return [
340
- `const [$RefreshSig$, $RefreshReg$] = __react_refresh_transform_define(${ JSON . stringify ( id ) } )` ,
341
- code ,
342
- `__react_refresh_transform_setupHot(module.hot)` ,
343
- ] . join ( ';' )
339
+ const output = new MagicString ( code )
340
+ output . prepend (
341
+ `const [$RefreshSig$, $RefreshReg$] = __react_refresh_transform_define(${ JSON . stringify ( id ) } );` ,
342
+ )
343
+ output . append ( `;__react_refresh_transform_setupHot(module.hot);` )
344
+ return { code : output . toString ( ) , map : output . generateMap ( ) }
344
345
} ,
345
346
} ,
346
347
}
Original file line number Diff line number Diff line change 1
- import { useState } from 'react'
1
+ import React from 'react'
2
2
// @ts -expect-error no type
3
3
import virtualTest from 'virtual:test'
4
4
// @ts -expect-error no type
5
5
import testAlias from 'test-alias'
6
+ import { throwError } from './error'
6
7
7
8
export function App ( ) {
8
- const [ count , setCount ] = useState ( 0 )
9
+ const [ count , setCount ] = React . useState ( 0 )
9
10
10
11
return (
11
12
< div >
@@ -16,6 +17,8 @@ export function App() {
16
17
</ button >
17
18
< pre > [virtual] { virtualTest } </ pre >
18
19
< pre > [alias] { testAlias } </ pre >
20
+ { /* TODO: app.tsx source map is slightly off? */ }
21
+ < button onClick = { ( ) => throwError ( ) } > stacktrace</ button >
19
22
</ div >
20
23
</ div >
21
24
)
Original file line number Diff line number Diff line change
1
+ //
2
+ // random new lines
3
+ //
4
+ export function throwError ( ) {
5
+ //
6
+ // and more
7
+ //
8
+ throw new Error ( 'boom' )
9
+ }
You can’t perform that action at this time.
0 commit comments