Skip to content

There should be a way to disable sideEffects: false #972

Closed
@RReverser

Description

@RReverser

🐛 Bug description

Custom JS snippets can contain top-level side-effects. Right now, wasm-pack generated package.json includes sideEffects: false which marks every file as side-effect free, leading to potential bugs after bundling.

🤔 Expected Behavior

When JS snippet files are generated, they should be put into the sideEffects array, and only the JS file generated by wasm-bindgen should be assumed to be side-effect free since it's the only one wasm-bindgen has control over.

package.json allows to list potentially side-effect-y files as

{
  "sideEffects": [
    "path/to/snippet.js"
  ]
}

This will avoid bugs for snippets with top-level side-effects, while it won't decrease optimization level for common scenarios where the module is used via its main entry point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions