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

Setting moduleSideEffects: false removes side effectful getter inside a exported function since 4.9.2 #5408

Open
sapphi-red opened this issue Mar 1, 2024 · 2 comments

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented Mar 1, 2024

Rollup Version

4.12.0 (since 4.9.2)

Operating System (or Browser)

StackBlitz

Node Version (if applicable)

No response

Link To Reproduction

https://stackblitz.com/edit/rollup-repro-3brsqu?file=src%2FsupportsPassive.js,dist%2Fmain.js

Expected Behaviour

supportsPassive is not removed.

const supportsPassive = (() => {
  // simular to jQuery's test
  let supported = false;
  try {
    addEventListener(
      'test',
      () => {
        // do nothing
      },
      Object.defineProperty({}, 'passive', {
        get() {
          supported = true;
          return true;
        },
      })
    );
  } catch (e) {
    // do nothing
  }
  return supported;
})();

class TouchBackendImpl {
  addEventListener() {
    const options = supportsPassive ? { capture, passive: false } : capture;
    console.log(options);
  }
}

export { TouchBackendImpl };

Actual Behaviour

supportsPassive is removed;

class TouchBackendImpl {
  addEventListener() {
    const options = capture;
    console.log(options);
  }
}

export { TouchBackendImpl };

Additional Information

This happens with 4.9.2 and doesn't happen with 4.9.1. I guess #5322 is related.

Original issue: vitejs/vite#16065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants