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

Block scope transform not included when targeting Safari 10 #6605

Closed
babel-bot opened this issue Sep 7, 2017 · 8 comments · Fixed by #10127
Closed

Block scope transform not included when targeting Safari 10 #6605

babel-bot opened this issue Sep 7, 2017 · 8 comments · Fixed by #10127
Labels
area: compat-table Has PR imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env

Comments

@babel-bot
Copy link
Collaborator

Issue originally reported by @ssilve1989 in babel/babel-preset-env#411

Specifying a target of "safari >= 10" doesn't use the transform-es2015-block-scoping plugin. Yet Safari 10 does need this because of this bug.

Ex:

{
  let a = 3
}

let a = 3

is an error in Safari 10.1.2 resulting in SyntaxError: Can't create duplicate variable that shadows a global property: 'a'.

I've had to manually include this plugin in the include option to get Safari working.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @existentialism

@ssilve1989 thanks for the report! since we source our mappings via compat-table, mind reporting this over there?

@babel-bot
Copy link
Collaborator Author

Comment originally made by @ssilve1989

@existentialism done

@wessberg
Copy link

This was resolved and merged in compat-table/compat-table#1183.

I just ran into this issue when using @babel/preset-env when testing on Safari 10.1.
Which surprises me given that @babel/preset-env is depending on a version of compat-data based on the following PR: compat-table/compat-table#1458.

@existentialism
Copy link
Member

existentialism commented Jun 23, 2019

@wessberg the compat table mapping shows:

https://github.com/kangax/compat-table/blob/gh-pages/data-es6.js#L561

safari10: null,
safari10_1: true,

So preset-env treats safari >= 10.1 as passing that test. I haven't tested (and it doesn't look like the author of PR tested it either), but if 10.1 doesn't pass, then we should update compat-table!

@wessberg
Copy link

wessberg commented Jun 23, 2019

I’ve made a simple repro: http://safari_10_1_repro.surge.sh/ with the following code:

function func(a = 1) {
    for (let a = 2; ;) {
        break;
    }
}
func();

I’ve tested it in Safari 10.1 and can confirm that it doesn’t work. We get SyntaxError: Cannot declare a let variable twice ‘a’.

Screen Shot 2019-06-23 at 12 38 38 PM

I have updated the old issue on the compat-table repository with this information. I hope we’ll get it resolved.

@existentialism
Copy link
Member

@wessberg thanks!

@wessberg
Copy link

It has been fixed and merged into compat-table!

@existentialism
Copy link
Member

@wessberg awesome, thank so much for getting that taken care of!

Just pushed: #10127

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compat-table Has PR imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants