@@ -405,17 +405,21 @@ function addMissingLibraryStubs(unusedLibSymbols) {
405
405
return rtn ;
406
406
}
407
407
408
+ function exportSymbol ( name ) {
409
+ if ( MODULARIZE === 'instance' ) {
410
+ return `__exp_${ name } = ${ name } ;` ;
411
+ }
412
+ return `Module['${ name } '] = ${ name } ;` ;
413
+ }
414
+
408
415
// export parts of the JS runtime that the user asked for
409
- function exportRuntime ( ) {
416
+ function exportRuntimeSymbols ( ) {
410
417
// optionally export something.
411
418
function maybeExport ( name ) {
412
419
// If requested to be exported, export it. HEAP objects are exported
413
420
// separately in updateMemoryViews
414
421
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 ) ;
419
423
}
420
424
}
421
425
@@ -509,6 +513,7 @@ function exportRuntime() {
509
513
}
510
514
511
515
const exports = runtimeElements . map ( maybeExport ) ;
516
+ exports . unshift ( '// Begin runtime exports' )
512
517
const results = exports . filter ( ( name ) => name ) ;
513
518
514
519
if ( ASSERTIONS && ! EXPORT_ALL ) {
@@ -540,8 +545,25 @@ function exportRuntime() {
540
545
return results . join ( '\n' ) + '\n' ;
541
546
}
542
547
548
+ function exportLibrarySymbols ( ) {
549
+ const results = [ '// Begin JS library exports' ] ;
550
+ for ( const ident of librarySymbols ) {
551
+ if ( ! isDecorator ( ident ) && ! isInternalSymbol ( ident ) ) {
552
+ if ( EXPORT_ALL || EXPORTED_FUNCTIONS . has ( ident ) ) {
553
+ results . push ( exportSymbol ( ident ) ) ;
554
+ }
555
+ }
556
+ }
557
+
558
+ return results . join ( '\n' ) + '\n' ;
559
+ }
560
+
561
+ function exportJSSymbols ( ) {
562
+ return exportRuntimeSymbols ( ) + exportLibrarySymbols ( ) ;
563
+ }
564
+
543
565
addToCompileTimeContext ( {
544
- exportRuntime ,
566
+ exportJSSymbols ,
545
567
loadStructInfo,
546
568
LibraryManager,
547
569
librarySymbols,
0 commit comments