Skip to content

Commit 90c1c8a

Browse files
authored
Merge pull request #15437 from webpack/fix/issue-11871
fix imports order
2 parents 4abf353 + 8e6f006 commit 90c1c8a

4 files changed

Lines changed: 36 additions & 1 deletion

File tree

lib/dependencies/HarmonyExportInitFragment.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ class HarmonyExportInitFragment extends InitFragment {
145145
? `/* unused harmony export ${first(this.unusedExports)} */\n`
146146
: "";
147147
const definitions = [];
148-
for (const [key, value] of this.exportMap) {
148+
const orderedExportMap = Array.from(this.exportMap).sort(([a], [b]) =>
149+
a < b ? -1 : 1
150+
);
151+
for (const [key, value] of orderedExportMap) {
149152
definitions.push(
150153
`\n/* harmony export */ ${JSON.stringify(
151154
key
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const W = "w";
2+
export const A = "a";
3+
export const a = "a";
4+
export const _12 = "12";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as values from "./a.js";
2+
3+
it("imports should have correct order", () => {
4+
expect(Object.keys(values)).toEqual(["A", "W", "_12", "a"])
5+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use strict";
2+
3+
/** @type {import("../../../../").Configuration[]} */
4+
module.exports = [
5+
{
6+
mode: "development"
7+
},
8+
{
9+
mode: "production"
10+
},
11+
{
12+
mode: "production",
13+
optimization: {
14+
concatenateModules: false
15+
}
16+
},
17+
{
18+
mode: "development",
19+
optimization: {
20+
concatenateModules: true
21+
}
22+
}
23+
];

0 commit comments

Comments
 (0)