Description
Right now, it's already possible to hook into the file loading via locateFile
and provide URLs for JavaScript files, Workers, Wasm etc. After retrieving such a URL, Emscripten takes care of loading the actual resource in a hardcoded way depending on the environment (e.g. using XHR on the Web).
Problem is, many users use Emscripten output as part of larger Web apps using bundler tooling, which might offer optimisations such as code splitting, merging various resources together etc.
In this case, URL + XHR is no longer a sufficient combination for retrieving the contents back, as the only way to retrieve resources back is via custom APIs (e.g. import('some-loader!../path-to-resource')
syntax in Webpack). It's possible to opt-out of those APIs and preserve files as separate, but then user loses out on any optimisations offered by such tooling.
I propose that, in addition to locateFile(URL)
hook, Emscripten would provide a loadFile(URL)
hook as well, which would allow to customise the way a file is loaded and integrate better with arbitrary tooling and environments.