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

Different code removed after compression depending on formatting #8435

Closed
shredor opened this issue Dec 19, 2023 · 1 comment · Fixed by #8439
Closed

Different code removed after compression depending on formatting #8435

shredor opened this issue Dec 19, 2023 · 1 comment · Fixed by #8439
Assignees
Labels
Milestone

Comments

@shredor
Copy link

shredor commented Dec 19, 2023

Describe the bug

After compilation some code is missing. If I change formatting (e.g. add whitespace) everything works well

Input code

const init = () => {
  var e = window.parcelRequire;
  e.register('module1', function () {
    class Hello {
      world() {}
    }
}), e.register('module2', function () {
      console.log('test')
    });
};

init();

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "dynamicImport": true,
      "tsx": true,
      "jsx": true
    },
    "minify": {
      "compress": true,
      "mangle": false
    },
    "loose": false
  },
  "env": {
    "targets": "> 0.25%, not dead, Safari >=8",
    "mode": "entry",
    "coreJs": "3.27",
    "loose": false,
    "bugfixes": true
  },
  "minify": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.101&code=H4sIAAAAAAAAA23PMQ7CMAwF0D2n%2BFsSqaoEa1VmZm5QpaaKZGJI0nZAuTsJMHazvr%2BebCchZfjgM0YYi%2FGCtwK2KYJqsvswy94%2Fp%2BiIb%2FRafaSh7qmPtPiUKRr9kHllOukO9zW47CU0qCmA4yklXIlZ%2FgmwS%2BS5Nco3KKrY7gA8H4KVrBcLU8%2ByGJ0pZW1%2Fjh1UGZRqv5g6fwBCS3yK2gAAAA%3D%3D&config=H4sIAAAAAAAAA22Py4oCQQxF935FEXDXiCgyw8C41%2B18QaY63ZR0PUji0IX471O2dvvAXeXc4iT3NDMGDmLhy5zKswwJWYinuRDJQbEvBDQnEssuKVRjWueA3tmdT5G1fFI%2B0hSq9K%2FoMKGBnK8BeBdckx%2FX2ugTk8irwGNoOyq0wU6eJV2M8pgMHCj83espckt6kcLWLBerzbwyIaqpCevK%2FGCD7Mz2%2BxPGu2J9MRaJch6hjUz7wbFerD7g3fYb%2Bz22jetJ7pWvN011B3r%2BB3YL95yHAQAA

SWC Info output

No response

Expected behavior

var e;(e=window.parcelRequire).register("module1",function(){}),e.register("module2",function(){console.log("test")});

If I add whitespace at the beginning of line 7 output becomes correct

Actual behavior

window.parcelRequire.register("module1",function(){});

Version

1.3.101

Additional context

No response

@shredor shredor added the C-bug label Dec 19, 2023
@kdy1 kdy1 added this to the Planned milestone Dec 20, 2023
@kdy1 kdy1 self-assigned this Dec 20, 2023
kdy1 pushed a commit that referenced this issue Dec 21, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.102 Dec 31, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Jan 30, 2024

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 Jan 30, 2024
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