-
Notifications
You must be signed in to change notification settings - Fork 170
add vanilla.js #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ryoppippi
wants to merge
1
commit into
eknkc:master
Choose a base branch
from
ryoppippi:feature/add-vanilla
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| node_modules | ||
| dist | ||
| dist-ssr | ||
| *.local | ||
|
|
||
| # Editor directories and files | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea | ||
| .DS_Store | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? |
This file contains hidden or 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,14 @@ | ||
| { | ||
| "name": "vanilla-benchmark", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "vite build --ssr src/entry-server.ts --outDir dist" | ||
| }, | ||
| "devDependencies": { | ||
| "typescript": "^5.2.2", | ||
| "vite": "^5.2.0" | ||
| }, | ||
| "main": "dist/entry-server.js" | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,57 @@ | ||
| import type { IncomingMessage, ServerResponse } from "http"; | ||
| import { testData } from "testdata"; | ||
|
|
||
| type EntryData = Awaited<ReturnType<typeof testData>>[0] | ||
|
|
||
| function renderEntry(entry: EntryData) { | ||
| return ` | ||
| <tr> | ||
| <td>${entry.id}</td> | ||
| <td>${entry.name}</td> | ||
| </tr> | ||
| ` | ||
| } | ||
|
|
||
| function renderTable(entries: EntryData[]) { | ||
| let tableHtml = "" | ||
| for(let i = 0; i < entries.length; i++) { | ||
| tableHtml += renderEntry(entries[i]) | ||
| } | ||
|
|
||
| return ` | ||
| <table> | ||
| <tbody> | ||
| ${tableHtml} | ||
| </tbody> | ||
| </table> | ||
| ` | ||
| } | ||
|
|
||
| function renderLayout(html: string) { | ||
| return ` | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Vanilla</title> | ||
| </head> | ||
| <body> | ||
| ${html} | ||
| </body> | ||
| </html> | ||
| ` | ||
| } | ||
|
|
||
| export async function renderHtml() { | ||
| const data = await testData() | ||
| const tableHtmlString = renderTable(data) | ||
| const html = renderLayout(tableHtmlString) | ||
| return { html } | ||
| } | ||
|
|
||
| export async function buildHandler(){ | ||
| return async function handler(_: IncomingMessage, res: ServerResponse) { | ||
| const { html } = await renderHtml() | ||
| res.setHeader("Content-Type", "text/html") | ||
| res.end(html) | ||
| } | ||
| } | ||
This file contains hidden or 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,23 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2020", | ||
| "useDefineForClassFields": true, | ||
| "module": "ESNext", | ||
| "lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
| "skipLibCheck": true, | ||
|
|
||
| /* Bundler mode */ | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true, | ||
| "resolveJsonModule": true, | ||
| "isolatedModules": true, | ||
| "noEmit": true, | ||
|
|
||
| /* Linting */ | ||
| "strict": true, | ||
| "noUnusedLocals": true, | ||
| "noUnusedParameters": true, | ||
| "noFallthroughCasesInSwitch": true | ||
| }, | ||
| "include": ["src"] | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This part is something like async/suspense logic
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.
It is a sync render. "Suspense logic" first renders a fallback html then hydrates it with the resolved content
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.
You could hydrate a shadowroot. It allows for fallbacks content while waiting for the next chunk of the response to stream in:
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.
Who's ready for yet another new framework?
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.
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.
I couldn't get it. I think it's enough. Did you see the bundled result from Marko? It's nearly the same as mine.