fix ExportsInfo
This commit is contained in:
parent
cb639b3efc
commit
216c3daa4e
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue