@@ -25,7 +25,6 @@ const excludeNames = new Set(["README.md", "LICENSE", "LICENSE.md", "LICENSE.txt
2525const tarExcludes = [
2626 "node_modules/.bin" ,
2727 "node_modules/katex/src" ,
28- "*.d.ts" ,
2928 "*.map" ,
3029 "README.md" ,
3130 "LICENSE" ,
@@ -35,13 +34,24 @@ const tarExcludes = [
3534 . map ( ( p ) => `--exclude='${ p } '` )
3635 . join ( " " ) ;
3736
37+ // TypeScript's lib.*.d.ts files are required by tsserver for IntelliSense.
38+ const keepDts = new Set ( [ "typescript/lib" ] ) ;
39+
3840// Hash node_modules content deterministically (independent of tar metadata)
3941console . log ( "Hashing lib/node_modules..." ) ;
4042
41- function shouldExclude ( name : string ) : boolean {
43+ function shouldExclude ( name : string , relPath : string ) : boolean {
4244 if ( excludeNames . has ( name ) ) return true ;
4345 for ( const ext of excludeExts ) {
44- if ( name . endsWith ( ext ) ) return true ;
46+ if ( name . endsWith ( ext ) ) {
47+ // Keep .d.ts files required by tsserver for IntelliSense
48+ if ( ext === ".d.ts" ) {
49+ for ( const keep of keepDts ) {
50+ if ( relPath . includes ( keep ) ) return false ;
51+ }
52+ }
53+ return true ;
54+ }
4555 }
4656 return false ;
4757}
@@ -58,8 +68,9 @@ function collectFiles(dir: string, files: string[] = []): string[] {
5868 if ( excludeDirPaths . has ( relative ( nodeModulesDir , fullPath ) ) ) continue ;
5969 collectFiles ( fullPath , files ) ;
6070 } else if ( entry . isFile ( ) || isSymlink ) {
61- if ( shouldExclude ( entry . name ) ) continue ;
62- files . push ( relative ( nodeModulesDir , fullPath ) ) ;
71+ const relPath = relative ( nodeModulesDir , fullPath ) ;
72+ if ( shouldExclude ( entry . name , relPath ) ) continue ;
73+ files . push ( relPath ) ;
6374 }
6475 }
6576 return files ;
0 commit comments