Skip to content

Commit 216c3da

Browse files
committed
fix ExportsInfo
1 parent cb639b3 commit 216c3da

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

lib/ExportsInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ class ExportsInfo {
584584
if (info.exportsInfo && name.length > 1) {
585585
return info.exportsInfo.isExportProvided(name.slice(1));
586586
}
587-
return info.provided;
587+
return info.provided ? name.length === 1 || undefined : info.provided;
588588
}
589589
const info = this.getReadOnlyExportInfo(name);
590590
return info.provided;

test/cases/parsing/harmony-export-import-specifier/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { b1, usedB1, usedB2, usedB3, usedB4 } from "./b.js";
66
import { usedE1, usedE2 } from "./e.js";
77
import { h } from "./h.js";
88
import * as m from "./m";
9+
import {object as obj} from "./m";
910
import * as o from "./o";
1011
import * as p from "./p";
1112
import * as q from "./q";
@@ -45,6 +46,8 @@ it("complex case should work correctly", () => {
4546
it("should handle 'm in n' case", () => {
4647
const obj = { aaa: "aaa" in m };
4748
expect(obj.aaa).toBe(true);
49+
expect("not_here" in m.object).toBe(false);
50+
expect("not_here" in obj).toBe(false);
4851
expect("aaa" in o).toBe(true);
4952
expect("aaa" in p).toBe(false);
5053
expect("ccc" in m).toBe(false);

test/cases/parsing/harmony-export-import-specifier/m.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const aaa = 1;
22
export const bbb = 2;
3+
export const object = {};
34
export * as ddd from "./n";
45
export const usedA = __webpack_exports_info__.aaa.used;
56
export const canMangleA = __webpack_exports_info__.ccc.canMangle;

test/cases/parsing/harmony-reexport/a.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ import { b } from "./b";
33
export function a() {
44
return b();
55
}
6+
export const obj = {};
67
export const aUsed = __webpack_exports_info__.a.used;
78
export const aProvided = __webpack_exports_info__.a.provideInfo;
9+
export const objUsed = __webpack_exports_info__.obj.used;
10+
export const objAProvided = __webpack_exports_info__.obj.A.provideInfo;
11+
export const aToStringProvided = __webpack_exports_info__.a.toString.provideInfo;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { a, aUsed, aCanBeMangled, aProvided } from "./reexport";
1+
import { a, aUsed, aCanBeMangled, aProvided, aToStringProvided, obj, objUsed, objAProvided } from "./reexport";
22

3-
if (a()) console.log("a");
3+
if (a()) console.log("a", obj);
44

55
it("should not allow mangle if some exports are unknown", () => {
66
expect(aUsed).toBe(true);
77
expect(aProvided).toBe(true);
88
expect(aCanBeMangled).toBe(false);
9+
expect(objUsed).toBe(true);
10+
expect(objAProvided).toBe(undefined);
11+
expect(aToStringProvided).toBe(undefined);
912
});

0 commit comments

Comments
 (0)