wallabyjs / quokka

Repository for Quokka.js questions and issues
https://quokkajs.com
1.18k stars 31 forks source link

Issue with Quokka adding escape characters to back ticks. #935

Closed THLyon closed 9 months ago

THLyon commented 9 months ago

Issue description or question

When running code that utilizes back ticks for template literals and avoiding escape characters, the escape characters are added in output.

Is this issue related to Quokka not outputting the expected results of your code?: Yes/No

Yes, and yes I am getting the command line response with node.js.

Sample code

const role = 'Software Engineer'; 
console.log(`I'm a ${role}!`)

Sample repository link

N/A, just created a sandbox, easy to reproduce issue in sandbox. Can create a repo if necessary.

If the issue can not be reproduced just using the quokka file above (for example because it requires/imports some files from your project), please create a small repository where the issue can be reproduced.

Quokka.js Console Output

'I\'m a Software Engineer!' 
  ​​​​​at ​​​​​​​​`I'm a ${ role }!`​​​ ​sandbox.js:2:1

image

Code editor version

Visual Studio Code v1.?

OS name and version

OSX

smcenlly commented 9 months ago

Quokka has not actually added escape characters to your string within your template literal (backticks).

Quokka's has been designed to ensure a consistent string representation in outputs, using single quotes with necessary escaping, regardless of the original format. This method addresses the diversity of string creation methods (single quotes, double quotes, template literals) and complex string constructions. This is a deliberate design decision to standardize the string output to ensure readability and predictability across various coding scenarios.