File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,26 +12,13 @@ function convertToCommonJs(filePath) {
1212 fs . renameSync ( filePath , commonJsPath ) ;
1313}
1414
15- function convertToCommonJsDeclaration ( filePath ) {
16- // update imports
17- const content = fs . readFileSync ( filePath , 'utf-8' ) ;
18- const updatedContent = content . replace ( / ( f r o m [ ' " ] ) ( .* ) ( \. j s ) ( [ ' " ] ; ? ) / g, '$1$2.cjs$4' ) ;
19- fs . writeFileSync ( filePath , updatedContent , 'utf-8' ) ;
20-
21- // update file extension
22- const commonJsDeclPath = filePath . replace ( / \. d \. t s $ / , '.d.cts' ) ;
23- fs . renameSync ( filePath , commonJsDeclPath ) ;
24- }
25-
2615function walk ( dir ) {
2716 fs . readdirSync ( dir ) . forEach ( file => {
2817 const fullPath = path . join ( dir , file ) ;
2918 if ( fs . lstatSync ( fullPath ) . isDirectory ( ) ) {
3019 walk ( fullPath ) ;
3120 } else if ( file . endsWith ( '.js' ) ) {
3221 convertToCommonJs ( fullPath ) ;
33- } else if ( file . endsWith ( '.d.ts' ) ) {
34- convertToCommonJsDeclaration ( fullPath ) ;
3522 }
3623 } ) ;
3724}
You can’t perform that action at this time.
0 commit comments