You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,30 @@
2
2
3
3
## Unreleased
4
4
5
+
* The "preserve" JSX mode now preserves JSX text verbatim ([#3605](https://github.com/evanw/esbuild/issues/3605))
6
+
7
+
The [JSX specification](https://facebook.github.io/jsx/) deliberately doesn't specify how JSX text is supposed to be interpreted and there is no canonical way to interpret JSX text. Two most popular interpretations are Babel and TypeScript. Yes [they are different](https://twitter.com/jarredsumner/status/1456118847937781764) (esbuild [deliberately follows TypeScript](https://twitter.com/evanwallace/status/1456122279453208576) by the way). Previously esbuild normalized text to the TypeScript interpretation when the "preserve" JSX mode is active. However, "preserve" should arguably reproduce the original JSX text verbatim so that whatever JSX transform runs after esbuild is free to interpret it however it wants. So with this release, esbuild will now pass JSX text through unmodified:
8
+
9
+
```jsx
10
+
// Original code
11
+
let el =
12
+
<a href={'/'} title=''"'> some text
13
+
{foo}
14
+
more text </a>
15
+
16
+
// Old output (with --loader=jsx --jsx=preserve)
17
+
let el =<a href="/" title={`'"`}>
18
+
{" some text"}
19
+
{foo}
20
+
{"more text "}
21
+
</a>;
22
+
23
+
// New output (with --loader=jsx --jsx=preserve)
24
+
let el =<a href={"/"} title=''"'> some text
25
+
{foo}
26
+
more text </a>;
27
+
```
28
+
5
29
* Allow JSX elements as JSX attribute values
6
30
7
31
JSX has an obscure feature where you can use JSX elements in attribute position without surrounding them with`{...}`. It looks like this:
0 commit comments