We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We use Webpack + html-webpack-plugin + terser-webpack-plugin with SWC as a minifier.
html-webpack-plugin
terser-webpack-plugin
We inline some JS into a .ejs template, basically:
.ejs
<body> <script><%= someVar =></script> </body>
It works fine with Terser & esbuild as minifiers, but breaks on SWC.
I traced the problem and it looks that SWC does not escape tags and this breaks the template as someVar contains + </script>, so we get:
someVar
+ </script>
<body> <script>"" + "</script>";</script> <!-- ⬆️ a closing tag 💣 --> </body>
export const foo = "</script>"
N/A
https://play.swc.rs/?version=1.9.1&code=H4sIAAAAAAAAA0utKMgvKlFIzs8rLlFIy89XsFVQstEvTi7KLCixUwIAa3ctVB4AAAA%3D&config=H4sIAAAAAAAAA1WPSw7DIAxE9zkF8rqLKIsueoceAlEnIuIn7EhFUe5eIJC2O%2FuNRzPeByFgJQUPsecxL0FGwnjtmVByLN%2BZAKeApKIODLeuMhWJ44aVHKcALOOCXExI0ziNzQDGe8KMZ2kIG7Pa6Tn9RipvQ0Si%2F8NyKt1iLv%2BZOLRUsP61VbG9UuqeDe7wPephpXIlmp7dWN84Pk9GmjkVAQAA
@swc/core@1.9.1
SWC should escape closing tags like Terser and esbuild:
export const foo = "<\/script>"
REPL
SWC produces:
No response
The text was updated successfully, but these errors were encountered:
Duplicate of #7602
Sorry, something went wrong.
#9729 will implement this
No branches or pull requests
Describe the bug
We use Webpack +
html-webpack-plugin
+terser-webpack-plugin
with SWC as a minifier.We inline some JS into a
.ejs
template, basically:It works fine with Terser & esbuild as minifiers, but breaks on SWC.
I traced the problem and it looks that SWC does not escape tags and this breaks the template as
someVar
contains+ </script>
, so we get:Input code
Config
N/A
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.9.1&code=H4sIAAAAAAAAA0utKMgvKlFIzs8rLlFIy89XsFVQstEvTi7KLCixUwIAa3ctVB4AAAA%3D&config=H4sIAAAAAAAAA1WPSw7DIAxE9zkF8rqLKIsueoceAlEnIuIn7EhFUe5eIJC2O%2FuNRzPeByFgJQUPsecxL0FGwnjtmVByLN%2BZAKeApKIODLeuMhWJ44aVHKcALOOCXExI0ziNzQDGe8KMZ2kIG7Pa6Tn9RipvQ0Si%2F8NyKt1iLv%2BZOLRUsP61VbG9UuqeDe7wPephpXIlmp7dWN84Pk9GmjkVAQAA
SWC Info output
@swc/core@1.9.1
Expected behavior
SWC should escape closing tags like Terser and esbuild:
Terser
esbuild
REPL
Actual behavior
SWC produces:
REPL
Version
@swc/core@1.9.1
Additional context
No response
The text was updated successfully, but these errors were encountered: