@@ -405,17 +405,21 @@ function addMissingLibraryStubs(unusedLibSymbols) {
405405 return rtn ;
406406}
407407
408+ function exportSymbol ( name ) {
409+ if ( MODULARIZE === 'instance' ) {
410+ return `__exp_${ name } = ${ name } ;` ;
411+ }
412+ return `Module['${ name } '] = ${ name } ;` ;
413+ }
414+
408415// export parts of the JS runtime that the user asked for
409- function exportRuntime ( ) {
416+ function exportRuntimeSymbols ( ) {
410417 // optionally export something.
411418 function maybeExport ( name ) {
412419 // If requested to be exported, export it. HEAP objects are exported
413420 // separately in updateMemoryViews
414421 if ( EXPORTED_RUNTIME_METHODS . has ( name ) && ! name . startsWith ( 'HEAP' ) ) {
415- if ( MODULARIZE === 'instance' ) {
416- return `__exp_${ name } = ${ name } ;` ;
417- }
418- return `Module['${ name } '] = ${ name } ;` ;
422+ return exportSymbol ( name ) ;
419423 }
420424 }
421425
@@ -509,6 +513,7 @@ function exportRuntime() {
509513 }
510514
511515 const exports = runtimeElements . map ( maybeExport ) ;
516+ exports . unshift ( '// Begin runtime exports' ) ;
512517 const results = exports . filter ( ( name ) => name ) ;
513518
514519 if ( ASSERTIONS && ! EXPORT_ALL ) {
@@ -540,8 +545,23 @@ function exportRuntime() {
540545 return results . join ( '\n' ) + '\n' ;
541546}
542547
548+ function exportLibrarySymbols ( ) {
549+ const results = [ '// Begin JS library exports' ] ;
550+ for ( const ident of librarySymbols ) {
551+ if ( EXPORT_ALL || EXPORTED_FUNCTIONS . has ( ident ) ) {
552+ results . push ( exportSymbol ( ident ) ) ;
553+ }
554+ }
555+
556+ return results . join ( '\n' ) + '\n' ;
557+ }
558+
559+ function exportJSSymbols ( ) {
560+ return exportRuntimeSymbols ( ) + exportLibrarySymbols ( ) ;
561+ }
562+
543563addToCompileTimeContext ( {
544- exportRuntime ,
564+ exportJSSymbols ,
545565 loadStructInfo,
546566 LibraryManager,
547567 librarySymbols,
0 commit comments