File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 11import { dirname , resolve } from 'node:path'
22import { fileURLToPath } from 'node:url'
3+ import fs from 'node:fs'
34import colors from 'picocolors'
4- import { rewriteImports } from './util'
5+ import { rewriteImports , walkDir } from './util'
56
67const dir = dirname ( fileURLToPath ( import . meta. url ) )
78const nodeDts = resolve ( dir , '../dist/node/index.d.ts' )
@@ -14,3 +15,18 @@ rewriteImports(nodeDts, (importPath) => {
1415} )
1516
1617console . 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 {
2121 return p . replace ( / \\ / g, '/' )
2222}
2323
24- function walkDir ( dir : string , handleFile : ( file : string ) => void ) : void {
24+ export function walkDir ( dir : string , handleFile : ( file : string ) => void ) : void {
2525 if ( statSync ( dir ) . isDirectory ( ) ) {
2626 const files = readdirSync ( dir )
2727 for ( const file of files ) {
Original file line number Diff line number Diff line change 22 "compilerOptions" : {
33 "noEmit" : true ,
44 "moduleResolution" : " classic" ,
5+ "noResolve" : true ,
6+ "typeRoots" : [],
57 // Only add entries to `paths` when you are adding/updating dependencies (not devDependencies)
68 // See CONTRIBUTING.md "Ensure type support" for more details
79 "paths" : {
1416 // indirect: postcss depends on it
1517 "source-map-js" : [" ./node_modules/source-map-js/source-map.d.ts" ]
1618 },
17- "typeRoots" : [],
1819 "strict" : true ,
1920 "exactOptionalPropertyTypes" : true
2021 },
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+ ]
2237}
You can’t perform that action at this time.
0 commit comments