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

The package is not tree-shakeable due to side-effects #254

Open
0x009922 opened this issue May 30, 2022 · 0 comments · May be fixed by #255
Open

The package is not tree-shakeable due to side-effects #254

0x009922 opened this issue May 30, 2022 · 0 comments · May be fixed by #255

Comments

@0x009922
Copy link

0x009922 commented May 30, 2022

Description

body-scroll-lock package has side-effects, thus it cannot be fully tree-shaken.

Reproduction

You can explore tree-shaking sample at rollup repl.

Expected

Expected to see in the output only my console.log

Actual

// http-url:https://unpkg.com/body-scroll-lock@latest/lib/bodyScrollLock.esm.js
var hasPassiveEvents = false;
if (typeof window !== "undefined") {
  passiveTestOptions = {
    get passive() {
      hasPassiveEvents = true;
      return void 0;
    }
  };
  window.addEventListener("testPassive", null, passiveTestOptions);
  window.removeEventListener("testPassive", null, passiveTestOptions);
}
var passiveTestOptions;
var isIosDevice = typeof window !== "undefined" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1);

// /input.tsx
console.log("my side effects");
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 a pull request may close this issue.

1 participant