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
Fix commonjs exports with destructuring. #5469
Merged
jridgewell
merged 13 commits into
babel:master
from
yavorsky:fix-commonjs-destructuring
Jun 21, 2017
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f81d749
Fix exports while destructuring.
yavorsky 9b410be
Add test for exports destructuring.
yavorsky 0c2e3b1
Remove exports definition.
yavorsky b5bb89b
Add array pattern to exports destructuring.
yavorsky 06f67e1
Consider default parameters for array pattern.
yavorsky b608e28
Consider rest params for array pattern in exports.
yavorsky 45b4174
Consider default params for object pattern.
yavorsky c82b084
Fix object rest params for exports.
yavorsky 18d6ba9
Fix export array rest expected output.
yavorsky c42e027
Add object rest spread syntax using plugin.
yavorsky 7035401
Fix visitor inheritance.
yavorsky ddfb6f2
Remove object-rest-spread syntax.
yavorsky f2f226b
Add syntax-object-rest-spread as devDep for tests.
yavorsky File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
1 change: 1 addition & 0 deletions
1
...s-commonjs/test/fixtures/strict/export-const-destructuring-array-default-params/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 @@ | ||
export const [foo, bar = 2] = []; |
5 changes: 5 additions & 0 deletions
5
...commonjs/test/fixtures/strict/export-const-destructuring-array-default-params/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 @@ | ||
"use strict"; | ||
|
||
const [foo, bar = 2] = []; | ||
exports.foo = foo; | ||
exports.bar = bar; |
1 change: 1 addition & 0 deletions
1
...015-modules-commonjs/test/fixtures/strict/export-const-destructuring-array-rest/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 @@ | ||
export const [foo, bar, ...baz] = []; |
6 changes: 6 additions & 0 deletions
6
...5-modules-commonjs/test/fixtures/strict/export-const-destructuring-array-rest/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,6 @@ | ||
"use strict"; | ||
|
||
const [foo, bar, ...baz] = []; | ||
exports.foo = foo; | ||
exports.bar = bar; | ||
exports.baz = baz; |
1 change: 1 addition & 0 deletions
1
...m-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-array/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 @@ | ||
export const [foo, bar] = []; |
5 changes: 5 additions & 0 deletions
5
...es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-array/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 @@ | ||
"use strict"; | ||
|
||
const [foo, bar] = []; | ||
exports.foo = foo; | ||
exports.bar = bar; |
1 change: 1 addition & 0 deletions
1
...-commonjs/test/fixtures/strict/export-const-destructuring-object-default-params/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 @@ | ||
export const { foo, bar = 1 } = {}; |
5 changes: 5 additions & 0 deletions
5
...ommonjs/test/fixtures/strict/export-const-destructuring-object-default-params/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 @@ | ||
"use strict"; | ||
|
||
const { foo, bar = 1 } = {}; | ||
exports.foo = foo; | ||
exports.bar = bar; |
1 change: 1 addition & 0 deletions
1
...-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object/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 @@ | ||
export const { foo: bar, baz } = {}; |
5 changes: 5 additions & 0 deletions
5
...s2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object/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 @@ | ||
"use strict"; | ||
|
||
const { foo: bar, baz } = {}; | ||
exports.bar = bar; | ||
exports.baz = baz; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be handling
ArrayPattern
too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@loganfsmyth Sure! Going to add. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the
ArrayPattern
be a separate PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xtuc I've started work on it but could pick it out to a separate PR