-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(es/transforms/module/commonjs): fix named exports overrides #2883
Merged
+105
−16
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
949ba8f
Adding test case for issue 2101.
JeremyGrieshop 30b0822
Merge branch 'swc-project:main' into issue-2101
JeremyGrieshop 8b4e172
Moving test files to appropriate crates.
JeremyGrieshop b779b73
Moving issue-2548 into the more appropriate testing create.
JeremyGrieshop f2cd5bc
Adding test case 2 for issue-2101.
JeremyGrieshop 320965b
Adding preliminary pass through each statement to gather a list of na…
JeremyGrieshop 7cb8114
Merge branch 'swc-project:main' into issue-2101
JeremyGrieshop 9a7fb76
Fixing test issue-1714.
JeremyGrieshop 8f29499
Merge branch 'main' into issue-2101
JeremyGrieshop 4306260
Removing clone() perf issuue.
JeremyGrieshop d790776
Merge branch 'main' into issue-2101
JeremyGrieshop 099a2ad
Merge branch 'main' into issue-2101
JeremyGrieshop a4bb682
Merge branch 'main' into issue-2101
JeremyGrieshop c5477e8
Merge branch 'main' into issue-2101
JeremyGrieshop 2002be2
Merge branch 'main' into issue-2101
kdy1 6591614
Merge branch 'main' into issue-2101
kdy1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_transforms_module/tests/fixture/commonjs/issue-2101/1/input.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 @@ | ||
import { customRender } from './customRender'; | ||
|
||
// re-export everything | ||
export * from '@testing-library/react'; | ||
|
||
// override render method | ||
export { customRender as render }; |
26 changes: 26 additions & 0 deletions
26
crates/swc_ecma_transforms_module/tests/fixture/commonjs/issue-2101/1/output.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,26 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _exportNames = { | ||
render: true | ||
}; | ||
Object.defineProperty(exports, "render", { | ||
enumerable: true, | ||
get: function() { | ||
return _customRender.customRender; | ||
} | ||
}); | ||
var _customRender = require("./customRender"); | ||
var _react = require("@testing-library/react"); | ||
Object.keys(_react).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _react[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _react[key]; | ||
} | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
crates/swc_ecma_transforms_module/tests/fixture/commonjs/issue-2101/2/input.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,9 @@ | ||
import { customRender } from './customRender'; | ||
|
||
// override render method | ||
export { customRender as render }; | ||
|
||
// re-ordering the export wildcard from case 1 should make no difference to output | ||
|
||
// re-export everything | ||
export * from '@testing-library/react'; |
26 changes: 26 additions & 0 deletions
26
crates/swc_ecma_transforms_module/tests/fixture/commonjs/issue-2101/2/output.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,26 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "render", { | ||
enumerable: true, | ||
get: function() { | ||
return _customRender.customRender; | ||
} | ||
}); | ||
var _exportNames = { | ||
render: true | ||
}; | ||
var _customRender = require("./customRender"); | ||
var _react = require("@testing-library/react"); | ||
Object.keys(_react).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _react[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _react[key]; | ||
} | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.
I think we don't need
clone()
.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.
I'm fairly new to Rust. Is there a better way to iterate a vector twice? Removing clone would cause the second iteration to fail.
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.
You can use
for item in &items
instead, as&Vec<T>
implementsIntoIterator<Item = &T>
.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.
Ah, thank you! One of these days, I will learn Rust properly.