@pyreon/compiler 0.11.5 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +4 -4
- package/package.json +10 -10
- package/src/index.ts +6 -11
- package/src/jsx.ts +104 -104
- package/src/project-scanner.ts +21 -21
- package/src/react-intercept.ts +213 -213
- package/src/tests/jsx.test.ts +583 -583
- package/src/tests/project-scanner.test.ts +63 -63
- package/src/tests/react-intercept.test.ts +280 -280
package/README.md
CHANGED
|
@@ -11,11 +11,14 @@ bun add @pyreon/compiler
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { transformJSX } from
|
|
14
|
+
import { transformJSX } from '@pyreon/compiler'
|
|
15
15
|
|
|
16
|
-
const result = transformJSX(
|
|
16
|
+
const result = transformJSX(
|
|
17
|
+
`
|
|
17
18
|
const App = () => <div class={color()}>{count()}</div>
|
|
18
|
-
`,
|
|
19
|
+
`,
|
|
20
|
+
'app.tsx',
|
|
21
|
+
)
|
|
19
22
|
|
|
20
23
|
console.log(result.code)
|
|
21
24
|
// Dynamic expressions are wrapped: {() => count()}, class={() => color()}
|
|
@@ -26,13 +29,13 @@ console.log(result.code)
|
|
|
26
29
|
|
|
27
30
|
The compiler transforms JSX expression containers and props so the Pyreon runtime receives reactive getters instead of eagerly-evaluated values.
|
|
28
31
|
|
|
29
|
-
| Input
|
|
30
|
-
|
|
31
|
-
| `<div>{expr}</div>`
|
|
32
|
-
| `<div class={expr}>`
|
|
33
|
-
| `<button onClick={fn}>`
|
|
34
|
-
| `<div>{() => expr}</div>` | unchanged
|
|
35
|
-
| `<div>{"literal"}</div>`
|
|
32
|
+
| Input | Output | Reason |
|
|
33
|
+
| ------------------------- | -------------------------- | --------------- |
|
|
34
|
+
| `<div>{expr}</div>` | `<div>{() => expr}</div>` | Dynamic child |
|
|
35
|
+
| `<div class={expr}>` | `<div class={() => expr}>` | Dynamic prop |
|
|
36
|
+
| `<button onClick={fn}>` | unchanged | Event handler |
|
|
37
|
+
| `<div>{() => expr}</div>` | unchanged | Already wrapped |
|
|
38
|
+
| `<div>{"literal"}</div>` | unchanged | Static value |
|
|
36
39
|
|
|
37
40
|
### Static Hoisting
|
|
38
41
|
|