Skip to content

Emit doesn't add newlines after blocks #8203

Open
@lucacasonato

Description

Describe the bug

Blocks that are not followed by a semicolon do not have a newline added to them.

Input code

{ const asd = foo; }
{ 123; 1; }

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.94-nightly-20231016.1&code=H4sIAAAAAAAAA6tWSM7PKy5RSCxOUbBVSMvPt1ao5apWMDQytlYwBLIBia4%2FlCAAAAA%3D&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BAWdSIifrKJVBTl7iUE0maH3xsz8jooBbNoeKq1PMsQkYX4nEsi2Sf8lARIOxTNJia49XaWvRrRCtVoOxpIyBOluiX3hoMNQajjLXPGmzH%2FC3VwkUnkCu4o%2BsnSVTc0JbjwXmrZDkk50qF%2FwA%2FqsvNjMPLqm4kXGrYvhlQioBQBAAA%3D

SWC Info output

No response

Expected behavior

{
    var asd = foo;
}
{
    123;
    1;
}

Note the newline after the first and second block.

Actual behavior

{
    var asd = foo;
}{
    123;
    1;
}

Note there is no newline after the first and second block.

Version

1.3.94-nightly-20231016.1

Additional context

No response

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions