Skip to content

Please explain why you are rebuilding wasm in postinstall. #4442

@huuyafwww

Description

@huuyafwww

Hello!
Thank you for developing the wonderful Sharp library.

I am currently using pnpm in my project, and while checking the lifecycle script,
I need some information to decide whether to allow Sharp's postinstall.
I have a question about one point.

I think sharp uses node-gyp during installation to rebuild the C# main body into wasm format using emscripten.

"install": "node install/check.js",

const status = spawnRebuild();

spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {

This means rebuilding all WASM files for each cross-platform. Is that correct?
Strictly speaking, I understand that it regenerates wasm corresponding to all packages under the src directory.
Furthermore, if that understanding is correct, there is a question.

For example, let's look at @img/sharp-darwin-arm64.
If you check the npm code, you will see that it contains lib/sharp-darwin-arm64.node.
My understanding is that the wasm output is included in the package.
https://www.npmjs.com/package/@img/sharp-darwin-arm64?activeTab=code

However, I don't understand why it needs to be rebuilt again during installation. Could you please explain?🙇‍♂️
This is just my guess, but I think they are rebuilding to generate the optimal wasm for each execution environment's runtime. Is that correct?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions