@@ -2325,23 +2325,15 @@ def modularize():
2325
2325
if async_emit != '' and settings .EXPORT_NAME == 'config' :
2326
2326
diagnostics .warning ('emcc' , 'EXPORT_NAME should not be named "config" when targeting Safari' )
2327
2327
2328
- src = '''
2329
- %(maybe_async)sfunction(moduleArg = {}) {
2330
-
2331
- %(src)s
2332
-
2333
- return %(return_value)s
2334
- }
2335
- ''' % {
2336
- 'maybe_async' : async_emit ,
2337
- 'src' : src ,
2338
- 'return_value' : return_value ,
2339
- }
2340
-
2341
2328
if settings .MINIMAL_RUNTIME and not settings .PTHREADS :
2342
2329
# Single threaded MINIMAL_RUNTIME programs do not need access to
2343
2330
# document.currentScript, so a simple export declaration is enough.
2344
- src = '/** @nocollapse */ var %s = %s' % (settings .EXPORT_NAME , src )
2331
+ src = f'''\
2332
+ var { settings .EXPORT_NAME } = { async_emit } (moduleArg = {{}}) => {{
2333
+ { src }
2334
+ return { return_value } ;
2335
+ }};
2336
+ '''
2345
2337
else :
2346
2338
script_url_node = ''
2347
2339
# When MODULARIZE this JS may be executed later,
@@ -2355,19 +2347,14 @@ def modularize():
2355
2347
script_url = "typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined"
2356
2348
if shared .target_environment_may_be ('node' ):
2357
2349
script_url_node = "if (typeof __filename !== 'undefined') _scriptDir ||= __filename;"
2358
- src = '''%(node_imports)s
2359
- var %(EXPORT_NAME)s = (() => {
2360
- var _scriptDir = %(script_url)s;
2361
- %(script_url_node)s
2362
- return (%(src)s);
2363
- })();
2364
- ''' % {
2365
- 'node_imports' : node_es6_imports (),
2366
- 'EXPORT_NAME' : settings .EXPORT_NAME ,
2367
- 'script_url' : script_url ,
2368
- 'script_url_node' : script_url_node ,
2369
- 'src' : src ,
2370
- }
2350
+ src = f'''{ node_es6_imports ()}
2351
+ var { settings .EXPORT_NAME } = { async_emit } (moduleArg = {{}}) => {{
2352
+ var _scriptDir = { script_url } ;
2353
+ { script_url_node }
2354
+ { src }
2355
+ return { return_value } ;
2356
+ }};
2357
+ '''
2371
2358
# Given the async nature of how the Module function and Module object
2372
2359
# come into existence in AudioWorkletGlobalScope, store the Module
2373
2360
# function under a different variable name so that AudioWorkletGlobalScope
@@ -2378,14 +2365,14 @@ def modularize():
2378
2365
2379
2366
# Export using a UMD style export, or ES6 exports if selected
2380
2367
if settings .EXPORT_ES6 :
2381
- src += 'export default %s;' % settings .EXPORT_NAME
2368
+ src += f 'export default { settings .EXPORT_NAME } ;'
2382
2369
elif not settings .MINIMAL_RUNTIME :
2383
- src += '''\
2370
+ src += f '''
2384
2371
if (typeof exports === 'object' && typeof module === 'object')
2385
- module.exports = %( EXPORT_NAME)s ;
2372
+ module.exports = { settings . EXPORT_NAME } ;
2386
2373
else if (typeof define === 'function' && define['amd'])
2387
- define([], () => %( EXPORT_NAME)s );
2388
- ''' % { 'EXPORT_NAME' : settings . EXPORT_NAME }
2374
+ define([], () => { settings . EXPORT_NAME } );
2375
+ '''
2389
2376
2390
2377
final_js += '.modular.js'
2391
2378
write_file (final_js , src )
0 commit comments