@@ -406,6 +406,11 @@ function addMissingLibraryStubs(unusedLibSymbols) {
406
406
}
407
407
408
408
function exportSymbol ( name ) {
409
+ if ( WASM_ESM_INTEGRATION ) {
410
+ // In ESM integration mode symbols are exported by being included in
411
+ // an export { foo, bar } list so we build up the simple list of names
412
+ return name ;
413
+ }
409
414
if ( MODULARIZE === 'instance' ) {
410
415
return `__exp_${ name } = ${ name } ;` ;
411
416
}
@@ -416,10 +421,13 @@ function exportSymbol(name) {
416
421
function exportRuntimeSymbols ( ) {
417
422
// optionally export something.
418
423
function maybeExport ( name ) {
419
- // If requested to be exported, export it. HEAP objects are exported
420
- // separately in updateMemoryViews
421
- if ( EXPORTED_RUNTIME_METHODS . has ( name ) && ! name . startsWith ( 'HEAP' ) ) {
422
- return exportSymbol ( name ) ;
424
+ // If requested to be exported, export it.
425
+ if ( EXPORTED_RUNTIME_METHODS . has ( name ) ) {
426
+ // Unless we are in WASM_ESM_INTEGRATION mode then HEAP objects are
427
+ // exported separately in updateMemoryViews
428
+ if ( WASM_ESM_INTEGRATION || ! name . startsWith ( 'HEAP' ) ) {
429
+ return exportSymbol ( name ) ;
430
+ }
423
431
}
424
432
}
425
433
@@ -518,6 +526,10 @@ function exportRuntimeSymbols() {
518
526
const exports = runtimeElements . map ( maybeExport ) ;
519
527
const results = exports . filter ( ( name ) => name ) ;
520
528
529
+ if ( WASM_ESM_INTEGRATION ) {
530
+ return '// Runtime exports\nexport { ' + results . join ( ', ' ) + ' };\n' ;
531
+ }
532
+
521
533
if ( ASSERTIONS && ! EXPORT_ALL ) {
522
534
// in ASSERTIONS mode we show a useful error if it is used without being
523
535
// exported. See `unexportedRuntimeSymbol` in runtime_debug.js.
@@ -563,7 +575,7 @@ function exportLibrarySymbols() {
563
575
function exportJSSymbols ( ) {
564
576
// In WASM_ESM_INTEGRATION mode JS library symbols are marked with `export`
565
577
// at the point of declaration.
566
- if ( WASM_ESM_INTEGRATION ) return '' ;
578
+ if ( WASM_ESM_INTEGRATION ) return exportRuntimeSymbols ( ) ;
567
579
return exportRuntimeSymbols ( ) + ' ' + exportLibrarySymbols ( ) ;
568
580
}
569
581
0 commit comments