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(es/minifier): Do not drop properties from a var used in export default #7711

Closed
wants to merge 3 commits into from

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Jul 27, 2023

@kdy1 kdy1 added this to the Planned milestone Jul 27, 2023
@kdy1 kdy1 self-assigned this Jul 27, 2023
@kdy1 kdy1 marked this pull request as ready for review July 27, 2023 02:37
@kdy1 kdy1 requested a review from jridgewell July 27, 2023 02:37
Copy link
Member Author

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swc-bump:

  • swc_ecma_usage_analyzer

@ThomasJClark
Copy link

ThomasJClark commented Jul 27, 2023

Thanks for looking into this. Although the example in #7710 uses a default export, this also occurs when obj is used in other ways. Here are some additional test cases for this, reproducible with the same version/config as the original issue.

Input code

const obj = {
    foo: 1,
    bar: 2,
};
console.log(obj.bar);
export const o = obj;

Expected behavior

console.log(2);
export var o = {
    foo: 1,
    bar: 2
};

Actual behavior

console.log(2);
export var o = {
    bar: 2
};

Input code

const obj = {
    foo: 1,
    bar: 2,
};

console.log(obj.bar);

[obj].forEach(o => console.log(o));

Expected behavior

console.log(2), [
    {
        foo: 1,
        bar: 2
    }
].forEach(function(o) {
    return console.log(o);
});

Actual behavior

console.log(2), [
    {
        bar: 2
    }
].forEach(function(o) {
    return console.log(o);
});

@kdy1
Copy link
Member Author

kdy1 commented Jul 28, 2023

I'll merge this into #7702

@kdy1 kdy1 closed this Jul 28, 2023
@kdy1 kdy1 deleted the issue-7710 branch July 28, 2023 03:46
@kdy1 kdy1 modified the milestones: Planned, v1.3.72 Jul 28, 2023
@swc-project swc-project locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Object properties are incorrectly erased when using hoist_props
2 participants