-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrates
examples/tsjs/
to use Preact.
Refs #71.
- Loading branch information
Showing
16 changed files
with
151 additions
and
130 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
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export function renderJsChild(): string; | ||
import { VNode } from 'preact'; | ||
|
||
export function JsChild(): VNode; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export function renderJsChild() { | ||
return ` | ||
<div class="js-child"> | ||
<span>JS child</span> | ||
</div> | ||
`.trim(); | ||
import { h } from 'preact'; | ||
|
||
export function JsChild() { | ||
return h('div', { className: 'js-child' }, [ | ||
h('span', {}, [ 'JS child' ]), | ||
]); | ||
} |
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
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
export function renderJsParent(): string; | ||
import { VNode } from 'preact'; | ||
|
||
export function JsParent(): VNode; |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { renderTsChild } from '../ts_child/ts_child.mjs'; | ||
import { h } from 'preact'; | ||
import { TsChild } from '../ts_child/ts_child.js'; | ||
|
||
export function renderJsParent() { | ||
return ` | ||
<div class="js-parent"> | ||
<span>JS parent</span> | ||
${renderTsChild()} | ||
</div> | ||
`.trim(); | ||
export function JsParent() { | ||
return h('div', { className: 'js-parent' }, [ | ||
h('span', {}, [ 'JS parent' ]), | ||
TsChild(), | ||
]); | ||
} |
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 @@ | ||
{ | ||
"type": "module" | ||
} |
This file was deleted.
Oops, something went wrong.
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,93 @@ | ||
import { PrerenderResource, includeScript, renderToHtml } from '@rules_prerender/preact'; | ||
import { JsParent } from './js_parent/js_parent.mjs'; | ||
import { TsParent } from './ts_parent/ts_parent.js'; | ||
|
||
export default function*(): Generator<PrerenderResource, void, void> { | ||
// Index page to list the various test cases. | ||
yield PrerenderResource.of('/index.html', renderToHtml( | ||
<html> | ||
<head> | ||
<title>TS/JS</title> | ||
<meta charSet='utf8' /> | ||
</head> | ||
<body> | ||
<ul> | ||
<li><a href='/js-depends-on-ts.html'>JS depends on TS</a></li> | ||
<li><a href='/ts-depends-on-js.html'>TS depends on JS</a></li> | ||
<li><a href='/ts-script-depends-on-js-script.html'> | ||
TS script depends on JS script | ||
</a></li> | ||
<li><a href='/js-script-depends-on-ts-script.html'> | ||
JS script depends on TS script | ||
</a></li> | ||
</ul> | ||
</body> | ||
</html>, | ||
)); | ||
|
||
// Test case for JS depending on TS. | ||
yield PrerenderResource.of('/js-depends-on-ts.html', renderToHtml( | ||
<html> | ||
<head> | ||
<title>JS depends on TS</title> | ||
<meta charSet='utf8' /> | ||
</head> | ||
<body> | ||
<JsParent /> | ||
</body> | ||
</html>, | ||
)); | ||
|
||
// Test case for TS depending on JS. | ||
yield PrerenderResource.of('/ts-depends-on-js.html', renderToHtml( | ||
<html> | ||
<head> | ||
<title>TS depends on JS</title> | ||
<meta charSet='utf8' /> | ||
</head> | ||
<body> | ||
<TsParent /> | ||
</body> | ||
</html>, | ||
)); | ||
|
||
// Test case for client-side TS depending on JS. | ||
yield PrerenderResource.of( | ||
'/ts-script-depends-on-js-script.html', | ||
renderToHtml( | ||
<html> | ||
<head> | ||
<title>TS script depends on JS script</title> | ||
<meta charSet='utf8' /> | ||
</head> | ||
<body> | ||
<div id='replace-ts-parent-script'> | ||
Text to be replaced by client-side JS. | ||
</div> | ||
|
||
{includeScript('./ts_parent_script.mjs', import.meta)} | ||
</body> | ||
</html>, | ||
), | ||
); | ||
|
||
// Test case for client-side JS depending on TS. | ||
yield PrerenderResource.of( | ||
'/js-script-depends-on-ts-script.html', | ||
renderToHtml( | ||
<html> | ||
<head> | ||
<title>JS script depends on TS script</title> | ||
<meta charSet='utf8' /> | ||
</head> | ||
<body> | ||
<div id='replace-js-parent-script'> | ||
Text to be replaced by client-side JS. | ||
</div> | ||
|
||
{includeScript('./js_parent_script.mjs', import.meta)} | ||
</body> | ||
</html>, | ||
), | ||
); | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import { VNode } from 'preact'; | ||
|
||
export function TsChild(): VNode { | ||
return <div class="ts-child"> | ||
<span>TS child</span> | ||
</div>; | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
import { VNode } from 'preact'; | ||
import { JsChild } from '../js_child/js_child.mjs'; | ||
|
||
export function TsParent(): VNode { | ||
return <div class="ts-parent"> | ||
<span>TS parent</span> | ||
<JsChild /> | ||
</div>; | ||
} |