-
Notifications
You must be signed in to change notification settings - Fork 27
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
Implement externalized WASM build #98
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 7c74749.
I'm still curious how the |
@mochaaP I tried to grok the code and perhaps come with an explanation myself, but to no avail. Adding some docs (README? Comment block in code?) would probably help any future maintainer to understand what we are trying to archive here and why it's done in this specific way. @guybedford Aside – thanks for the patience with this change, I really appreciate it! |
Added comments to explain the load process. If something is still unclear, please point it out :) |
@mochaaP thanks for adding comments, my question though specifically is how you are hooking the |
To clear some confusion: fs.readFile is not hooked -- instead there are two flavors: CJS and ESM. The CJS flavor inlines the WASM binary as a base64 string. This is what libnode bundles, and it won't be published to npm (or not exported by package.json). The ESM flavor assumes this module is properly installed as a package, and reads the WASM binary from a relative path. (Sorry for the late reply. I was working on other projects previously.) |
This is the part I still do not understand properly - you mean it is loaded relative to the Node.js binary itself? Why would we want to ship a Node.js binary that loads another separate Wasm file at runtime? |
Normal Node.js distribution will only inline the CJS flavor, since it's not installed as a module. (i.e. have full filesystem structure, If one opts in to use the ESM flavor, it means the module has a place on the filesystem, thus we are able to resolve a WASM file relative to |
An alternative to #97.
See #96 for more info.