Skip to content

Commit e1a8f93

Browse files
committed
Rewrite JS build steps. Rewrite fetching logic for remote components, React, and React-DOM.
1 parent 9216c92 commit e1a8f93

File tree

22 files changed

+382
-158
lines changed

22 files changed

+382
-158
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
uses: ./.github/workflows/.hatch-run.yml
1111
with:
1212
job-name: "Publish to PyPI"
13-
run-cmd: "hatch build --clean && hatch publish --yes"
13+
run-cmd: "hatch run javascript:build && hatch build --clean && hatch publish --yes"
1414
secrets:
1515
pypi-username: ${{ secrets.PYPI_USERNAME }}
1616
pypi-password: ${{ secrets.PYPI_PASSWORD }}

pyproject.toml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ reactpy = "reactpy._console.cli:entry_point"
7272

7373
[[tool.hatch.build.hooks.build-scripts.scripts]]
7474
commands = [
75-
"hatch --env default run javascript:build",
76-
'python "src/build_scripts/copy_dir.py" "src/js/node_modules/@pyscript/core/dist" "src/reactpy/static/pyscript"',
77-
'python "src/build_scripts/copy_dir.py" "src/js/node_modules/morphdom/dist" "src/reactpy/static/morphdom"',
75+
'hatch --env default run "src/build_scripts/copy_dir.py" "src/js/node_modules/@pyscript/core/dist" "src/reactpy/static/pyscript"',
76+
'hatch --env default run "src/build_scripts/copy_dir.py" "src/js/node_modules/morphdom/dist" "src/reactpy/static/morphdom"',
7877
]
7978
artifacts = []
8079

@@ -84,13 +83,15 @@ artifacts = []
8483
[tool.hatch.envs.hatch-test.scripts]
8584
run = [
8685
'hatch --env default run "src/build_scripts/install_playwright.py"',
86+
"hatch --env default run javascript:build --dev",
8787
"hatch --env default build -t wheel",
8888
"pytest{env:HATCH_TEST_ARGS:} {args}",
8989
]
9090
run-cov = [
91-
'hatch --env default run "src/build_scripts/delete_old_coverage.py"',
9291
'hatch --env default run "src/build_scripts/install_playwright.py"',
92+
"hatch --env default run javascript:build --dev",
9393
"hatch --env default build -t wheel",
94+
'hatch --env default run "src/build_scripts/delete_old_coverage.py"',
9495
"coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}",
9596
]
9697
cov-combine = "coverage combine"
@@ -198,22 +199,15 @@ test = ['hatch run javascript:build_event_to_object', 'bun test']
198199
build = [
199200
'hatch run "src/build_scripts/clean_js_dir.py"',
200201
'bun install --cwd "src/js"',
201-
'hatch run javascript:build_event_to_object',
202-
'hatch run javascript:build_client',
203-
'hatch run javascript:build_app',
202+
'hatch run javascript:build_event_to_object {args}',
203+
'hatch run javascript:build_client {args}',
204+
'hatch run javascript:build_app {args}',
204205
]
205206
build_event_to_object = [
206-
'bun install --cwd "src/js/packages/event-to-object"',
207-
'bun run --cwd "src/js/packages/event-to-object" build',
208-
]
209-
build_client = [
210-
'bun install --cwd "src/js/packages/@reactpy/client"',
211-
'bun run --cwd "src/js/packages/@reactpy/client" build',
212-
]
213-
build_app = [
214-
'bun install --cwd "src/js/packages/@reactpy/app"',
215-
'bun run --cwd "src/js/packages/@reactpy/app" build',
207+
'hatch run "src/build_scripts/build_js_event_to_object.py" {args}',
216208
]
209+
build_client = ['hatch run "src/build_scripts/build_js_client.py" {args}']
210+
build_app = ['hatch run "src/build_scripts/build_js_app.py" {args}']
217211
publish_event_to_object = [
218212
'hatch run javascript:build_event_to_object',
219213
'cd "src/js/packages/event-to-object" && bun publish --access public',

src/build_scripts/build_js_app.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# /// script
2+
# requires-python = ">=3.11"
3+
# dependencies = []
4+
# ///
5+
import pathlib
6+
import subprocess
7+
import sys
8+
9+
dev_mode = "--dev" in sys.argv
10+
root_dir = pathlib.Path(__file__).parent.parent.parent
11+
build_commands = [
12+
[
13+
"bun",
14+
"install",
15+
"--cwd",
16+
"src/js/packages/@reactpy/app",
17+
*([] if dev_mode else ["--production"]),
18+
],
19+
[
20+
"bun",
21+
"run",
22+
"--cwd",
23+
"src/js/packages/@reactpy/app",
24+
"buildDev" if dev_mode else "build",
25+
],
26+
]
27+
28+
for command in build_commands:
29+
print(f"Running command: '{command}'...") # noqa: T201
30+
subprocess.run(command, check=True, cwd=root_dir) # noqa: S603
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# /// script
2+
# requires-python = ">=3.11"
3+
# dependencies = []
4+
# ///
5+
import pathlib
6+
import subprocess
7+
import sys
8+
9+
dev_mode = "--dev" in sys.argv
10+
root_dir = pathlib.Path(__file__).parent.parent.parent
11+
build_commands = [
12+
[
13+
"bun",
14+
"install",
15+
"--cwd",
16+
"src/js/packages/@reactpy/client",
17+
*([] if dev_mode else ["--production"]),
18+
],
19+
[
20+
"bun",
21+
"run",
22+
"--cwd",
23+
"src/js/packages/@reactpy/client",
24+
"build",
25+
],
26+
]
27+
28+
for command in build_commands:
29+
print(f"Running command: '{command}'...") # noqa: T201
30+
subprocess.run(command, check=True, cwd=root_dir) # noqa: S603
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# /// script
2+
# requires-python = ">=3.11"
3+
# dependencies = []
4+
# ///
5+
import pathlib
6+
import subprocess
7+
import sys
8+
9+
dev_mode = "--dev" in sys.argv
10+
root_dir = pathlib.Path(__file__).parent.parent.parent
11+
build_commands = [
12+
[
13+
"bun",
14+
"install",
15+
"--cwd",
16+
"src/js/packages/event-to-object",
17+
*([] if dev_mode else ["--production"]),
18+
],
19+
[
20+
"bun",
21+
"run",
22+
"--cwd",
23+
"src/js/packages/event-to-object",
24+
"build",
25+
],
26+
]
27+
28+
for command in build_commands:
29+
print(f"Running command: '{command}'...") # noqa: T201
30+
subprocess.run(command, check=True, cwd=root_dir) # noqa: S603

src/js/bun.lockb

0 Bytes
Binary file not shown.

src/js/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"workspaces": [
3-
"packages/*",
4-
"packages/@reactpy/*"
3+
"packages/event-to-object",
4+
"packages/@reactpy/app",
5+
"packages/@reactpy/client"
56
],
67
"catalog": {
78
"preact": "^10.27.2",

src/js/packages/@reactpy/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"license": "MIT",
1414
"name": "@reactpy/app",
1515
"scripts": {
16-
"build": "bun build \"src/index.ts\" \"src/react.ts\" \"src/react-dom.ts\" \"src/react-jsx-runtime.ts\" --outdir=\"../../../../reactpy/static/\" --minify --sourcemap=\"linked\" --splitting",
16+
"build": "bun build \"src/index.ts\" \"src/preact.ts\" \"src/preact-dom.ts\" \"src/preact-jsx-runtime.ts\" --outdir=\"../../../../reactpy/static/\" --minify --production --sourcemap=\"linked\" --splitting",
17+
"buildDev": "bun build \"src/index.ts\" \"src/preact.ts\" \"src/preact-dom.ts\" \"src/preact-jsx-runtime.ts\" --outdir=\"../../../../reactpy/static/\" --sourcemap=\"linked\" --splitting",
1718
"checkTypes": "tsc --noEmit"
1819
}
1920
}
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "preact/compat/jsx-runtime";

0 commit comments

Comments
 (0)