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

Function declarations within blocks are transpiled into code that breaks on some pre-ES2015 targets #257

Open
anttikissa opened this issue May 6, 2020 · 0 comments

Comments

@anttikissa
Copy link

Prior to ES2015, function declarations within blocks were forbidden in strict mode (See MDN web docs):

(function() {
  'use strict';
  if (1) {
    function x() {
      // This results in "Strict mode does not allow function declarations in a
      // lexically nested statement" or a similar error in some older browsers
    }
  }
})();

(Sorry, I didn't have the weapons to test this myself, just consulted the and trust my colleague's report.)

We ran into this issue when we saw some some buble-transformed code crash on iOS 9 Safari.

Would it be within Bublé's scope to transform this into equivalent code that works? E.g.:

(function() {
  'use strict';
  if (1) {
    var x = function x() {
      // Tada!
    }
  }
})();
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