mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(napi/transformer): refresh plugin doesn't work even after passing the refresh option (#5702)
This commit is contained in:
parent
c2997f1775
commit
608b7d37d6
2 changed files with 33 additions and 1 deletions
|
|
@ -161,7 +161,7 @@ impl From<ReactBindingOptions> for ReactOptions {
|
|||
pragma_frag: options.pragma_frag,
|
||||
use_built_ins: options.use_built_ins,
|
||||
use_spread: options.use_spread,
|
||||
refresh: ops.refresh.map(Into::into),
|
||||
refresh: options.refresh.map(Into::into),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,3 +35,35 @@ test(oxc.transform('test.ts', 'class A<T> {}', { sourcemap: true }), {
|
|||
version: 3,
|
||||
},
|
||||
});
|
||||
|
||||
// Test react refresh plugin
|
||||
test(
|
||||
oxc.transform(
|
||||
'test.tsx',
|
||||
`
|
||||
import { useState } from "react";
|
||||
export const App = () => {
|
||||
const [count, setCount] = useState(0);
|
||||
return <button onClick={() => setCount(count + 1)}>count is {count}</button>;
|
||||
};
|
||||
`,
|
||||
{ react: { refresh: {} } },
|
||||
),
|
||||
{
|
||||
code: 'var _s = $RefreshSig$();\n' +
|
||||
'import { useState } from "react";\n' +
|
||||
'import { jsxs as _jsxs } from "react/jsx-runtime";\n' +
|
||||
'export const App = () => {\n' +
|
||||
'\t_s();\n' +
|
||||
'\tconst [count, setCount] = useState(0);\n' +
|
||||
'\treturn _jsxs("button", {\n' +
|
||||
'\t\tonClick: () => setCount(count + 1),\n' +
|
||||
'\t\tchildren: ["count is ", count]\n' +
|
||||
'\t});\n' +
|
||||
'};\n' +
|
||||
'_s(App, "oDgYfYHkD9Wkv4hrAPCkI/ev3YU=");\n' +
|
||||
'_c = App;\n' +
|
||||
'var _c;\n' +
|
||||
'$RefreshReg$(_c, "App");\n',
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue