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

When optimizer is enabled, using spreads in object literals causes swc to freeze #1901

Closed
macarie opened this issue Jul 7, 2021 · 1 comment · Fixed by #1950
Closed

When optimizer is enabled, using spreads in object literals causes swc to freeze #1901

macarie opened this issue Jul 7, 2021 · 1 comment · Fixed by #1950
Labels
Milestone

Comments

@macarie
Copy link

macarie commented Jul 7, 2021

Describe the bug
When optimizer is enabled, swc freezes (and has high CPU usage) if there are spreads in object literals.

Reproduction code

compile.js
const { resolve } = require('path')

const swc = require('@swc/core')

swc
  .transformFile(resolve(__dirname, 'swc-test.js'), {
    jsc: {
      transform: {
        optimizer: {
          globals: {
            vars: {
              __DEBUG__: 'true',
            },
          },
        },
      },
    },
  })
  .then(({ code, map }) => {
    console.log(code)
    console.log(map)
  })
swc-test.js
const object = { a: true }

export const mapContextToProps = () => {
  return { ...object }
}

Expected behavior
The code should be transpiled correctly.

Version
The version of @swc/core: 1.2.63

@macarie macarie added the C-bug label Jul 7, 2021
@kdy1 kdy1 modified the milestones: v1.2.64, v1.2.65 Jul 7, 2021
@kdy1 kdy1 modified the milestones: v1.2.65, v1.2.66, v1.2.67 Jul 18, 2021
@kdy1 kdy1 mentioned this issue Jul 22, 2021
3 tasks
kdy1 added a commit to kdy1/swc that referenced this issue Jul 22, 2021
kdy1 added a commit that referenced this issue Jul 22, 2021
swc_ecma_trasnsforms_base:
 - `fixer`: Don't de-optimize `++foo || bar`.

swc_ecma_trasnsforms_typescript:
 - Allow using properties from a decorated class. (#1869)

swc_ecma_transforms_optimization:
 - Fix infinite loop. (#1901, #1946)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 23, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants