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

Multi-line comment being stripped from generated code #3715

Closed
smcenlly opened this issue Feb 24, 2022 · 3 comments · Fixed by #3720
Closed

Multi-line comment being stripped from generated code #3715

smcenlly opened this issue Feb 24, 2022 · 3 comments · Fixed by #3720
Assignees
Labels
Milestone

Comments

@smcenlly
Copy link

Describe the bug

We create some popular developer tools (Quokka.js, Wallaby.js).

Our tools rely on code comments being correctly in code emitted by SWC.

It appears that SWC sometimes (not always) removes multi-line comment from generated code.

Input code

a() /* IMPORTANT_DO_NOT_REMOVE */ ;

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": false,
      "dynamicImport": false
    }
  },
  "sourceMaps": true
}

Playground link

https://play.swc.rs/?version=1.2.144&code=H4sIAAAAAAAAA0vU0FTQ11Lw9A3wDwpx9AuJd%2FGP9%2FMPiQ9y9fUPc1XQ0lewBgAeBNe1IwAAAA%3D%3D&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU%2FMMKZAOKZZcVTNf6tKEXagYUeScdiiyd%2BZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc%2F0N7G%2FHPynaLySe0Cj9ke9LUAAAA%3D

Expected behavior

Generated code should be:

a() /* IMPORTANT_DO_NOT_REMOVE */ ;

Actual behavior

Generated code is:

a();

Version

@swc/core@1.2.144

Additional context

No response

@smcenlly smcenlly added the C-bug label Feb 24, 2022
@kwonoj
Copy link
Member

kwonoj commented Feb 24, 2022

👋 I'm wallaby / quokka daily user.

We really don't have good defined behavior around comment. #2964 is one of the examples. There is internal consideration to revisit whole comment, but also it doesn't aim to fix specific issues around comment.

How much is this a blocker for you? Is there any workaround you can apply?

@smcenlly
Copy link
Author

👋 I'm wallaby / quokka daily user.

That's awesome :)


One of Quokka/Wallaby key features is Live Comments, which gives users a mechanism to always log a value when Wallaby/Quokka runs their code.

We've been recommending people use swc over babel or TypeScript (see our blog post) because of the massive performance benefits. And we're also using swc in our own projects.

There's no real work around for us on this issue. It seems to work most of the time, but not always.

I wouldn't say it's a blocker for us per se but it'll definitely affect our customers and perhaps make them choose babel instead of swc when running their tests if they find it particularly painful.

@kdy1 kdy1 added this to the v1.2.145 milestone Feb 24, 2022
@kdy1 kdy1 self-assigned this Feb 24, 2022
kdy1 added a commit to kdy1/swc that referenced this issue Feb 24, 2022
kdy1 added a commit to kdy1/swc that referenced this issue Feb 24, 2022
@swc-bot
Copy link
Collaborator

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

4 participants