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

All call parameters are treeshaken with tryCatchDeoptimization: false #2913

Closed
manucorporat opened this issue Jun 9, 2019 · 1 comment · Fixed by #2914
Closed

All call parameters are treeshaken with tryCatchDeoptimization: false #2913

manucorporat opened this issue Jun 9, 2019 · 1 comment · Fixed by #2914

Comments

@manucorporat
Copy link
Contributor

manucorporat commented Jun 9, 2019

  • Rollup Version: 1.14.5
  • Operating System (or Browser): osx
  • Node Version: 12.0.0

How Do We Reproduce?

index.js

function foo(bar) {
  bar.prop = 12;
}
function main(obj) {
  try {
    foo(obj);
  } catch (e) {
    console.error(e);
  }
}
main({});

rollup.config.js

export default {
  input: 'index.js',
  treeshake: {
    tryCatchDeoptimization: false,
  },
  output: {
    format: 'es',
    file: 'output.js'
  }
};

Also, included a small repo case, just:

rollup-bug.zip

npm i
npm run build

and inspect the output.js file

Expected Behavior

The parameter passed to the foo functions should not be treeshaken, since it's actually used.

function main(obj) {
  try {
    foo(obj);
  } catch (e) {
    console.error(e);
  }
}

Actual Behavior

function main(obj) {
  try {
    foo();
  } catch (e) {
    console.error(e);
  }
}

making it crash at runtime, since foo expects an argument

@lukastaegert
Copy link
Member

Fix at #2914. Turns out it was a simple oversight in TryStatement that could have caused even more mayhem, thanks for spotting and reporting it!

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.

2 participants