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

Use asynchronous wasm instantiation methods where possible #174

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Dec 4, 2024

This fixes a problem (introduced in #167) on Chrome, which would complain about the module being too big. It also significantly simplifies the code on the browser entry points, because instantiateStreaming is widely supported.

@richvdh richvdh requested a review from a team as a code owner December 4, 2024 17:57
@richvdh richvdh requested review from Hywan and sandhose December 4, 2024 17:57
@richvdh richvdh mentioned this pull request Dec 4, 2024
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed the tsconfig so that tsc actually check JS files in #176. You should probably rebase on that and check that everything typechecks

index.js Outdated Show resolved Hide resolved
node.mjs Outdated Show resolved Hide resolved
node.mjs Outdated Show resolved Hide resolved
node.mjs Show resolved Hide resolved
node.mjs Outdated Show resolved Hide resolved
index.mjs Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.mjs Outdated Show resolved Hide resolved
@richvdh
Copy link
Member Author

richvdh commented Dec 7, 2024

I've fixed the tsconfig so that tsc actually check JS files in #176. You should probably rebase on that and check that everything typechecks

Will do, but you need to fix the CI for it first ;)

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@sandhose
Copy link
Member

sandhose commented Dec 10, 2024

I've merged #176, I merged back main on this PR fixing the conflicts

instance.exports.__wbindgen_start();
initialised = true;
return instance.exports;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was rather thinking that returning this here would reduce the number of @ts-expect-errors we needed, but 🤷

node.js Outdated Show resolved Hide resolved
node.mjs Outdated Show resolved Hide resolved
... because I keep getting confused
Currently, every call to `loadModuleSync` or `loadModuleAsync` in the node
entry points has to be followed by a call to `initInstance`. This change moves
that call into `loadModule[A]sync` instead.

This (a) brings the node code more into line with the browser code; (b) lays
groundwork for the future where I want to move bits of `initInstance` into `loadModule[A]sync`.
This fixes a problem on Chrome, which would complain about the module being too
big. It also significantly simplifies the code on the browser entry points,
because `instantiateStreaming` is widely supported.
@richvdh richvdh force-pushed the rav/async_instantiate branch from 9c45cdf to 91ae6a2 Compare December 10, 2024 17:26
@richvdh richvdh enabled auto-merge (squash) December 10, 2024 17:26
@richvdh richvdh merged commit 68c75e5 into main Dec 10, 2024
3 checks passed
@richvdh richvdh deleted the rav/async_instantiate branch December 10, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants