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

Span/sourcemap/comments of transformed module #5377

Closed
magic-akari opened this issue Aug 3, 2022 · 1 comment · Fixed by #5657
Closed

Span/sourcemap/comments of transformed module #5377

magic-akari opened this issue Aug 3, 2022 · 1 comment · Fixed by #5657
Assignees
Labels
Milestone

Comments

@magic-akari
Copy link
Member

Describe the bug

Some comments are output in the wrong place.

Input code

/* 1 */ export /* 2 */ const /* 3 */ foo /* 4 */ = 1, /* 5 */ bar /* 6 */ = 2; /* 7 */

/* 8 */ export /* 9 */ default /* 10 */ function () {} /* 11 */

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "target": "es2022"
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": true
}

Playground link

https://play.swc.rs/?version=1.2.222&code=H4sIAAAAAAAAA9PXUjBU0NJXSK0oyC8qUdDXUjACcZPz84rBPGMQLy0%2FH8Q2AbFtFQx1QBxTECcpsQjENoNIGFmDOOZADhcXkGGBaq4liJuSmpZYmgPmGxqAjS7NSy7JzM9T0NBUqK4Fi4PcAwA91WrflwAAAA%3D%3D&config=H4sIAAAAAAAAAy2LSwqAMAxE7zJrF9Jl7%2BAhQo1SsR%2BSCBbx7lpxNcN7Mxc2DfAXKomy9KYtG53w4JBIg8RquAcYycrWsbrRuY5SmY%2Bd%2B8dafROhpFTypp%2BMOS4NfqFdeUDU6V%2BbHHw%2FPvro7HgAAAA%3D

Expected behavior

I don't know exactly what the correct behavior is.
But I will try to make some improvements.

Actual behavior

/* 1 */ "use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    /* 3 */ foo: ()=>foo /* 4 */ ,
    /* 5 */ bar: ()=>bar /* 6 */ ,
    /* 8 */ default: ()=>_default /* 11 */ 
});
/* 2 */ const foo = 1, bar = 2; /* 7 */ 
/* 10 */ function _default() {}

Version

1.2.222

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone Aug 3, 2022
@kdy1 kdy1 self-assigned this Aug 30, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.4 Sep 30, 2022
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 30, 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 30, 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