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

[v3] treeshake unexpectedly assumed "a" in b==b.a != null #4680

Closed
liuxingbaoyu opened this issue Oct 17, 2022 · 4 comments · Fixed by #4684
Closed

[v3] treeshake unexpectedly assumed "a" in b==b.a != null #4680

liuxingbaoyu opened this issue Oct 17, 2022 · 4 comments · Fixed by #4684

Comments

@liuxingbaoyu
Copy link

liuxingbaoyu commented Oct 17, 2022

Rollup Version

3.2.2

Operating System (or Browser)

all

Node Version (if applicable)

14-18

Link To Reproduction

repl

Expected Behaviour

/* TREE-SHAKING */
import * as virtualTypes from "./virtual-types";

function isVirtualType(type) {
  return type in virtualTypes;
}

function explode(type) {
  if(!(type in virtualTypes))return;

  const types = virtualTypes[type]

  if(virtualTypes[type] != null){
    // here ↑
    for (const type of types) {
      if (visitor[type]) {
        mergePair(visitor[type], fns);
      }
    }
  }
}

var visitors = /*#__PURE__*/Object.freeze({
  __proto__: null,
  explode: explode,
  verify: verify,
  merge: merge
});

Actual Behaviour

'use strict';

const a=[];

var virtualTypes = /*#__PURE__*/Object.freeze({
  __proto__: null,
  a: a
});

/* TREE-SHAKING */

function explode(type) {
  if(!(type in virtualTypes))return;

  const types = virtualTypes[type];

  {
    // here ↑
    for (const type of types) {
      if (visitor[type]) {
        mergePair(visitor[type], fns);
      }
    }
  }
}

/*#__PURE__*/Object.freeze({
  __proto__: null,
  explode: explode,
  verify: verify,
  merge: merge
});
@liuxingbaoyu liuxingbaoyu changed the title treeshake unexpectedly assumed a in b==b.a != null treeshake unexpectedly assumed "a" in b==b.a != null Oct 17, 2022
@liuxingbaoyu liuxingbaoyu changed the title treeshake unexpectedly assumed "a" in b==b.a != null [v3] treeshake unexpectedly assumed "a" in b==b.a != null Oct 17, 2022
@liuxingbaoyu
Copy link
Author

Thanks!

@rollup-bot
Copy link
Collaborator

This issue has been resolved via #4684 as part of rollup@3.2.3. You can test it via npm install rollup.

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

Successfully merging a pull request may close this issue.

3 participants