()
| 2452 | |
| 2453 | |
| 2454 | def modularize(): |
| 2455 | global final_js |
| 2456 | logger.debug(f'Modularizing, creating factory function called `{settings.EXPORT_NAME}`') |
| 2457 | modularize_src = building.read_and_preprocess(utils.path_from_root('src/modularize.js'), expand_macros=True) |
| 2458 | if settings.MINIFY_WHITESPACE: |
| 2459 | with shared.get_temp_files().get_file(suffix='.js') as tmp: |
| 2460 | write_file(tmp, modularize_src) |
| 2461 | minified_file = building.acorn_optimizer(tmp, ['--minify-whitespace']) |
| 2462 | modularize_src = read_file(minified_file) |
| 2463 | |
| 2464 | # Replace INNER_JS_CODE in the minified code |
| 2465 | full_src = do_replace(modularize_src, '"<<< INNER_JS_CODE >>>"', read_file(final_js)) |
| 2466 | final_js += '.modular.js' |
| 2467 | write_file(final_js, full_src) |
| 2468 | shared.get_temp_files().note(final_js) |
| 2469 | save_intermediate('modularized') |
| 2470 | |
| 2471 | # FIXME(https://github.com/emscripten-core/emscripten/issues/24558): Running acorn at this |
| 2472 | # late phase seems to cause OOM (some kind of infinite loop perhaps) in node. |
| 2473 | # Instead we minify src/modularize.js in isolation above. |
| 2474 | # if settings.MINIFY_WHITESPACE: |
| 2475 | # final_js = building.acorn_optimizer(final_js, ['--minify-whitespace']) |
| 2476 | |
| 2477 | |
| 2478 | def module_export_name_substitution(): |
no test coverage detected