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

does not remove imports that belongs to dead code which is removed by common-shake #19

Open
nikhildpawar opened this issue Oct 25, 2018 · 1 comment

Comments

@nikhildpawar
Copy link

Thanks for the efforts. This plugin works great. I will try to explain the case i came across.

"index.es6" imports {Storage} from "abc" which intern import {Cookie} from "xyz".
"abc" is using {Cookie} from "xyz". But Index.es6 is not using {Storage} from "abc". Now common-shake is removing {Storage} from the code but {Cookie} remains in the output file. If I remove reference to {Cookie} from abc then common-shake is removing {Cookie} as well.

Here is the file structure

index.es6

import {Storage} from "./abc";
console.log("this is an example");

abc.es6

import {Cookie} from "./xyz";

export var Storage = function(){
}
Storage.prototype = {
  getCookie: function(){
    let cookie = new Cookie(); // if i remove this line then common-shake removes Cookie from the output
  }
}

xyz.es6

export var Cookie= function(){
}

Cookie.prototype = {
  readCookie: function(){
     console.log("reading cookie");
  }
}
@goto-bus-stop
Copy link
Member

Sorry I missed this. The reason for this is that common-shake doesn't know that the Storage.prototype assignment is related to the exports.Storage export. I don't think that'll be easy to solve, it would require much more sophisticated analysis than common-shake can do currently.

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

2 participants