File tree 3 files changed +35
-4
lines changed
3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { dirname , resolve } from 'node:path'
2
2
import { fileURLToPath } from 'node:url'
3
+ import fs from 'node:fs'
3
4
import colors from 'picocolors'
4
- import { rewriteImports } from './util'
5
+ import { rewriteImports , walkDir } from './util'
5
6
6
7
const dir = dirname ( fileURLToPath ( import . meta. url ) )
7
8
const nodeDts = resolve ( dir , '../dist/node/index.d.ts' )
@@ -14,3 +15,18 @@ rewriteImports(nodeDts, (importPath) => {
14
15
} )
15
16
16
17
console . log ( colors . green ( colors . bold ( `patched types/* imports` ) ) )
18
+
19
+ // remove picomatch type import because only the internal property uses it
20
+ const picomatchImport = "import type { Matcher as Matcher_2 } from 'picomatch';"
21
+
22
+ walkDir ( nodeDts , ( file ) => {
23
+ const content = fs . readFileSync ( file , 'utf-8' )
24
+ if ( ! content . includes ( picomatchImport ) ) {
25
+ throw new Error ( `Should find picomatch type import in ${ file } ` )
26
+ }
27
+
28
+ const replacedContent = content . replace ( picomatchImport , '' )
29
+ fs . writeFileSync ( file , replacedContent , 'utf-8' )
30
+ } )
31
+
32
+ console . log ( colors . green ( colors . bold ( `removed picomatch type import` ) ) )
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export function slash(p: string): string {
21
21
return p . replace ( / \\ / g, '/' )
22
22
}
23
23
24
- function walkDir ( dir : string , handleFile : ( file : string ) => void ) : void {
24
+ export function walkDir ( dir : string , handleFile : ( file : string ) => void ) : void {
25
25
if ( statSync ( dir ) . isDirectory ( ) ) {
26
26
const files = readdirSync ( dir )
27
27
for ( const file of files ) {
Original file line number Diff line number Diff line change 2
2
"compilerOptions" : {
3
3
"noEmit" : true ,
4
4
"moduleResolution" : " classic" ,
5
+ "noResolve" : true ,
6
+ "typeRoots" : [],
5
7
// Only add entries to `paths` when you are adding/updating dependencies (not devDependencies)
6
8
// See CONTRIBUTING.md "Ensure type support" for more details
7
9
"paths" : {
14
16
// indirect: postcss depends on it
15
17
"source-map-js" : [" ./node_modules/source-map-js/source-map.d.ts" ]
16
18
},
17
- "typeRoots" : [],
18
19
"strict" : true ,
19
20
"exactOptionalPropertyTypes" : true
20
21
},
21
- "include" : [" dist/**/*.d.ts" ]
22
+ "include" : [
23
+ " ../../node_modules/@types/node/**/*" ,
24
+ // dependencies
25
+ " ./node_modules/rollup/**/*" ,
26
+ " ./node_modules/esbuild/**/*" ,
27
+ " ./node_modules/postcss/**/*" ,
28
+ " ./node_modules/source-map-js/**/*" ,
29
+ // dist
30
+ " dist/**/*" ,
31
+ " types/customEvent.d.ts" ,
32
+ " types/hmrPayload.d.ts" ,
33
+ " types/importGlob.d.ts" ,
34
+ " types/importMeta.d.ts" ,
35
+ " types/hot.d.ts"
36
+ ]
22
37
}
You can’t perform that action at this time.
0 commit comments