Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ src % tree
│ ├── client.js # nested pages are just pages, so they also can have a page scoped client and style.
│ └── style.css
├── html-page
│ ├── client.js
│ ├── client.jsx # client bundles can also be written in .jsx/.tsx
│ ├── page.html # Raw html pages are also supported. They support handlebars template blocks.
│ ├── page.vars.js # pages can define page variables in a page.vars.js.
│ └── style.css
Expand Down Expand Up @@ -316,6 +316,10 @@ await someHelper()
await funnyLibrary()
```

#### .tsx/.jsx

Client bundles support .jsx and .tsx. They default to preact, so if you want mainlain recat, customize your esbuild settings to load that instead.

### Page variable files

Each page can also have a `page.vars.js` file that exports a `default` function or object that contains page specific variables.
Expand Down Expand Up @@ -1184,7 +1188,7 @@ Some notable features are included below, see the [roadmap](https://github.com/u
- [x] Esbuild settings escape hatch
- [x] Copy folders
- [x] Full Typescript support via native type stripping
- [ ] JSX support in client bundles
- [x] JSX+TSX support in client bundles
- ...[See roadmap](https://github.com/users/bcomnes/projects/3/)

## History
Expand Down
3 changes: 2 additions & 1 deletion examples/preact/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

This is a preact example.

[Isomorphic Component Rendering](./isomorphic/)
- [Isomorphic Component Rendering](./isomorphic/)
- [JSX-page](./jsx-page/)
12 changes: 12 additions & 0 deletions examples/preact/src/jsx-page/client.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render } from 'preact'

export const page = () => {
return (
<div>
look ma, client side jsx!
</div>
)
}

const renderTarget = document.querySelector('.jsx-app')
render(page(), renderTarget)
4 changes: 4 additions & 0 deletions examples/preact/src/jsx-page/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<h2>This is an html page, with a client.jsx that mounts onto it</h2>
<div class="jsx-app"></div>
</div>
3 changes: 2 additions & 1 deletion examples/type-stripping/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

This is a preact example.

[Isomorphic Component Rendering](./isomorphic/)
- [Isomorphic Component Rendering](./isomorphic/)
- [tsx-client]('./isomorphic/')
14 changes: 14 additions & 0 deletions examples/type-stripping/src/tsx-page/client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render } from 'preact'

export const page = () => {
return (
<div>
look ma, client side jsx!
</div>
)
}

const renderTarget = document.querySelector('.jsx-app')
if (renderTarget) {
render(page(), renderTarget)
}
4 changes: 4 additions & 0 deletions examples/type-stripping/src/tsx-page/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<h2>This is an html page, with a client.jsx that mounts onto it</h2>
<div class="jsx-app"></div>
</div>
4 changes: 3 additions & 1 deletion examples/type-stripping/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"erasableSyntaxOnly": true,
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"include": [
"**/*",
Expand Down
2 changes: 2 additions & 0 deletions lib/build-esbuild/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export async function buildEsbuild (src, dest, siteData, opts) {
metafile: true,
entryNames: '[dir]/[name]-[hash]',
chunkNames: 'chunks/[ext]/[name]-[hash]',
jsx: 'automatic',
jsxImportSource: 'preact'
}

const esbuildSettingsExtends = siteData.esbuildSettings
Expand Down
4 changes: 2 additions & 2 deletions lib/identify-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const jsPageDraftNames = hasTS
: ['page.draft.js', 'page.draft.mjs', 'page.draft.cjs']

const pageClientNames = hasTS
? ['client.ts', 'client.mts', 'client.cts', 'client.js', 'client.mjs', 'client.cjs']
: ['client.js', 'client.mjs', 'client.cjs']
? ['client.tsx', 'client.ts', 'client.mts', 'client.cts', 'client.jsx', 'client.js', 'client.mjs', 'client.cjs']
: ['client.jsx', 'client.js', 'client.mjs', 'client.cjs']

const pageVarsNames = hasTS
? ['page.vars.ts', 'page.vars.mts', 'page.vars.cts',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"p-map": "^7.0.2",
"package-json": "^10.0.0",
"pkg-dir": "^8.0.0",
"preact": "^10.26.6",
"pretty": "^2.0.0",
"pretty-tree": "^1.0.0",
"read-pkg": "^9.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render } from 'preact'

export const page = () => {
return (
<div>
look ma, client side jsx!
</div>
)
}

const renderTarget = document.querySelector('.tsx-app')
if (renderTarget) {
render(page(), renderTarget)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export default function () {
return `Hello world, from 2025. Also typescript`
return `
Hello world, from 2025. Also typescript
<div class="tsx-app"></div>
`
}

export const vars = {
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "@voxpelli/tsconfig/node20.json",
"compilerOptions": {
"skipLibCheck": true
"skipLibCheck": true,
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"include": [
"lib/**/*",
Expand Down