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): Abort sequential inliner on optional chaining #6637

Merged
merged 29 commits into from Dec 14, 2022

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Dec 13, 2022

Description:

I'm currently reducing it.

Related issue:


Investigation

image

var a, b;
a?.foo?.(b = 1)
console.log(b)

prints undefined.

Works

{
  defaults: true,
  sequences: false,
  collapse_vars: false,
}

@kdy1 kdy1 added this to the Planned milestone Dec 13, 2022
@kdy1 kdy1 self-assigned this Dec 13, 2022
@kdy1 kdy1 changed the title fix(es/minifier): Fix a bug fix(es/minifier): Fix `react-tablee Dec 13, 2022
@kdy1 kdy1 changed the title fix(es/minifier): Fix `react-tablee fix(es/minifier): Fix react-table Dec 13, 2022
@kdy1 kdy1 changed the title fix(es/minifier): Fix react-table fix(es/minifier): Abort sequential inliner on optional chaining Dec 13, 2022
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_minifier

@@ -0,0 +1,8 @@
export function memo(getDeps, fn, opts) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Previous output:

export function memo(getDeps, fn, opts) {
    let result, deps = [];
    return ()=>{
        opts.key && opts.debug && Date.now();
        const newDeps = getDeps(), depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index)=>deps[index] !== dep);
        return depsChanged && (deps = newDeps, opts.key && opts.debug && Date.now(), opts?.onChange?.(result = fn(...newDeps)), opts.key && opts.debug && opts?.debug()), result;
    };
}

@kdy1 kdy1 marked this pull request as ready for review December 13, 2022 11:53
@kdy1 kdy1 requested a review from jridgewell December 13, 2022 11:53
kodiakhq[bot]
kodiakhq bot previously approved these changes Dec 13, 2022
jridgewell
jridgewell previously approved these changes Dec 13, 2022
@kdy1 kdy1 dismissed stale reviews from jridgewell and kodiakhq via cef1be2 December 14, 2022 01:48
@kdy1 kdy1 enabled auto-merge (squash) December 14, 2022 01:48
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit e4e4d6c into swc-project:main Dec 14, 2022
@kdy1 kdy1 deleted the issue-6636 branch December 14, 2022 04:45
@kdy1 kdy1 mentioned this pull request Dec 14, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.23 Dec 14, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Jan 13, 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.

minifier breaks @tanstack/react-table
3 participants