Skip to content

Commit 7d47f4f

Browse files
authored
Build JS distributables using local javascript (#1243)
1 parent 8dece1d commit 7d47f4f

File tree

8 files changed

+63
-65
lines changed

8 files changed

+63
-65
lines changed

.editorconfig

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
charset = utf-8
11+
end_of_line = lf
12+
13+
[*.py]
14+
indent_size = 4
15+
max_line_length = 120
16+
17+
[*.md]
18+
indent_size = 4
19+
20+
[*.html]
21+
max_line_length = off
22+
23+
[*.js]
24+
max_line_length = off
25+
26+
[*.css]
27+
indent_size = 4
28+
max_line_length = off
29+
30+
# Tests can violate line width restrictions in the interest of clarity.
31+
[**/test_*.py]
32+
max_line_length = off

src/js/app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"license": "MIT",
44
"main": "src/dist/index.js",
55
"types": "src/dist/index.d.ts",
6-
"description": "A client application for ReactPy implemented in React",
6+
"description": "Main entry point for ReactPy.",
77
"dependencies": {
8-
"@reactpy/client": "^0.2.0",
8+
"@reactpy/client": "file:../packages/@reactpy/client",
99
"preact": "^10.7.0"
1010
},
1111
"devDependencies": {

src/js/package-lock.json

+13-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"license": "MIT",
77
"name": "@reactpy/client",
88
"type": "module",
9-
"version": "0.3.1",
9+
"version": "0.3.2",
1010
"dependencies": {
11-
"event-to-object": "^0.1.2",
11+
"event-to-object": "file:../event-to-object",
1212
"json-pointer": "^0.6.2"
1313
},
1414
"devDependencies": {

src/py/reactpy/.temp.py

-28
This file was deleted.

src/py/reactpy/pyproject.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ all = ["types"]
105105

106106
[tool.hatch.build.targets.sdist]
107107
artifacts = ["_static"]
108+
exclude = ["scripts/", "tests/"]
108109

109110
[tool.hatch.build.targets.wheel]
110111
artifacts = ["_static"]
112+
exclude = ["scripts/", "tests/"]
111113

112114
[[tool.hatch.build.hooks.build-scripts.scripts]]
113-
out_dir = "reactpy/_static"
114115
commands = [
115-
# link the js directory if it doesn't exist - use Python to avoid platform differences
116-
"python -c \"import pathlib as p;js=p.Path('js');js.unlink(missing_ok=True);js.symlink_to(p.Path('..','..','js').resolve(),target_is_directory=True);\"",
117-
"cd js && npm ci && npm run build",
116+
"cd .. && cd .. && cd js && npm install && npm run build",
117+
"cd scripts && python copy_js_output.py",
118118
]
119-
artifacts = ["js/app/dist/"]
119+
artifacts = []
120120

121121
# --- Pytest ---------------------------------------------------------------------------
122122

src/py/reactpy/reactpy/backend/_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
MODULES_PATH = PATH_PREFIX / "modules"
2222
ASSETS_PATH = PATH_PREFIX / "assets"
2323
STREAM_PATH = PATH_PREFIX / "stream"
24-
CLIENT_BUILD_DIR = Path(_reactpy_file_path).parent / "_static" / "js" / "app" / "dist"
24+
CLIENT_BUILD_DIR = Path(_reactpy_file_path).parent / "_static"
2525

2626

2727
async def serve_with_uvicorn(
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from pathlib import Path
2+
from shutil import copytree, rmtree
3+
4+
output_dir = Path(__file__).parent.parent / "reactpy" / "_static"
5+
source_dir = Path(__file__).parent.parent.parent.parent / "js" / "app" / "dist"
6+
rmtree(output_dir, ignore_errors=True)
7+
copytree(source_dir, output_dir)
8+
print("JavaScript output copied to reactpy/_static") # noqa: T201

0 commit comments

Comments
 (0)