Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay processing of extern-pre-js and extern-post-js files #23268

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,6 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915
options.post_js.append(utils.path_from_root('src/threadprofiler.js'))
settings.REQUIRED_EXPORTS.append('emscripten_main_runtime_thread_id')

options.extern_pre_js = read_js_files(options.extern_pre_js)
options.extern_post_js = read_js_files(options.extern_post_js)

# TODO: support source maps with js_transform
if options.js_transform and settings.GENERATE_SOURCE_MAP:
logger.warning('disabling source maps because a js transform is being done')
Expand Down Expand Up @@ -2158,13 +2155,15 @@ def phase_final_emitting(options, state, target, wasm_target):

# Apply pre and postjs files
if options.extern_pre_js or options.extern_post_js:
extern_pre_js = read_js_files(options.extern_pre_js)
extern_post_js = read_js_files(options.extern_post_js)
logger.debug('applying extern pre/postjses')
src = read_file(final_js)
final_js += '.epp.js'
with open(final_js, 'w', encoding='utf-8') as f:
f.write(options.extern_pre_js)
f.write(extern_pre_js)
f.write(src)
f.write(options.extern_post_js)
f.write(extern_post_js)
save_intermediate('extern-pre-post')

js_manipulation.handle_license(final_js)
Expand Down
Loading