@@ -19,16 +19,20 @@ function appendFileContents(targetFilePath, sourceFilePath, divider = '\n') {
1919 } )
2020}
2121
22- function removeExport ( filePath ) {
22+ function removeImportExport ( filePath ) {
2323 const data = fs . readFileSync ( filePath , { encoding : 'utf-8' } )
2424 // remove export declarations and non-interface/type exports
2525 const processedContent = data
2626 . split ( '\n' )
2727 . filter ( ( line ) => {
28+ const l = line . trim ( )
2829 // Remove export declarations
29- if ( line . trim ( ) . startsWith ( 'export ' ) ) {
30+ if ( l . startsWith ( 'export ' ) ) {
3031 // Keep only interface and type exports
31- return line . includes ( 'interface' ) || line . includes ( 'type' )
32+ return l . includes ( 'interface' ) || l . includes ( 'type' )
33+ }
34+ if ( l . startsWith ( 'import' ) ) {
35+ return false
3236 }
3337 return true
3438 } )
@@ -62,16 +66,15 @@ const main = () => {
6266 const command = `yarn dts-bundle-generator -o ${ outFile } src/web-exports.ts --no-check`
6367 execSync ( command , { stdio : 'inherit' } )
6468 const outFileAbs = path . join ( __dirname , outFile )
65- removeExport ( outFileAbs )
6669
67- // Prepend ignore artifactions
6870 prependGenerated ( outFileAbs )
6971
7072 // Append the contents of web-exports-globals.ts
7173 const globalsFilePath = path . join ( __dirname , 'src/web-exports-globals.ts' )
7274 appendFileContents ( outFileAbs , globalsFilePath )
7375 // remove any comments that use // like ts-ignore, ts-nocheck etc (/* */ is OK)
7476 filterLines ( outFileAbs , ( line ) => ! line . startsWith ( '//' ) )
77+ removeImportExport ( outFileAbs )
7578}
7679
7780main ( )
0 commit comments