@@ -20,7 +20,7 @@ const BabelJsLoaderFactory: ConfigureWebpackUtils['getJSLoader'] = ({
20
20
} ;
21
21
} ;
22
22
23
- async function createSwcLoaderFactory ( ) : Promise <
23
+ async function createSwcJsLoaderFactory ( ) : Promise <
24
24
ConfigureWebpackUtils [ 'getJSLoader' ]
25
25
> {
26
26
const loader = await importSwcLoader ( ) ;
@@ -34,7 +34,7 @@ async function createSwcLoaderFactory(): Promise<
34
34
}
35
35
36
36
// Same as swcLoader, except we use the built-in SWC loader
37
- async function createRspackLoaderFactory ( ) : Promise <
37
+ async function createRspackSwcJsLoaderFactory ( ) : Promise <
38
38
ConfigureWebpackUtils [ 'getJSLoader' ]
39
39
> {
40
40
const loader = 'builtin:swc-loader' ;
@@ -62,14 +62,10 @@ export async function createJsLoaderFactory({
62
62
} ) : Promise < ConfigureWebpackUtils [ 'getJSLoader' ] > {
63
63
const currentBundler = await getCurrentBundler ( { siteConfig} ) ;
64
64
const isSWCLoader = siteConfig . future . experimental_faster . swcJsLoader ;
65
-
66
65
if ( currentBundler . name === 'rspack' ) {
67
- if ( ! isSWCLoader ) {
68
- throw new Error (
69
- 'When using Rspack bundler, it is required to enable swcJsLoader too' ,
70
- ) ;
71
- }
72
- return createRspackLoaderFactory ( ) ;
66
+ return isSWCLoader
67
+ ? createRspackSwcJsLoaderFactory ( )
68
+ : BabelJsLoaderFactory ;
73
69
}
74
70
const jsLoader = siteConfig . webpack ?. jsLoader ?? 'babel' ;
75
71
if (
@@ -84,7 +80,7 @@ export async function createJsLoaderFactory({
84
80
return ( { isServer} ) => jsLoader ( isServer ) ;
85
81
}
86
82
if ( siteConfig . future ?. experimental_faster . swcJsLoader ) {
87
- return createSwcLoaderFactory ( ) ;
83
+ return createSwcJsLoaderFactory ( ) ;
88
84
}
89
85
if ( jsLoader === 'babel' ) {
90
86
return BabelJsLoaderFactory ;
0 commit comments