forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform do-expressions on exit (babel#5694)
* Transform do-expressions on exit This allows other transforms (notably, block scoping) to do their magic first, possibly saving closures. Also fixes a bug with declaring duplicate bindings (de-opts now). * Use strict in exec test * lint
- Loading branch information
1 parent
c474fd4
commit 8cd4a62
Showing
5 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/babel-plugin-transform-do-expressions/test/fixtures/do-expressions/block-scope.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
|
||
let a = 1; | ||
|
||
(do { | ||
let a = 2; | ||
assert.equal(a, 2); | ||
}); | ||
assert.equal(a, 1); | ||
|
7 changes: 7 additions & 0 deletions
7
.../babel-plugin-transform-do-expressions/test/fixtures/do-expressions/block-scope/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let a = 1; | ||
|
||
(do { | ||
let a = 2; | ||
a; | ||
}); | ||
|
5 changes: 5 additions & 0 deletions
5
...abel-plugin-transform-do-expressions/test/fixtures/do-expressions/block-scope/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var _a; | ||
|
||
var a = 1; | ||
|
||
_a = 2, _a; |
3 changes: 3 additions & 0 deletions
3
...bel-plugin-transform-do-expressions/test/fixtures/do-expressions/block-scope/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["transform-es2015-block-scoping", "transform-do-expressions"] | ||
} |