Use new URL(..., import.meta.url) pattern in minimal runtime if EXPORT_ES6 is enabled#26039
Conversation
311043c to
af94025
Compare
|
Ignore Copilot; GitHub auto-enabled that setting for my account 🙃 |
There was a problem hiding this comment.
Pull request overview
This PR adds support for bundler-friendly new URL(..., import.meta.url) pattern in minimal runtime when EXPORT_ES6 is enabled, specifically for the MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION feature. This enables better integration with modern bundlers like Vite that recognize and transform this pattern.
- Introduces conditional logic to use
new URL()pattern when bothEXPORT_ES6andMINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATIONare enabled - Adds test to verify the generated code contains the expected URL pattern
- Handles special case for Audio Worklet environments where
new URL()cannot be used
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/postamble_minimal.js | Adds preprocessor directives to conditionally generate new URL() pattern for wasm module loading based on ES6 and Audio Worklet settings |
| test/test_other.py | Adds test to verify that ES6 modules with streaming instantiation generate correct URL resolution using import.meta.url |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
af94025 to
13afe52
Compare
|
cc @RReverser |
test/test_other.py
Outdated
There was a problem hiding this comment.
We have test_vite in test_browser.py what should be able to not only test that this string exists but that it works in the vite bundler.
IIUC we could add a variant of that test that uses -sMINIMAL_RUNTIME -sMINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION ?
There was a problem hiding this comment.
I've added a test for Vite. Should I keep this one as well?
There was a problem hiding this comment.
Probably not worth keeping this one too
| '-o', | ||
| 'hello.mjs']) | ||
| self.run_process(shared.get_npm_cmd('vite') + ['build']) | ||
| self.run_browser('dist/index.html', '/report_result?exit:0') |
There was a problem hiding this comment.
Rather than adding a new test here you should be able to using @parameterize.
Something like:
@parameterized({
'': ([],),
'minimal': (['-sMINIMAL_RUNTIME', '-sMINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION'],),
})
def test_vite_minimal_runtime(self, args):
(then add args to the compile_btest arguments).
test/test_browser.py
Outdated
There was a problem hiding this comment.
Can you confirm this test fails before this PR, and passes after?
There was a problem hiding this comment.
Manually confirmed the (newly @parameterized) test fails without the changes made in this PR.
fbb38c2 to
62edd26
Compare
|
CI seems to be green now; I think it was an issue with the autogenerated copyright date. Anything holding this up? |
…PORT_ES6` is enabled (emscripten-core#26039) This should make it possible to use `MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION` with [bundlers like Vite](https://vite.dev/guide/assets) that recognize and transform `new URL('...', import.meta.url)`.
This should make it possible to use
MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATIONwith bundlers like Vite that recognize and transformnew URL('...', import.meta.url).