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

fix ExportsInfo #15634

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/ExportsInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ class ExportsInfo {
if (info.exportsInfo && name.length > 1) {
return info.exportsInfo.isExportProvided(name.slice(1));
}
return info.provided;
return info.provided ? name.length === 1 || undefined : info.provided;
}
const info = this.getReadOnlyExportInfo(name);
return info.provided;
Expand Down
3 changes: 3 additions & 0 deletions test/cases/parsing/harmony-export-import-specifier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { b1, usedB1, usedB2, usedB3, usedB4 } from "./b.js";
import { usedE1, usedE2 } from "./e.js";
import { h } from "./h.js";
import * as m from "./m";
import {object as obj} from "./m";
import * as o from "./o";
import * as p from "./p";
import * as q from "./q";
Expand Down Expand Up @@ -45,6 +46,8 @@ it("complex case should work correctly", () => {
it("should handle 'm in n' case", () => {
const obj = { aaa: "aaa" in m };
expect(obj.aaa).toBe(true);
expect("not_here" in m.object).toBe(false);
expect("not_here" in obj).toBe(false);
expect("aaa" in o).toBe(true);
expect("aaa" in p).toBe(false);
expect("ccc" in m).toBe(false);
Expand Down
1 change: 1 addition & 0 deletions test/cases/parsing/harmony-export-import-specifier/m.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const aaa = 1;
export const bbb = 2;
export const object = {};
export * as ddd from "./n";
export const usedA = __webpack_exports_info__.aaa.used;
export const canMangleA = __webpack_exports_info__.ccc.canMangle;
Expand Down
4 changes: 4 additions & 0 deletions test/cases/parsing/harmony-reexport/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ import { b } from "./b";
export function a() {
return b();
}
export const obj = {};
export const aUsed = __webpack_exports_info__.a.used;
export const aProvided = __webpack_exports_info__.a.provideInfo;
export const objUsed = __webpack_exports_info__.obj.used;
export const objAProvided = __webpack_exports_info__.obj.A.provideInfo;
export const aToStringProvided = __webpack_exports_info__.a.toString.provideInfo;
7 changes: 5 additions & 2 deletions test/cases/parsing/harmony-reexport/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { a, aUsed, aCanBeMangled, aProvided } from "./reexport";
import { a, aUsed, aCanBeMangled, aProvided, aToStringProvided, obj, objUsed, objAProvided } from "./reexport";

if (a()) console.log("a");
if (a()) console.log("a", obj);

it("should not allow mangle if some exports are unknown", () => {
expect(aUsed).toBe(true);
expect(aProvided).toBe(true);
expect(aCanBeMangled).toBe(false);
expect(objUsed).toBe(true);
expect(objAProvided).toBe(undefined);
expect(aToStringProvided).toBe(undefined);
});