-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/react): Don't panic on invalid react pragma (#5101)
- Loading branch information
1 parent
b79593f
commit cc555ef
Showing
8 changed files
with
82 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/1/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** @jsx h */ | ||
/** @jsxFrag */ | ||
import { h } from "preact"; | ||
|
||
import { Marked } from "markdown"; | ||
|
||
export const handler = { | ||
async GET(req, ctx) { | ||
const markdown = await Deno.readTextFile(`posts/${ctx.params.id}.md`); | ||
const markup = Marked.parse(markdown); | ||
const resp = await ctx.render({ markup }); | ||
return resp; | ||
}, | ||
}; | ||
|
||
export default function Greet(props) { | ||
return ( | ||
<> | ||
<div | ||
dangerouslySetInnerHTML={{ | ||
__html: props.data.markup.content, | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/1/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** @jsx h */ /** @jsxFrag */ import { h } from "preact"; | ||
import { Marked } from "markdown"; | ||
export const handler = { | ||
async GET (req, ctx) { | ||
const markdown = await Deno.readTextFile(`posts/${ctx.params.id}.md`); | ||
const markup = Marked.parse(markdown); | ||
const resp = await ctx.render({ | ||
markup | ||
}); | ||
return resp; | ||
} | ||
}; | ||
export default function Greet(props) { | ||
return /*#__PURE__*/ h(React.Fragment, null, /*#__PURE__*/ h("div", { | ||
dangerouslySetInnerHTML: { | ||
__html: props.data.markup.content | ||
} | ||
})); | ||
}; |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/2/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** @jsxRuntime typo */ | ||
|
||
<></>; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/2/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** @jsxRuntime typo */ /*#__PURE__*/ React.createElement(React.Fragment, null); |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/2/output.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
x Runtime must be either `classic` or `automatic`. | ||
,-[input.js:1:1] | ||
1 | /** @jsxRuntime typo */ | ||
: ^^^^^^^^^^^^^^^^^^^^^^^ | ||
`---- |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/empty-pragma/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @jsxRuntime */ | ||
/** @jsxImportSource */ | ||
/** @jsxFrag */ | ||
/** @jsx */ | ||
|
||
<></>; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-5099/empty-pragma/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** @jsxRuntime */ /** @jsxImportSource */ /** @jsxFrag */ /** @jsx */ /*#__PURE__*/ React.createElement(React.Fragment, null); |
cc555ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/minify/libraries/antd
1771788978
ns/iter (± 16669574
)1599975030
ns/iter (± 28758983
)1.11
es/full/minify/libraries/d3
437184199
ns/iter (± 8211800
)396959922
ns/iter (± 15446481
)1.10
es/full/minify/libraries/echarts
1646626722
ns/iter (± 26247902
)1589097115
ns/iter (± 42324391
)1.04
es/full/minify/libraries/jquery
101124919
ns/iter (± 1505968
)84644941
ns/iter (± 2910349
)1.19
es/full/minify/libraries/lodash
123081517
ns/iter (± 1713130
)112608268
ns/iter (± 5492771
)1.09
es/full/minify/libraries/moment
56858034
ns/iter (± 1884735
)51338152
ns/iter (± 2305632
)1.11
es/full/minify/libraries/react
18318908
ns/iter (± 480075
)17026397
ns/iter (± 536243
)1.08
es/full/minify/libraries/terser
612749535
ns/iter (± 7881364
)587856641
ns/iter (± 18152813
)1.04
es/full/minify/libraries/three
566433380
ns/iter (± 10163256
)531676215
ns/iter (± 20852964
)1.07
es/full/minify/libraries/typescript
3622765861
ns/iter (± 51835452
)3379635233
ns/iter (± 75698354
)1.07
es/full/minify/libraries/victory
756431610
ns/iter (± 12645296
)708962964
ns/iter (± 13900330
)1.07
es/full/minify/libraries/vue
157329616
ns/iter (± 2630021
)130996250
ns/iter (± 5992301
)1.20
es/full/codegen/es3
31514
ns/iter (± 1149
)31644
ns/iter (± 1198
)1.00
es/full/codegen/es5
31595
ns/iter (± 1184
)31371
ns/iter (± 766
)1.01
es/full/codegen/es2015
31614
ns/iter (± 644
)31323
ns/iter (± 1012
)1.01
es/full/codegen/es2016
31474
ns/iter (± 948
)31478
ns/iter (± 1033
)1.00
es/full/codegen/es2017
31478
ns/iter (± 236
)31591
ns/iter (± 1577
)1.00
es/full/codegen/es2018
31496
ns/iter (± 411
)31549
ns/iter (± 4155
)1.00
es/full/codegen/es2019
31548
ns/iter (± 1006
)31465
ns/iter (± 851
)1.00
es/full/codegen/es2020
31505
ns/iter (± 803
)31636
ns/iter (± 880
)1.00
es/full/all/es3
194404854
ns/iter (± 7990189
)178687799
ns/iter (± 5083764
)1.09
es/full/all/es5
184087025
ns/iter (± 9525468
)167611732
ns/iter (± 5243538
)1.10
es/full/all/es2015
158410817
ns/iter (± 5015893
)137190996
ns/iter (± 4834286
)1.15
es/full/all/es2016
155362470
ns/iter (± 7982369
)135971499
ns/iter (± 4862728
)1.14
es/full/all/es2017
144914360
ns/iter (± 9326334
)135173979
ns/iter (± 8248585
)1.07
es/full/all/es2018
148640063
ns/iter (± 7121701
)133845158
ns/iter (± 3564844
)1.11
es/full/all/es2019
143510252
ns/iter (± 5524097
)134003135
ns/iter (± 4549299
)1.07
es/full/all/es2020
144708352
ns/iter (± 7610179
)128619488
ns/iter (± 3947352
)1.13
es/full/parser
720679
ns/iter (± 24655
)698411
ns/iter (± 40476
)1.03
es/full/base/fixer
29730
ns/iter (± 595
)28402
ns/iter (± 892
)1.05
es/full/base/resolver_and_hygiene
87439
ns/iter (± 1450
)85567
ns/iter (± 7764
)1.02
serialization of ast node
215
ns/iter (± 3
)209
ns/iter (± 6
)1.03
serialization of serde
229
ns/iter (± 4
)225
ns/iter (± 6
)1.02
This comment was automatically generated by workflow using github-action-benchmark.