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

jsc.minify.format.inlineScript support #7602

Closed
9aoy opened this issue Jun 29, 2023 · 4 comments · Fixed by #9729
Closed

jsc.minify.format.inlineScript support #7602

9aoy opened this issue Jun 29, 2023 · 4 comments · Fixed by #9729
Assignees
Milestone

Comments

@9aoy
Copy link

9aoy commented Jun 29, 2023

Describe the feature

https://swc.rs/docs/configuration/minification#jscminifyformat

image

input:

 "<script></script>"

expected output:

 "<script><\\/script>"

Are you willing to work on this yourself?
yes

Babel plugin or link to the feature description

https://github.com/terser/terser/blob/aeddfabd04ace5a6565b2920b074ad7dc210bcac/lib/output.js#L367

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone Jun 29, 2023
@Skalman
Copy link

Skalman commented Jul 6, 2023

FWIW, the Terser implementation isn't complete, so the linked code isn't sufficient to make it completely safe.

I've filed an issue with Terser: terser/terser#1408

@fabiosantoscode
Copy link
Contributor

I'm implementing this with a simple lookup of the latest printed stuff before printing.

For example I'm going to check if the output stream ends with "--" before printing the ">" operator. If it does, I'll add a space.

@adam-azarchs
Copy link

It looks like #8252 tried to fix this, but it doesn't seem to actually work. I haven't dug deep into why, but at least in my use case I'm using swc as the minifier in a webpack build, where pre-minification it's got a.innerHTML="<script>\x3c/script>" (which comes from react-dom, so I'd expect this to be a fairly common thing for people to encounter), so I'm wondering if maybe the issue is one of order of operations between converting \x3c to / and escaping / to \/.

@swc-bot
Copy link
Collaborator

swc-bot commented Dec 11, 2024

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 Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

6 participants