-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Is there a way to preserve string delimiters? #3804
Comments
No, there isn't a way to preserve string delimiters. String literals behave exactly the same as no-substitution template literals at run-time, so esbuild treats them as equivalent and may turn either one into the other one depending on the situation. For example, esbuild may turn Can you say more about why you consider string literals to be not equivalent to no-substitution template literals? |
However it can make compiling it faster nodejs/node#41448. |
That makes a lot of sense. However, it would still be nice if that was something I could configure to not happen (or even say which delimiter to use, since different projects have different rules concerning those, so most projects with linting will already fairly consistently use ' or " or ` )
It mostly matters during the dev process: if I'm debugging in the browser, and there's an error, the fastest way to find it in the source is to just copy a stretch of text and find-in-file with that. Selecting that stretch with quotation marks (and usually the preceding And to explain things a little further: normally you can just use sourcemaps. No problem there, but I'm working on a project that's essentially an in-browser transpiler, turning graphics code into JS modules that then get dynamically imported so they can run as on-page graphics. In that context, there are no source maps, and stack traces can be surprisingly useless depending on the browser, so finding the source of bugs turns into a more manual process. |
It sounds like when you're debugging, you're saying that you prefer code that's more optimized for human readability than for machine consumption. The good news is that esbuild already does have the ability to preserve |
that's fair, cheers! |
I noticed that esbuild produces a bundle where all my backticks are replaced by single quotes, so that this:
turns into this
And I understand the variable rename, that saves a bunch of bytes, but replacing one string delimiter for another does not help make the code smaller (they're all one byte), nor does it make the resulting code execute any faster. However, it does make it needlessly more work to search for bits of erroneous code involving strings.
Is there a way to tell esbuild to not touch string delimiters?
The text was updated successfully, but these errors were encountered: