Skip to content

Build JS distributables using local javascript #1243

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
end_of_line = lf

[*.py]
indent_size = 4
max_line_length = 120

[*.md]
indent_size = 4

[*.html]
max_line_length = off

[*.js]
max_line_length = off

[*.css]
indent_size = 4
max_line_length = off

# Tests can violate line width restrictions in the interest of clarity.
[**/test_*.py]
max_line_length = off
4 changes: 2 additions & 2 deletions src/js/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"license": "MIT",
"main": "src/dist/index.js",
"types": "src/dist/index.d.ts",
"description": "A client application for ReactPy implemented in React",
"description": "Main entry point for ReactPy.",
"dependencies": {
"@reactpy/client": "^0.2.0",
"@reactpy/client": "file:../packages/@reactpy/client",
"preact": "^10.7.0"
},
"devDependencies": {
Expand Down
40 changes: 13 additions & 27 deletions src/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/js/packages/@reactpy/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"license": "MIT",
"name": "@reactpy/client",
"type": "module",
"version": "0.3.1",
"version": "0.3.2",
"dependencies": {
"event-to-object": "^0.1.2",
"event-to-object": "file:../event-to-object",
"json-pointer": "^0.6.2"
},
"devDependencies": {
Expand Down
28 changes: 0 additions & 28 deletions src/py/reactpy/.temp.py

This file was deleted.

10 changes: 5 additions & 5 deletions src/py/reactpy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ all = ["types"]

[tool.hatch.build.targets.sdist]
artifacts = ["_static"]
exclude = ["scripts/", "tests/"]

[tool.hatch.build.targets.wheel]
artifacts = ["_static"]
exclude = ["scripts/", "tests/"]

[[tool.hatch.build.hooks.build-scripts.scripts]]
out_dir = "reactpy/_static"
commands = [
# link the js directory if it doesn't exist - use Python to avoid platform differences
"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);\"",
"cd js && npm ci && npm run build",
"cd .. && cd .. && cd js && npm install && npm run build",
"cd scripts && python copy_js_output.py",
]
artifacts = ["js/app/dist/"]
artifacts = []

# --- Pytest ---------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/py/reactpy/reactpy/backend/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
MODULES_PATH = PATH_PREFIX / "modules"
ASSETS_PATH = PATH_PREFIX / "assets"
STREAM_PATH = PATH_PREFIX / "stream"
CLIENT_BUILD_DIR = Path(_reactpy_file_path).parent / "_static" / "js" / "app" / "dist"
CLIENT_BUILD_DIR = Path(_reactpy_file_path).parent / "_static"


async def serve_with_uvicorn(
Expand Down
8 changes: 8 additions & 0 deletions src/py/reactpy/scripts/copy_js_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pathlib import Path
from shutil import copytree, rmtree

output_dir = Path(__file__).parent.parent / "reactpy" / "_static"
source_dir = Path(__file__).parent.parent.parent.parent / "js" / "app" / "dist"
rmtree(output_dir, ignore_errors=True)
copytree(source_dir, output_dir)
print("JavaScript output copied to reactpy/_static") # noqa: T201
Loading