11// @ts -check
2- const rspack = require ( '@rspack/core' ) ;
3- const packageJSON = require ( './package.json' ) ;
4- const path = require ( 'path' ) ;
5- const { merge } = require ( 'webpack-merge' ) ;
6- const ReactRefreshPlugin = require ( '@rspack/plugin-react-refresh' ) ;
7- const { svgLoader, typescriptLoaderProd, typescriptLoaderDev } = require ( '../../scripts/rspack-common' ) ;
2+ import rspack from '@rspack/core' ;
3+ import packageJSON from './package.json' with { type : 'json' } ;
4+ import path from 'path' ;
5+ import { fileURLToPath } from 'url' ;
6+ import { merge } from 'webpack-merge' ;
7+ import ReactRefreshPlugin from '@rspack/plugin-react-refresh' ;
8+ import { svgLoader , typescriptLoaderProd , typescriptLoaderDev } from '../../scripts/rspack-common.js' ;
9+
10+ const __filename = fileURLToPath ( import . meta. url ) ;
11+ const __dirname = path . dirname ( __filename ) ;
812
913const isProduction = mode => mode === 'production' ;
1014const isDevelopment = mode => ! isProduction ( mode ) ;
@@ -228,23 +232,6 @@ const prodConfig = mode => {
228232 } ,
229233 } ) ;
230234
231- // CJS module bundle (no chunks)
232- const uiCjs = merge ( entryForVariant ( variants . ui ) , common ( { mode, variant : variants . ui } ) , commonForProdBundled ( ) , {
233- output : {
234- filename : '[name].js' ,
235- libraryTarget : 'commonjs' ,
236- } ,
237- plugins : [
238- // Bundle everything into a single file for CJS
239- new rspack . optimize . LimitChunkCountPlugin ( {
240- maxChunks : 1 ,
241- } ) ,
242- ] ,
243- optimization : {
244- splitChunks : false ,
245- } ,
246- } ) ;
247-
248235 // Entry ESM module bundle (no chunks)
249236 const entryEsm = merge (
250237 entryForVariant ( variants . entry ) ,
@@ -270,29 +257,7 @@ const prodConfig = mode => {
270257 } ,
271258 ) ;
272259
273- // Entry CJS module bundle (no chunks)
274- const entryCjs = merge (
275- entryForVariant ( variants . entry ) ,
276- common ( { mode, variant : variants . entry } ) ,
277- commonForProdBundled ( ) ,
278- {
279- output : {
280- filename : '[name].js' ,
281- libraryTarget : 'commonjs' ,
282- } ,
283- plugins : [
284- // Bundle everything into a single file for CJS
285- new rspack . optimize . LimitChunkCountPlugin ( {
286- maxChunks : 1 ,
287- } ) ,
288- ] ,
289- optimization : {
290- splitChunks : false ,
291- } ,
292- } ,
293- ) ;
294-
295- return [ uiBrowser , uiEsm , uiCjs , entryEsm , entryCjs ] ;
260+ return [ uiBrowser , uiEsm , entryEsm ] ;
296261} ;
297262
298263/**
@@ -338,7 +303,7 @@ const devConfig = (mode, env) => {
338303 } ) ;
339304} ;
340305
341- module . exports = env => {
306+ export default env => {
342307 const mode = env . production ? 'production' : 'development' ;
343308 return isProduction ( mode ) ? prodConfig ( mode ) : devConfig ( mode , env ) ;
344309} ;
0 commit comments