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 { RsdoctorRspackPlugin } = require ( '@rsdoctor/rspack-plugin' ) ;
8- const { svgLoader, typescriptLoaderProd, typescriptLoaderDev } = require ( '../../scripts/rspack-common' ) ;
2+ import rspack from '@rspack/core' ;
3+ import path from 'path' ;
4+ import { fileURLToPath } from 'url' ;
5+ import { createRequire } from 'module' ;
6+ import { merge } from 'webpack-merge' ;
7+ import ReactRefreshPlugin from '@rspack/plugin-react-refresh' ;
8+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin' ;
9+ import { svgLoader , typescriptLoaderProd , typescriptLoaderDev } from '../../scripts/rspack-common.js' ;
10+ import packageJSON from './package.json' with { type : 'json' } ;
11+
12+ const require = createRequire ( import . meta. url ) ;
13+ const __filename = fileURLToPath ( import . meta. url ) ;
14+ const __dirname = path . dirname ( __filename ) ;
915
1016const isProduction = mode => mode === 'production' ;
1117const isDevelopment = mode => ! isProduction ( mode ) ;
@@ -185,7 +191,7 @@ const commonForProd = () => {
185191 output : {
186192 path : path . resolve ( __dirname , 'dist' ) ,
187193 filename : '[name].js' ,
188- libraryTarget : 'umd' ,
194+ library : { type : 'umd' } ,
189195 globalObject : 'globalThis' ,
190196 } ,
191197 optimization : {
@@ -305,7 +311,7 @@ const prodConfig = ({ mode, env, analysis }) => {
305311 } ,
306312 output : {
307313 filename : '[name].mjs' ,
308- libraryTarget : 'module' ,
314+ library : { type : 'module' } ,
309315 } ,
310316 plugins : [
311317 // Include the lazy chunks in the bundle as well
@@ -329,7 +335,7 @@ const prodConfig = ({ mode, env, analysis }) => {
329335 {
330336 output : {
331337 filename : '[name].js' ,
332- libraryTarget : 'commonjs' ,
338+ library : { type : 'commonjs' } ,
333339 } ,
334340 plugins : [
335341 // Include the lazy chunks in the bundle as well
@@ -378,7 +384,7 @@ const prodConfig = ({ mode, env, analysis }) => {
378384 } ,
379385 output : {
380386 filename : '[name].mjs' ,
381- libraryTarget : 'module' ,
387+ library : { type : 'module' } ,
382388 } ,
383389 } ,
384390 ) ;
@@ -392,7 +398,7 @@ const prodConfig = ({ mode, env, analysis }) => {
392398 {
393399 output : {
394400 filename : '[name].js' ,
395- libraryTarget : 'commonjs' ,
401+ library : { type : 'commonjs' } ,
396402 } ,
397403 } ,
398404 ) ;
@@ -443,7 +449,7 @@ const devConfig = ({ mode, env }) => {
443449 publicPath : isSandbox ? `` : `${ devUrl . origin } /npm` ,
444450 crossOriginLoading : 'anonymous' ,
445451 filename : `[name].js` ,
446- libraryTarget : 'umd' ,
452+ library : { type : 'umd' } ,
447453 } ,
448454 optimization : {
449455 minimize : false ,
@@ -463,11 +469,8 @@ const devConfig = ({ mode, env }) => {
463469 }
464470 : { } ) ,
465471 } ,
466- cache : true ,
467- experiments : {
468- cache : {
469- type : 'memory' ,
470- } ,
472+ cache : {
473+ type : 'memory' ,
471474 } ,
472475 lazyCompilation : false ,
473476 } ;
@@ -507,7 +510,7 @@ const devConfig = ({ mode, env }) => {
507510 return entryToConfigMap [ variant ] ;
508511} ;
509512
510- module . exports = env => {
513+ export default env => {
511514 const mode = env . production ? 'production' : 'development' ;
512515 const analysis = ! ! env . analysis ;
513516
0 commit comments