-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: babel-plugin-minify-mangle-names default parameter error (#42)
- Loading branch information
Showing
4 changed files
with
92 additions
and
6 deletions.
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
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
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
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,45 @@ | ||
import { test } from 'vitest'; | ||
import { testTransform } from '.'; | ||
import mangle from '../src/transforms/mangle'; | ||
|
||
const expectJS = testTransform(mangle); | ||
|
||
// https://github.com/j4k0xb/webcrack/issues/41 | ||
test('rename default parameters of function', () => { | ||
expectJS(` | ||
function func(arg1, arg2 = 0, arg3 = arg1, arg4 = arg1) { | ||
return arg1; | ||
} | ||
`).toMatchInlineSnapshot(` | ||
function a(a, b = 0, c = undefined, d = undefined) { | ||
if (c === undefined) c = a; | ||
if (d === undefined) d = a; | ||
return a; | ||
} | ||
`); | ||
}); | ||
|
||
test('rename default parameters of arrow function', () => { | ||
expectJS(` | ||
const func = (arg1, arg2 = 0, arg3 = arg1, arg4 = arg1) => arg1; | ||
`).toMatchInlineSnapshot(` | ||
const a = (a, b = 0, c = undefined, d = undefined) => { | ||
if (c === undefined) c = a; | ||
if (d === undefined) d = a; | ||
return a; | ||
}; | ||
`); | ||
}); | ||
|
||
test('rename default destructuring parameters', () => { | ||
expectJS(` | ||
function func(arg1, [arg2] = arg1) { | ||
return arg2; | ||
} | ||
`).toMatchInlineSnapshot(` | ||
function a(a, b = undefined) { | ||
var [c] = b === undefined ? a : b; | ||
return c; | ||
} | ||
`); | ||
}); |