File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import path from 'node:path'
22import { describe , expect , test } from 'vitest'
3+ import { PartialEnvironment } from '../../baseEnvironment'
34import { resolveConfig } from '../../config'
4- import { transformWithOxc } from '../../plugins/oxc'
5+ import { oxcPlugin , transformWithOxc } from '../../plugins/oxc'
6+
7+ describe ( 'oxcPlugin' , ( ) => {
8+ test ( 'preserves the language of modules with extensions in queries' , async ( ) => {
9+ const config = await resolveConfig (
10+ {
11+ configFile : false ,
12+ oxc : { jsxRefreshInclude : / \. t s x $ / } ,
13+ } ,
14+ 'serve' ,
15+ )
16+ const plugin = oxcPlugin ( config )
17+ const environment = new PartialEnvironment ( 'client' , config )
18+ const transform = plugin . transform as any
19+ const result = await transform . call (
20+ { environment } ,
21+ 'const value: string = "hello"' ,
22+ '/project/App.vue?vue&type=script&setup=true&lang.tsx' ,
23+ )
24+
25+ expect ( result . code ) . toMatchInlineSnapshot ( `
26+ "const value = "hello";
27+ "
28+ ` )
29+ } )
30+ } )
531
632describe ( 'transformWithOxc' , ( ) => {
733 test ( 'correctly overrides TS configuration and applies automatic transform' , async ( ) => {
Original file line number Diff line number Diff line change @@ -265,7 +265,11 @@ export function oxcPlugin(config: ResolvedConfig): Plugin {
265265 ) {
266266 result . jsx = { ...jsxOptions , refresh : false }
267267 }
268- if ( jsxRefreshFilter ?.( id ) && ! JS_TYPES_RE . test ( cleanUrl ( id ) ) ) {
268+ if (
269+ jsxRefreshFilter ?.( id ) &&
270+ ! JS_TYPES_RE . test ( id ) &&
271+ ! JS_TYPES_RE . test ( cleanUrl ( id ) )
272+ ) {
269273 result . lang = 'js'
270274 }
271275
You can’t perform that action at this time.
0 commit comments