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

Make module namespace sort compare function consistent #14287

Merged
merged 1 commit into from Feb 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/babel-helper-module-transforms/src/index.ts
Expand Up @@ -449,7 +449,11 @@ function buildExportInitializationStatements(
// https://tc39.es/ecma262/#sec-module-namespace-exotic-objects
// The [Exports] list is ordered as if an Array of those String values
// had been sorted using %Array.prototype.sort% using undefined as comparefn
initStatements.sort((a, b) => (a[0] > b[0] ? 1 : -1));
initStatements.sort(([a], [b]) => {
if (a < b) return -1;
if (b < a) return 1;
return 0;
});

const results = [];
if (noIncompleteNsImportDetection) {
Expand Down