mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
**Description:**
I was seeing this snapshot test failure when trying to upgrade swc in
Turbopack:
```js
--- expected
+++ actual
@@ -1,3 +1,3 @@
-module.exports=["index.js",(t,e,o)=>{let s="Hello";console.log("Hello, world!",3,s),console.log(s)}];
+module.exports=["index.js",(o,s,t)=>{const e="Hello";console.log("Hello, world!",3,e),console.log(e)}];
```
The problem was that `is_top_level` was true here, even though the code
is inside an arrow function:
https://github.com/swc-project/swc/blob/27931895f59135e11f83a4ddf1d311bdcde97321/crates/swc_ecma_minifier/src/compress/optimize/mod.rs#L2836
Probably caused by https://github.com/swc-project/swc/pull/11035
63 lines
3.5 KiB
HTML
63 lines
3.5 KiB
HTML
<!doctype html><title>Party Coffee Cake</title><!--[if lte IE 8]><script>alert("ie8!test")</script><![endif]--><script type=application/ld+json>{"@context":"https://schema.org/","@type":"Recipe","author":{"@type":"Person","name":"Mary Stone"},"datePublished":"2018-03-10","description":"This coffee cake is awesome and perfect for parties.","name":"Party Coffee Cake","prepTime":"PT20M"}</script><script type=application/ld+json crossorigin>{"@context":"https://schema.org/","@type":"Recipe","author":{"@type":"Person","name":"Mary Stone"},"datePublished":"2018-03-10","description":"This coffee cake is awesome and perfect for parties.","name":"Party Coffee Cake","prepTime":"PT20M"}</script><script type=application/ld+json crossorigin>
|
|
{
|
|
broken
|
|
</script><script type=unknown>
|
|
{
|
|
"@context": "https://schema.org/",
|
|
"@type": "Recipe",
|
|
"name": "Party Coffee Cake",
|
|
"author": {
|
|
"@type": "Person",
|
|
"name": "Mary Stone"
|
|
},
|
|
"datePublished": "2018-03-10",
|
|
"description": "This coffee cake is awesome and perfect for parties.",
|
|
"prepTime": "PT20M"
|
|
}
|
|
</script><script type=speculationrules>{"prerender":[{"score":0.5,"source":"list","urls":["/page/2"]},{"if_href_matches":["https://*.wikipedia.org/**"],"if_not_selector_matches":[".restricted-section *"],"score":0.1,"source":"document"}]}</script><script type=importmap>{"imports":{"lodash":"/node_modules/lodash-es/lodash.js","moment":"/node_modules/moment/src/moment.js"}}</script><script type=application/json src=data.json></script><script type=application/json src=data.json>
|
|
|
|
|
|
</script><script id=data type=application/json>{"foo":"bar"}</script><script>
|
|
broken broken
|
|
</script><script>var a=3,a=9</script><script type=module>import"foo.js"</script><script>let d=new Date;alert("Today's date is "+d)</script><script src=javascript.js>
|
|
|
|
|
|
|
|
</script><script src=javascript.js>
|
|
|
|
var q = "WRONG" ;
|
|
|
|
</script><script>const foo="testtest";function test(){alert("1 2")}alert("<!--"),alert("<!-- foo -->"),alert("-->"),alert("testtest")</script><h2>Party coffee cake recipe</h2>
|
|
<p>
|
|
<i>by Mary Stone, 2018-03-10</i>
|
|
</p>
|
|
<p>
|
|
This coffee cake is awesome and perfect for parties.
|
|
</p>
|
|
<p>
|
|
Preparation time: 20 minutes
|
|
</p>
|
|
<svg>
|
|
<script>alert("test")</script>
|
|
<script>alert(1)</script>
|
|
</svg>
|
|
<svg viewBox="0 0 10 10">
|
|
<script>window.addEventListener("DOMContentLoaded",()=>{document.querySelector("circle").addEventListener("click",t=>{let a,r,d;t.target.style.fill=(a=Math.round(255*Math.random()).toString(16).padStart(2,"0"),r=Math.round(255*Math.random()).toString(16).padStart(2,"0"),d=Math.round(255*Math.random()).toString(16).padStart(2,"0"),`#${a}${r}${d}`)})})</script>
|
|
|
|
<circle cx=5 cy=5 r=4 />
|
|
</svg>
|
|
<math>
|
|
<script>
|
|
// This is not script
|
|
|
|
|
|
alert('test')
|
|
</script>
|
|
</math>
|
|
<script blocking="a render">console.log("block")</script><script>!function(r){var r=Math.random();alert("1 "+(2+Math.random())),console.log(Math.random())}(0),window.jQuery||document.write('<script src="jquery.js"><\/script>')</script>
|
|
<div>test</div>
|
|
|
|
<div>topLevel - script</div>
|
|
<script>var topLevel=function(){let o="bar";o&&(o+="baz"),console.log(o)}</script>
|
|
<div>topLevel - module</div>
|
|
<script type=module></script> |