Skip to content

Commit fe84808

Browse files
committed
Seemingly fully functional Python build?
1 parent a15d33e commit fe84808

File tree

8 files changed

+28
-38
lines changed

8 files changed

+28
-38
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# --- Build Artifacts ---
2-
src/reactpy/static
2+
src/reactpy/static/**/index.js*
33

44
# --- Jupyter ---
55
*.ipynb_checkpoints

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ installer = "uv"
5858

5959
[[tool.hatch.build.hooks.build-scripts.scripts]]
6060
commands = [
61-
"bun install --cwd 'src/js/packages/@reactpy/app' --production --frozen-lockfile",
62-
"bun build './src/js/packages/@reactpy/app/src/index.ts' --outdir './src/js/packages/@reactpy/app/dist' --minify --sourcemap=linked",
63-
# "cd scripts && python copy_js_output.py",
61+
'bun install --cwd "src/js/packages/@reactpy/app" --production --frozen-lockfile',
62+
# TODO: Remove 'assets' from this path after turning ReactPy into ASGI middleware.
63+
'bun build "./src/js/packages/@reactpy/app/src/index.ts" --outdir "./src/reactpy/static/assets/" --minify --sourcemap=linked',
6464
]
6565
artifacts = []
6666

src/build_scripts/copy_js_output.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/js/packages/@reactpy/app/index.html

Lines changed: 0 additions & 15 deletions
This file was deleted.
-14.6 KB
Binary file not shown.

src/js/packages/@reactpy/app/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mount, SimpleReactPyClient } from "@reactpy/client";
22

3-
export function app(element: HTMLElement) {
3+
function app(element: HTMLElement) {
44
const client = new SimpleReactPyClient({
55
serverLocation: {
66
url: document.location.origin,
@@ -10,3 +10,11 @@ export function app(element: HTMLElement) {
1010
});
1111
mount(element, client);
1212
}
13+
14+
let element = document.getElementById("app");
15+
if (element){
16+
app(element);
17+
}
18+
else {
19+
console.error("Element with id 'app' not found");
20+
}

src/reactpy/backend/_common.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,7 @@ def vdom_head_elements_to_html(head: Sequence[VdomDict] | VdomDict | str) -> str
116116
class CommonOptions:
117117
"""Options for ReactPy's built-in backed server implementations"""
118118

119-
head: Sequence[VdomDict] | VdomDict | str = (
120-
html.title("ReactPy"),
121-
html.link(
122-
{
123-
"rel": "icon",
124-
"href": "/_reactpy/assets/reactpy-logo.ico",
125-
"type": "image/x-icon",
126-
}
127-
),
128-
)
119+
head: Sequence[VdomDict] | VdomDict | str = (html.title("ReactPy"),)
129120
"""Add elements to the ``<head>`` of the application.
130121
131122
For example, this can be used to customize the title of the page, link extra

src/reactpy/static/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<script type="module" crossorigin src="/_reactpy/assets/index.js"></script>
7+
{__head__}
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
</body>
13+
14+
</html>

0 commit comments

Comments
 (0)