Skip to content

Commit 860d403

Browse files
authored
Fix broken NPM distributables (#1331)
1 parent 996f143 commit 860d403

File tree

17 files changed

+66
-35
lines changed

17 files changed

+66
-35
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
src/reactpy/static/*.js*
33
src/reactpy/static/morphdom/
44
src/reactpy/static/pyscript/
5+
src/js/**/*.tgz
6+
src/js/**/LICENSE
57

68
# --- Jupyter ---
79
*.ipynb_checkpoints

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ build_client = ['hatch run "src/build_scripts/build_js_client.py" {args}']
210210
build_app = ['hatch run "src/build_scripts/build_js_app.py" {args}']
211211
publish_event_to_object = [
212212
'hatch run javascript:build_event_to_object',
213-
# FIXME: using npm publish to fix lack of "Trusted Publishing" in Bun
214-
# Ref: https://github.com/oven-sh/bun/issues/15601
215-
'cd "src/js/packages/event-to-object" && bunx npm@11.8.0 publish --provenance --access public',
213+
# FIXME: This is a temporary workaround. We are using `bun pm pack`->`npm publish` to fix missing "Trusted Publishing" support in `bun publish`
214+
# See the following ticket https://github.com/oven-sh/bun/issues/15601
215+
'cd "src/js/packages/event-to-object" && bun pm pack --filename "packages/event-to-object/dist.tgz" && bunx npm@11.8.0 publish dist.tgz --provenance --access public',
216216
]
217217
publish_client = [
218218
'hatch run javascript:build_client',
219-
# FIXME: using npm publish to fix lack of "Trusted Publishing" in Bun
220-
# Ref: https://github.com/oven-sh/bun/issues/15601
221-
'cd "src/js/packages/@reactpy/client" && bunx npm@11.8.0 publish --provenance --access public',
219+
# FIXME: This is a temporary workaround. We are using `bun pm pack`->`npm publish` to fix missing "Trusted Publishing" support in `bun publish`
220+
# See the following ticket https://github.com/oven-sh/bun/issues/15601
221+
'cd "src/js/packages/@reactpy/client" && bun pm pack --filename "packages/@reactpy/client/dist.tgz" && bunx npm@11.8.0 publish dist.tgz --provenance --access public',
222222
]
223223

224224
#########################

src/build_scripts/build_js_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
# dependencies = []
44
# ///
55
import pathlib
6+
import shutil
67
import subprocess
78
import sys
89

910
dev_mode = "--dev" in sys.argv
1011
root_dir = pathlib.Path(__file__).parent.parent.parent
12+
13+
# Copy LICENSE file
14+
shutil.copyfile(
15+
root_dir / "LICENSE", root_dir / "src/js/packages/@reactpy/client/LICENSE"
16+
)
17+
1118
build_commands = [
1219
[
1320
"bun",

src/build_scripts/build_js_event_to_object.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
# dependencies = []
44
# ///
55
import pathlib
6+
import shutil
67
import subprocess
78
import sys
89

910
dev_mode = "--dev" in sys.argv
1011
root_dir = pathlib.Path(__file__).parent.parent.parent
12+
13+
# Copy LICENSE file
14+
shutil.copyfile(
15+
root_dir / "LICENSE", root_dir / "src/js/packages/event-to-object/LICENSE"
16+
)
17+
1118
build_commands = [
1219
[
1320
"bun",

src/build_scripts/clean_js_dir.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
with contextlib.suppress(FileNotFoundError):
2424
shutil.rmtree(dist_dir)
2525

26+
# Delete all `*.tgz` files in `packages/**`
27+
dist_tgz_files = glob.glob(str(js_src_dir / "**/*.tgz"), recursive=True)
28+
for dist_tgz_file in dist_tgz_files:
29+
with contextlib.suppress(FileNotFoundError):
30+
os.remove(dist_tgz_file)
31+
2632
# Delete all `node_modules` folders
2733
node_modules_dirs = glob.glob(str(js_src_dir / "**/node_modules"), recursive=True)
2834
for node_modules_dir in node_modules_dirs:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
43
"outDir": "dist",
54
"rootDir": "src",
5+
"composite": true,
6+
"noEmit": false,
67
"esModuleInterop": true
78
},
89
"extends": "../../../tsconfig.json",

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"event-to-object": "catalog:"
1010
},
1111
"description": "A client for ReactPy implemented in React",
12+
"files": [
13+
"dist",
14+
"src",
15+
"LICENSE"
16+
],
1217
"devDependencies": {
1318
"@types/json-pointer": "catalog:",
1419
"typescript": "catalog:"
@@ -31,5 +36,5 @@
3136
"checkTypes": "tsc --noEmit"
3237
},
3338
"type": "module",
34-
"version": "1.0.2"
39+
"version": "1.0.3"
3540
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
43
"outDir": "dist",
5-
"rootDir": "src"
4+
"rootDir": "src",
5+
"composite": true,
6+
"noEmit": false
67
},
78
"extends": "../../../tsconfig.json",
89
"include": ["src"],

src/js/packages/event-to-object/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"json-pointer": "catalog:"
88
},
99
"description": "Converts a JavaScript events to JSON serializable objects.",
10+
"files": [
11+
"dist",
12+
"src",
13+
"LICENSE"
14+
],
1015
"devDependencies": {
1116
"happy-dom": "^15.0.0",
1217
"lodash": "^4.17.21",
@@ -31,5 +36,5 @@
3136
"checkTypes": "tsc --noEmit"
3237
},
3338
"type": "module",
34-
"version": "1.0.1"
39+
"version": "2.0.0"
3540
}

src/js/packages/event-to-object/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
43
"outDir": "dist",
5-
"rootDir": "src"
4+
"rootDir": "src",
5+
"composite": true,
6+
"noEmit": false
67
},
78
"extends": "../../tsconfig.json",
89
"include": ["src"]

0 commit comments

Comments
 (0)