Closed stormslowly closed 3 months ago
hi @kdy1
i run the code with crates/swc_ecma_minifier/src/cli/bin.rs
, the output is correct as expected.
and i study the code for nested tpl optimize in crates/swc_ecma_minifier/src/compress/pure/strings.rs
, i can't find a bug.
could you plz give some hint about the problem, maybe i can make a PR
Sorry. I missed your comment.
To make the test reliable, you would need to add
let pi= Math.random() >1.1 ? "foo": "bar";
let fi=`(${`${pi}`} - ${`\\*${pi}`})`
console.log(fi)
let pi= Math.random() < -0.1 ? "foo": "bar";
let fi=`(${`${pi}`} - ${`\\*${pi}`})`
console.log(fi)
so the Math.random()
does not make test wrongly pass.
I wrote the relevant documentation for debugging or testing to https://github.com/swc-project/swc/blob/e22f3ba9adf21eac057eab29284333b1631258b3/crates/swc_ecma_minifier/README.md#contributing
Once you get the location of the relevant code, my guess is that you will need to modify some code about the string replacing logic.
@kdy1 thanks for your guide. PR is ready.
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.
Describe the bug
expect the output should be
(foo - \*foo)
or(bar - \*bar)
but
(foo - *foo)
or(bar - *bar)
Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.6.7&code=H4sIAAAAAAAAA8tJLVEoyLRV8E0sydArSsxLyc%2FV0FSwM9AzU7BXUErLz1eyUlBKSixSsubKASpNy7RN0FCpTlCpLsisTahV0FUAcmJitKB8zQQuruT8vOL8nFS9nPx0jbRMTQD%2FL1pIYQAAAA%3D%3D&config=H4sIAAAAAAAAA32US47bMAyG9zlF4HUXg1kVPUB3PYOgSJSjVBINkcrEGOTupR%2FJpBM6O5sff1IiKX7u9vvuRK77tf%2BUT%2FkZbCWo93%2Bx0FjYXsTSgcuWXI0Ddz9u9EQTCjYRzKbrQjq2tQeeVfT%2B9v62KrqESHBTrLYcSwzjY06HeahA9GATq4RsGQrT%2F%2FqVVfyYANf2aD8gJrDlBTGWTCwMPVQtsMOU7EBgzrYqUaaT2hoJtRQTbAzeDBUHlRcfOWKRnM%2FUg%2FXGoQcFxQqO4xk0meQSWSG5nnKfGXs4tL6f%2B%2FxNDWebmmUlJ1zmlshplahHjMQmtKKVcIEbNVjgWtzvyhhMBW61POtOGMtGT%2F4CSAWSJSo2gxZ39ggyT1vq8FIZS5CR5VHhMt%2FaLQv0UlQTY1AqO1UGKketmxV8czBV1mnHWfFG%2BSh6MBCCzIoSmj4iu6OWlMcBMChA%2BmuDNlULMPdXuMGnB%2FEC%2F5Zbsj5gq0e2fNymNOYDphcJMvAR%2FQsHaQXjNq6yJS7DNm%2FFg4wGeNWl0Qyel4A8AEaT5n35NBvyPCSi6RMe1DUxyJzPTfy52q735Zxt6b%2BWwLKfd6tDl9G3Ga6bf2r6tK%2BlRxnLibovz9t%2Bvl%2Bpi%2FTnJp%2BOs7v%2BA6xLOoBKBgAA
SWC Info output
No response
Expected behavior
output
(foo - \*foo)
or(bar - \*bar)
Actual behavior
(foo - *foo)
or(bar - *bar)
Version
1.6.7
Additional context
No response