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
[systemjs] Fix nested let
/const
shadowing imported bindings
#14057
Merged
nicolo-ribaudo
merged 9 commits into
babel:main
from
The-x-Theorist:modules-systemjs-transformation
Mar 17, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
45f4c1f
Fix: modules-systemjs transformation
The-x-Theorist 8199f31
var declarations won't be renamed
The-x-Theorist 69c067b
check hoisted outside the for loop
The-x-Theorist a312fe2
TS warning fixed
The-x-Theorist 15714de
test added for destructuring
The-x-Theorist 6fe46d8
Improve TS types
nicolo-ribaudo 14e9cfd
Don't hoist let/const in blocks
nicolo-ribaudo aa5593e
Revert changes to `helper-hoist-variables`
nicolo-ribaudo aeb81ef
Add test
nicolo-ribaudo 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
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
9 changes: 9 additions & 0 deletions
9
...babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-let-const/input.mjs
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,9 @@ | ||
let l_foo = 1; | ||
const c_foo = 2; | ||
|
||
{ let l_foo, l_bar; const c_foo = 3; const c_bar = 4; } | ||
|
||
export { l_foo, c_foo }; | ||
|
||
export let l_bar = 4; | ||
export const c_bar = 6; |
23 changes: 23 additions & 0 deletions
23
...abel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-let-const/output.mjs
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,23 @@ | ||
System.register([], function (_export, _context) { | ||
"use strict"; | ||
|
||
var l_foo, c_foo, l_bar, c_bar; | ||
return { | ||
setters: [], | ||
execute: function () { | ||
_export("l_foo", l_foo = 1); | ||
|
||
_export("c_foo", c_foo = 2); | ||
|
||
{ | ||
let l_foo, l_bar; | ||
const c_foo = 3; | ||
const c_bar = 4; | ||
} | ||
|
||
_export("l_bar", l_bar = 4); | ||
|
||
_export("c_bar", c_bar = 6); | ||
} | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
...orm-modules-systemjs/test/fixtures/systemjs/module-level-variable-destructuring/input.mjs
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,8 @@ | ||
import { x } from './x.js'; | ||
|
||
if (true) { | ||
const { x } = { x: 1 }; | ||
console.log(x); | ||
} | ||
|
||
new (class extends x {})(); |
22 changes: 22 additions & 0 deletions
22
...rm-modules-systemjs/test/fixtures/systemjs/module-level-variable-destructuring/output.mjs
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,22 @@ | ||
System.register(["./x.js"], function (_export, _context) { | ||
"use strict"; | ||
|
||
var x; | ||
return { | ||
setters: [function (_xJs) { | ||
x = _xJs.x; | ||
}], | ||
execute: function () { | ||
if (true) { | ||
const { | ||
x | ||
} = { | ||
x: 1 | ||
}; | ||
console.log(x); | ||
} | ||
|
||
new class extends x {}(); | ||
} | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
...-plugin-transform-modules-systemjs/test/fixtures/systemjs/module-level-variable/input.mjs
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,8 @@ | ||
import { x } from './x.js'; | ||
|
||
if (true) { | ||
const x = 1; | ||
console.log(x); | ||
} | ||
|
||
new (class extends x {})(); |
18 changes: 18 additions & 0 deletions
18
...plugin-transform-modules-systemjs/test/fixtures/systemjs/module-level-variable/output.mjs
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,18 @@ | ||
System.register(["./x.js"], function (_export, _context) { | ||
"use strict"; | ||
|
||
var x; | ||
return { | ||
setters: [function (_xJs) { | ||
x = _xJs.x; | ||
}], | ||
execute: function () { | ||
if (true) { | ||
const x = 1; | ||
console.log(x); | ||
} | ||
|
||
new class extends x {}(); | ||
} | ||
}; | ||
}); |
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.
A top level var declaration can be nested within for statement:
or it could be within a do expression.
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.
They already have
var
, there is no need to manually change them.