File tree Expand file tree Collapse file tree 7 files changed +364
-818
lines changed Expand file tree Collapse file tree 7 files changed +364
-818
lines changed Original file line number Diff line number Diff line change 3838 },
3939 "homepage" : " https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme" ,
4040 "dependencies" : {
41- "@babel/core" : " ^7.25.2 " ,
41+ "@babel/core" : " ^7.26.0 " ,
4242 "@babel/plugin-transform-react-jsx-self" : " ^7.24.7" ,
4343 "@babel/plugin-transform-react-jsx-source" : " ^7.24.7" ,
4444 "@types/babel__core" : " ^7.20.5" ,
Original file line number Diff line number Diff line change @@ -249,6 +249,8 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
249249 } ,
250250 generatorOpts : {
251251 ...babelOptions . generatorOpts ,
252+ // import attributes parsing available without plugin since 7.26
253+ importAttributesKeyword : 'with' ,
252254 decoratorsBeforeExport : true ,
253255 } ,
254256 plugins,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Parent from './hmr/parent'
55import { JsxImportRuntime } from './hmr/jsx-import-runtime'
66import { CountProvider } from './context/CountProvider'
77import { ContextButton } from './context/ContextButton'
8+ import { TestImportAttributes } from './import-attributes/test'
89
910function App ( ) {
1011 const [ count , setCount ] = useState ( 0 )
@@ -40,6 +41,7 @@ function App() {
4041 < Parent />
4142 < JsxImportRuntime />
4243 < Button > button</ Button >
44+ < TestImportAttributes />
4345 </ div >
4446 )
4547}
Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ test.runIf(isServe)(
6969 } ,
7070)
7171
72+ test ( 'import attributes' , async ( ) => {
73+ expect ( await page . textContent ( '.import-attributes' ) ) . toBe ( 'ok' )
74+ } )
75+
7276if ( ! isBuild ) {
7377 // #9869
7478 test ( 'should only hmr files with exported react components' , async ( ) => {
Original file line number Diff line number Diff line change 1+ {
2+ "message" : " ok"
3+ }
Original file line number Diff line number Diff line change 1+ import data from './data.json' with { type : 'json' }
2+
3+ export function TestImportAttributes ( ) {
4+ return (
5+ < div >
6+ import-attirbutes: < span class = "import-attributes" > { data . message } </ span >
7+ </ div >
8+ )
9+ }
You can’t perform that action at this time.
0 commit comments