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

Recursive function uses itself and not gets removed by tree-shaking #1142

Closed
danez opened this issue Dec 13, 2016 · 1 comment · Fixed by #1143
Closed

Recursive function uses itself and not gets removed by tree-shaking #1142

danez opened this issue Dec 13, 2016 · 1 comment · Fixed by #1143

Comments

@danez
Copy link
Contributor

danez commented Dec 13, 2016

When having a function that calls itself, it is not removed by tree-shaking. Seems this happens because the Node gets activated, at least that's were I ended debugging.

Input

var set = function set(object) {
   object.value = value;

   set(Object.getPrototypeOf(object));
};

Expected output

'use strict';

Current output

'use strict';

var set = function set(object) {
   object.value = value;

   set(Object.getPrototypeOf(object));
};

Example

http://rollupjs.org/?version=0.37.0&shareable=JTdCJTIyb3B0aW9ucyUyMiUzQSU3QiUyMmZvcm1hdCUyMiUzQSUyMmNqcyUyMiUyQyUyMm1vZHVsZU5hbWUlMjIlM0ElMjJteUJ1bmRsZSUyMiUyQyUyMmdsb2JhbHMlMjIlM0ElN0IlN0QlN0QlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIybmFtZSUyMiUzQSUyMm1haW4uanMlMjIlMkMlMjJjb2RlJTIyJTNBJTIydmFyJTIwc2V0JTIwJTNEJTIwZnVuY3Rpb24lMjBzZXQob2JqZWN0KSUyMCU3QiU1Q24lMjAlMjAlMjBvYmplY3QudmFsdWUlMjAlM0QlMjB2YWx1ZSUzQiU1Q24lNUNuJTIwJTIwJTIwc2V0KE9iamVjdC5nZXRQcm90b3R5cGVPZihvYmplY3QpKSUzQiU1Q24lN0QlM0IlMjIlN0QlNUQlN0Q=

Environment

rollup: 0.37
node: 6.9.1
os: macOS 10.11

I can help to fix it, but I'm not sure where to start. I debugged a testcase with this input-code, but I'm not sure where the whole activation happens, and how the Node could detect that it got activated by itself.

@kzc
Copy link
Contributor

kzc commented Dec 14, 2016

Does this patch help?

#1120 (comment)

Edit: I just tried it on your example. It seems to work.

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.

2 participants