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

minify turns "a?.b instanceof c" into "a?.binstanceof c" #9719

Closed
mrdaniellewis opened this issue Nov 6, 2024 · 4 comments · Fixed by #9720
Closed

minify turns "a?.b instanceof c" into "a?.binstanceof c" #9719

mrdaniellewis opened this issue Nov 6, 2024 · 4 comments · Fixed by #9720
Assignees
Labels
Milestone

Comments

@mrdaniellewis
Copy link

Describe the bug

With the minify option a?.b instanceof c becomes a?.binstanceof c.

(Sorry if already reported)

Input code

`a?.b instanceof c`

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "tsx": false
    },
    "transform": {
      "decoratorVersion": "2022-03"
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "commonjs"
  },
  "minify": true,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.42&code=H4sIAAAAAAAAA8tMU9BItNdLUsjMKy5JzEtOzU9TSNZUqOZSUEjOzyvOz0nVy8lP11DPSM3JyVfX5KpVQAUAQu8VekAAAAA%3D&config=H4sIAAAAAAAAA1VQQQ6DMAy78wqU8yYhdtsfdt29KgEV0aZKijSE%2BPta1jK4JbYTW16ruoZRNDzrNY5x8YoF%2BdgjIosL6hMRCItH0Wx8gFthO9TEKhBLVASe8WCCpKNeTYI7tP0YCKyc9MT2bHK8eSOLIZfs2qZt780DrteKBwyJRkmCnAQmIsHilzFrnOmXs40m6xlFrsIkVW6Y8Jq3yq5gqZt3MneUekgJ4jdLbhT4K4tjaQKMvMp1wqrtC7NZO0JzAQAA

SWC Info output

No response

Expected behavior

There needs to be a space before instanceof

a?.b instanceof c

Actual behavior

There is no space before instanceof and it is a syntax error.

Version

= 1.7.42

Additional context

Noticed as from version 1.7.42 terser can no longer minify https://mozilla.github.io/pdf.js/

@kdy1 kdy1 added this to the Planned milestone Nov 6, 2024
@kdy1 kdy1 self-assigned this Nov 6, 2024
@kdy1
Copy link
Member

kdy1 commented Nov 6, 2024

I think #9675 is the cause cc @CamWass

@kdy1
Copy link
Member

kdy1 commented Nov 6, 2024

Oh. Sorry, #9675 was 1.7.40

@kdy1
Copy link
Member

kdy1 commented Nov 6, 2024

Changeset was the cause of 1.7.40 vs 1.7.42 and it seems like I didn't review carefully enough. Sorry for the inconvinience.

@kdy1
Copy link
Member

kdy1 commented Nov 6, 2024

I think this is a serious issue so I triggered 1.9.1 publish pipeline.
https://github.com/swc-project/swc/actions/runs/11703603896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants