Skip to content

Commit 681962a

Browse files
committed
build: only include import statements if the respective TS declarations exist
1 parent fa25196 commit 681962a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ function create( fullPath ) {
229229
while ( match !== null) {
230230
name = match[ 1 ];
231231
pkgPath = match[ 2 ];
232-
stmt = replace( IMPORT_STATEMENT, '<name>', name );
233-
stmt = replace( stmt, '<path>', pkgPath );
234-
importStmts.push( stmt );
235232

236233
tsDefPath = replace( require.resolve( pkgPath ), 'lib/index.js', 'docs/types/index.d.ts' );
237234
if ( fs.existsSync( tsDefPath ) ) {
235+
stmt = replace( IMPORT_STATEMENT, '<name>', name );
236+
stmt = replace( stmt, '<path>', pkgPath );
237+
importStmts.push( stmt );
238+
238239
tsDef = fs.readFileSync( tsDefPath, 'utf-8' );
239240
mainExport = tsDef.match( RE_TS_EXPORT );
240241
RE_DOC_MAIN_DECLARE = new RegExp( '(\\/\\*\\*\\n[\\s\\S]+?\\*\\/)\ndeclare (function|var|const) '+mainExport[ 1 ]+'([\\s\\S]*): ([\\s\\S]+?);' );

0 commit comments

Comments
 (0)