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

Shuffle transform in shift mode breaks program #48

Closed
relative opened this issue Dec 19, 2022 · 1 comment
Closed

Shuffle transform in shift mode breaks program #48

relative opened this issue Dec 19, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@relative
Copy link

Describe the bug:

shuffle transform will attempt to assign to arrays that are const

Config and Small code sample

Config:

{
    target: 'browser',
    shuffle: true,
    compact: false,
    minify: false,
}

Code:

const a=[1,2,3];

Expected behavior

it shouldn't try assigning to a const

Actual behavior

it assigns to a const

Additional context

if (varDeclarator.type == "VariableDeclarator") {
var varDec = parents[2];
if (varDec.type == "VariableDeclaration") {
var body = parents[3];
if (
varDec.declarations.length == 1 &&
Array.isArray(body) &&
varDeclarator.id.type === "Identifier" &&
varDeclarator.init === object
) {
inPlaceIndex = body.indexOf(varDec);
inPlaceBody = body;
inPlace = inPlaceIndex !== -1;
inPlaceName = varDeclarator.id.name;
}
}
}

${
inPlace ? `${inPlaceName} = ${name}` : name
} = ${name}.concat((function(){

@relative relative added the bug Something isn't working label Dec 19, 2022
@MichaelXF
Copy link
Owner

Thank you, fixed in 1.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants