-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mangle export with destructuring
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/configCases/mangle/mangle-with-destructuring-assignment/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as module from "./module"; | ||
|
||
it("should not mangle export when destructuring module", () => { | ||
const { obj: { a, b }, objCanMangle } = module | ||
expect(a).toBe("a"); | ||
expect(b).toBe("b"); | ||
expect(objCanMangle).toBe(false) | ||
}); | ||
|
||
it("should mangle export when destructuring module's porperty", () => { | ||
const { a, b } = module.obj2 | ||
const { obj2CanMangle } = module | ||
expect(a).toBe("a"); | ||
expect(b).toBe("b"); | ||
expect(obj2CanMangle).toBe(true) | ||
}); | ||
|
||
it("should mangle export when using module dot property", () => { | ||
expect(module.aaa).toBe("aaa"); | ||
expect(module.aaaCanMangle).toBe(true) | ||
}); |
8 changes: 8 additions & 0 deletions
8
test/configCases/mangle/mangle-with-destructuring-assignment/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const aaa = "aaa"; | ||
export const aaaCanMangle = __webpack_exports_info__.aaa.canMangle; | ||
|
||
export const obj = { a: "a", b: "b" } | ||
export const objCanMangle = __webpack_exports_info__.obj.canMangle; | ||
|
||
export const obj2 = { a: "a", b: "b" } | ||
export const obj2CanMangle = __webpack_exports_info__.obj2.canMangle; |
8 changes: 8 additions & 0 deletions
8
test/configCases/mangle/mangle-with-destructuring-assignment/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
optimization: { | ||
mangleExports: true, | ||
usedExports: true, | ||
providedExports: true | ||
} | ||
}; |