@@ -5,6 +5,7 @@ const path = require('path');
55const { merge } = require ( 'webpack-merge' ) ;
66const ReactRefreshPlugin = require ( '@rspack/plugin-react-refresh' ) ;
77const { RsdoctorRspackPlugin } = require ( '@rsdoctor/rspack-plugin' ) ;
8+ const { svgLoader, typescriptLoaderProd, typescriptLoaderDev } = require ( '../../scripts/rspack-common' ) ;
89
910const isProduction = mode => mode === 'production' ;
1011const isDevelopment = mode => ! isProduction ( mode ) ;
@@ -117,20 +118,6 @@ const common = ({ mode, variant, disableRHC = false }) => {
117118 chunks : 'all' ,
118119 enforce : true ,
119120 } ,
120- /**
121- * Sign up is shared between the SignUp component and the SignIn component.
122- */
123- signUp : {
124- minChunks : 1 ,
125- name : 'signup' ,
126- test : module => ! ! ( module . resource && module . resource . includes ( '/ui/components/SignUp' ) ) ,
127- } ,
128- common : {
129- minChunks : 1 ,
130- name : 'ui-common' ,
131- priority : - 20 ,
132- test : module => ! ! ( module . resource && ! module . resource . includes ( '/ui/components' ) ) ,
133- } ,
134121 defaultVendors : {
135122 minChunks : 1 ,
136123 test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ,
@@ -152,116 +139,6 @@ const common = ({ mode, variant, disableRHC = false }) => {
152139 } ;
153140} ;
154141
155- /** @type { () => (import('@rspack/core').RuleSetRule) } */
156- const svgLoader = ( ) => {
157- return {
158- test : / \. s v g $ / ,
159- resolve : {
160- fullySpecified : false ,
161- } ,
162- use : {
163- loader : '@svgr/webpack' ,
164- options : {
165- svgo : true ,
166- svgoConfig : {
167- floatPrecision : 3 ,
168- transformPrecision : 1 ,
169- plugins : [ 'preset-default' , 'removeDimensions' , 'removeStyleElement' ] ,
170- } ,
171- } ,
172- } ,
173- } ;
174- } ;
175-
176- /** @type { (opts?: { targets?: string, useCoreJs?: boolean }) => (import('@rspack/core').RuleSetRule[]) } */
177- const typescriptLoaderProd = (
178- { targets = packageJSON . browserslist , useCoreJs = false } = { targets : packageJSON . browserslist , useCoreJs : false } ,
179- ) => {
180- return [
181- {
182- test : / \. ( j s x ? | t s x ? ) $ / ,
183- exclude : / n o d e _ m o d u l e s / ,
184- use : {
185- loader : 'builtin:swc-loader' ,
186- options : {
187- env : {
188- targets,
189- ...( useCoreJs
190- ? {
191- mode : 'usage' ,
192- coreJs : require ( 'core-js/package.json' ) . version ,
193- }
194- : { } ) ,
195- } ,
196- jsc : {
197- parser : {
198- syntax : 'typescript' ,
199- tsx : true ,
200- } ,
201- externalHelpers : true ,
202- transform : {
203- react : {
204- runtime : 'automatic' ,
205- importSource : '@emotion/react' ,
206- development : false ,
207- refresh : false ,
208- } ,
209- } ,
210- } ,
211- } ,
212- } ,
213- } ,
214- {
215- test : / \. m ? j s $ / ,
216- exclude : / n o d e _ m o d u l e s [ \\ / ] c o r e - j s / ,
217- use : {
218- loader : 'builtin:swc-loader' ,
219- options : {
220- env : {
221- targets,
222- ...( useCoreJs
223- ? {
224- mode : 'usage' ,
225- coreJs : '3.41.0' ,
226- }
227- : { } ) ,
228- } ,
229- isModule : 'unknown' ,
230- } ,
231- } ,
232- } ,
233- ] ;
234- } ;
235-
236- /** @type { () => (import('@rspack/core').RuleSetRule[]) } */
237- const typescriptLoaderDev = ( ) => {
238- return [
239- {
240- test : / \. ( j s x ? | t s x ? ) $ / ,
241- exclude : / n o d e _ m o d u l e s / ,
242- loader : 'builtin:swc-loader' ,
243- options : {
244- jsc : {
245- target : 'esnext' ,
246- parser : {
247- syntax : 'typescript' ,
248- tsx : true ,
249- } ,
250- externalHelpers : true ,
251- transform : {
252- react : {
253- runtime : 'automatic' ,
254- importSource : '@emotion/react' ,
255- development : true ,
256- refresh : true ,
257- } ,
258- } ,
259- } ,
260- } ,
261- } ,
262- ] ;
263- } ;
264-
265142/**
266143 * Used for production builds that have dynamicly loaded chunks.
267144 * @type { (opts?: { targets?: string, useCoreJs?: boolean }) => (import('@rspack/core').Configuration) }
@@ -613,7 +490,7 @@ const devConfig = ({ mode, env }) => {
613490 cache : true ,
614491 experiments : {
615492 cache : {
616- type : 'persistent ' ,
493+ type : 'memory ' ,
617494 } ,
618495 } ,
619496 } ;
0 commit comments