@@ -175,6 +175,90 @@ describe('swc transforms support detection', () => {
175175 ) ;
176176 } ) ;
177177
178+ it ( 'should apply default react transform when plugin has no react transform options' , ( ) => {
179+ const inputConfig : SwcLoaderOptions = {
180+ jsc : {
181+ transform : { react : { } } ,
182+ } ,
183+ } ;
184+ const { swcConfig } = getSupportedSwcCustomTransforms (
185+ [ [ 'transform-react-jsx' , { } ] ] ,
186+ inputConfig
187+ ) ;
188+
189+ expect ( swcConfig . jsc ?. transform ?. react ) . toEqual ( {
190+ runtime : 'automatic' ,
191+ importSource : 'react' ,
192+ } ) ;
193+ } ) ;
194+
195+ it ( 'should preserve existing react transform config when plugin has none' , ( ) => {
196+ const inputConfig : SwcLoaderOptions = {
197+ jsc : {
198+ transform : {
199+ react : { runtime : 'automatic' , importSource : 'nativewind' } ,
200+ } ,
201+ } ,
202+ } ;
203+ const { swcConfig } = getSupportedSwcCustomTransforms (
204+ [ [ 'transform-react-jsx' , { } ] ] ,
205+ inputConfig
206+ ) ;
207+
208+ expect ( swcConfig . jsc ?. transform ?. react ) . toEqual ( {
209+ runtime : 'automatic' ,
210+ importSource : 'nativewind' ,
211+ } ) ;
212+ } ) ;
213+
214+ it ( 'should use plugin importSource option for react transform' , ( ) => {
215+ const inputConfig : SwcLoaderOptions = {
216+ jsc : {
217+ transform : {
218+ react : { } ,
219+ } ,
220+ } ,
221+ } ;
222+ const { swcConfig } = getSupportedSwcCustomTransforms (
223+ [
224+ [
225+ 'transform-react-jsx' ,
226+ { runtime : 'automatic' , importSource : 'nativewind' } ,
227+ ] ,
228+ ] ,
229+ inputConfig
230+ ) ;
231+
232+ expect ( swcConfig . jsc ?. transform ?. react ) . toEqual ( {
233+ runtime : 'automatic' ,
234+ importSource : 'nativewind' ,
235+ } ) ;
236+ } ) ;
237+
238+ it ( 'should use plugin importSource option for react transform and override existing importSource' , ( ) => {
239+ const inputConfig : SwcLoaderOptions = {
240+ jsc : {
241+ transform : {
242+ react : { importSource : 'preact' } ,
243+ } ,
244+ } ,
245+ } ;
246+ const { swcConfig } = getSupportedSwcCustomTransforms (
247+ [
248+ [
249+ 'transform-react-jsx' ,
250+ { runtime : 'automatic' , importSource : 'nativewind' } ,
251+ ] ,
252+ ] ,
253+ inputConfig
254+ ) ;
255+
256+ expect ( swcConfig . jsc ?. transform ?. react ) . toEqual ( {
257+ runtime : 'automatic' ,
258+ importSource : 'nativewind' ,
259+ } ) ;
260+ } ) ;
261+
178262 it ( 'configures modules commonjs options based on provided config (snapshot)' , ( ) => {
179263 const inputConfig : SwcLoaderOptions = { } ;
180264 const { swcConfig } = getSupportedSwcCustomTransforms (
0 commit comments