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 URL to get path to wasm asset #104

Merged
merged 1 commit into from
Sep 7, 2023
Merged

Use URL to get path to wasm asset #104

merged 1 commit into from
Sep 7, 2023

Conversation

freaz
Copy link
Member

@freaz freaz commented Sep 6, 2023

As follow up to findings from POD and how Webpack resolves paths to assets, this changes require.resolve to URL, to get path to core wasm asset.

It should work better with bundlers, but keep working the same when used without.

I also moved it to common, as it feels more generic, then just specific to Node.js. Even though it can't be used in CF worker.

Copy link
Contributor

@TheEdward162 TheEdward162 left a comment

Choose a reason for hiding this comment

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

Did you test this with the cloudflare example? It errors for me with Could not resolve "node:fs/promises" when I run wrangler dev or wrangler publish due to the wasm.js file being reachable from common.

@freaz
Copy link
Member Author

freaz commented Sep 6, 2023

Thanks. I did not try it. Also reason why it was in Node in the first place. I now kept just the function to get path to was in common, so every platform loads it as it suites it.

Copy link
Contributor

@TheEdward162 TheEdward162 left a comment

Choose a reason for hiding this comment

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

It's a shame we can't utilize the corePath function in cloudflare/esm import too, but that's just a dream.

@freaz
Copy link
Member Author

freaz commented Sep 7, 2023

I guess we could use async import or require.resolve with it, but not sure if it is better.

@freaz freaz merged commit 1201f66 into main Sep 7, 2023
4 checks passed
@freaz freaz deleted the feat/use_url_to_wasm branch September 7, 2023 09:46
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.

2 participants