@@ -65,6 +65,9 @@ const devserverHost =
65
65
const isDevMode = mode !== 'production' ;
66
66
const isDevServer = process . argv [ 1 ] . includes ( 'webpack-dev-server' ) ;
67
67
68
+ // TypeScript checker memory limit (in MB)
69
+ const TYPESCRIPT_MEMORY_LIMIT = 4096 ;
70
+
68
71
const output = {
69
72
path : BUILD_DIR ,
70
73
publicPath : '/static/assets/' ,
@@ -184,21 +187,64 @@ if (!isDevMode) {
184
187
chunkFilename : '[name].[chunkhash].chunk.css' ,
185
188
} ) ,
186
189
) ;
190
+ }
187
191
188
- // Runs type checking on a separate process to speed up the build
192
+ // Type checking for both dev and production
193
+ // In dev mode, this provides real-time type checking and builds .d.ts files for plugins
194
+ // Can be disabled with DISABLE_TYPE_CHECK=true npm run dev
195
+ if ( isDevMode ) {
196
+ if ( process . env . DISABLE_TYPE_CHECK ) {
197
+ console . log ( '⚡ Type checking disabled (DISABLE_TYPE_CHECK=true)' ) ;
198
+ } else {
199
+ console . log (
200
+ '✅ Type checking enabled (disable with DISABLE_TYPE_CHECK=true npm run dev)' ,
201
+ ) ;
202
+ // Optimized configuration for development - much faster type checking
203
+ plugins . push (
204
+ new ForkTsCheckerWebpackPlugin ( {
205
+ typescript : {
206
+ memoryLimit : TYPESCRIPT_MEMORY_LIMIT ,
207
+ build : true , // Generate .d.ts files
208
+ mode : 'write-references' , // Handle project references properly
209
+ // Use main tsconfig but with safe performance optimizations
210
+ configOverwrite : {
211
+ compilerOptions : {
212
+ // Only safe optimizations that won't cause errors
213
+ skipLibCheck : true , // Skip checking .d.ts files - safe and huge perf boost
214
+ incremental : true , // Enable incremental compilation
215
+ } ,
216
+ } ,
217
+ } ,
218
+ // Logger configuration
219
+ logger : 'webpack-infrastructure' ,
220
+ async : true , // Non-blocking type checking
221
+ // Only check files that webpack is actually processing
222
+ // This dramatically reduces the scope of type checking
223
+ issue : {
224
+ scope : 'webpack' , // Only check files in webpack's module graph, not entire project
225
+ include : [
226
+ { file : 'src/**/*.{ts,tsx}' } ,
227
+ { file : 'packages/*/src/**/*.{ts,tsx}' } ,
228
+ { file : 'plugins/*/src/**/*.{ts,tsx}' } ,
229
+ ] ,
230
+ exclude : [ { file : '**/node_modules/**' } ] ,
231
+ } ,
232
+ } ) ,
233
+ ) ;
234
+ }
235
+ } else {
236
+ // Production mode - full type checking
189
237
plugins . push (
190
238
new ForkTsCheckerWebpackPlugin ( {
191
239
typescript : {
192
- memoryLimit : 4096 ,
240
+ memoryLimit : TYPESCRIPT_MEMORY_LIMIT ,
193
241
build : true ,
194
- exclude : [
195
- '**/node_modules/**' ,
196
- '**/dist/**' ,
197
- '**/coverage/**' ,
198
- '**/storybook/**' ,
199
- '**/*.stories.{ts,tsx,js,jsx}' ,
200
- '**/*.{test,spec}.{ts,tsx,js,jsx}' ,
201
- ] ,
242
+ mode : 'write-references' ,
243
+ } ,
244
+ // Logger configuration
245
+ logger : 'webpack-infrastructure' ,
246
+ issue : {
247
+ exclude : [ { file : '**/node_modules/**' } ] ,
202
248
} ,
203
249
} ) ,
204
250
) ;
@@ -344,7 +390,12 @@ const config = {
344
390
} ,
345
391
resolve : {
346
392
// resolve modules from `/superset_frontend/node_modules` and `/superset_frontend`
347
- modules : [ 'node_modules' , APP_DIR ] ,
393
+ modules : [
394
+ 'node_modules' ,
395
+ APP_DIR ,
396
+ path . resolve ( APP_DIR , 'packages' ) ,
397
+ path . resolve ( APP_DIR , 'plugins' ) ,
398
+ ] ,
348
399
alias : {
349
400
react : path . resolve ( path . join ( APP_DIR , './node_modules/react' ) ) ,
350
401
// TODO: remove Handlebars alias once Handlebars NPM package has been updated to
@@ -538,6 +589,16 @@ const config = {
538
589
} ,
539
590
plugins,
540
591
devtool : isDevMode ? 'eval-cheap-module-source-map' : false ,
592
+ watchOptions : isDevMode
593
+ ? {
594
+ // Watch all plugin and package source directories
595
+ ignored : [ '**/node_modules' , '**/.git' , '**/lib' , '**/esm' , '**/dist' ] ,
596
+ // Poll less frequently to reduce file handles
597
+ poll : 2000 ,
598
+ // Aggregate changes for 500ms before rebuilding
599
+ aggregateTimeout : 500 ,
600
+ }
601
+ : undefined ,
541
602
} ;
542
603
543
604
// find all the symlinked plugins and use their source code for imports
0 commit comments