diff --git a/pyproject.toml b/pyproject.toml index 868e884ac..8c348f1e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,9 +60,16 @@ license-files = { paths = ["LICENSE"] } installer = "uv" [[tool.hatch.build.hooks.build-scripts.scripts]] +# Note: `hatch` can't be called within `build-scripts` when installing packages in editable mode, so we have to write the commands long-form commands = [ - "hatch run javascript:build", - 'hatch run "src/build_scripts/copy_dir.py" "src/js/packages/@reactpy/app/dist" "src/reactpy/static/assets"', + 'python "src/build_scripts/clean_js_dir.py"', + 'bun install --cwd "src/js/packages/event-to-object"', + 'bun run --cwd "src/js/packages/event-to-object" build', + 'bun install --cwd "src/js/packages/@reactpy/client"', + 'bun run --cwd "src/js/packages/@reactpy/client" build', + 'bun install --cwd "src/js/packages/@reactpy/app"', + 'bun run --cwd "src/js/packages/@reactpy/app" build', + 'python "src/build_scripts/copy_dir.py" "src/js/packages/@reactpy/app/dist" "src/reactpy/static/assets"', ] artifacts = [] diff --git a/src/js/.eslintrc.json b/src/js/.eslintrc.json deleted file mode 100644 index 8536da62b..000000000 --- a/src/js/.eslintrc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "env": { - "browser": true, - "node": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": ["react", "@typescript-eslint"], - "rules": { - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-empty-function": "off", - "react/prop-types": "off" - }, - "settings": { - "react": { - "version": "detect" - } - } -} diff --git a/src/js/bun.lockb b/src/js/bun.lockb index e935b9cc8..ff28eeb7f 100644 Binary files a/src/js/bun.lockb and b/src/js/bun.lockb differ diff --git a/src/js/eslint.config.mjs b/src/js/eslint.config.mjs new file mode 100644 index 000000000..7509afebe --- /dev/null +++ b/src/js/eslint.config.mjs @@ -0,0 +1,58 @@ +import react from "eslint-plugin-react"; +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [ + ...compat.extends( + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", + ), + { + ignores: ["**/node_modules/", "**/dist/"], + }, + { + plugins: { + react, + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + + parser: tsParser, + ecmaVersion: "latest", + sourceType: "module", + }, + + settings: { + react: { + version: "detect", + }, + }, + + rules: { + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-empty-function": "off", + "react/prop-types": "off", + }, + }, +]; diff --git a/src/js/package.json b/src/js/package.json index bb21320c4..26962b2c6 100644 --- a/src/js/package.json +++ b/src/js/package.json @@ -1,10 +1,13 @@ { "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.58.0", - "@typescript-eslint/parser": "^5.58.0", - "eslint": "^8.38.0", - "eslint-plugin-react": "^7.32.2", - "prettier": "^3.0.0-alpha.6" + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.18.0", + "@typescript-eslint/eslint-plugin": "^8.21.0", + "@typescript-eslint/parser": "^8.21.0", + "eslint": "^9.18.0", + "eslint-plugin-react": "^7.37.4", + "globals": "^15.14.0", + "prettier": "^3.4.2" }, "license": "MIT", "scripts": { diff --git a/src/js/packages/@reactpy/app/.eslintrc.json b/src/js/packages/@reactpy/app/.eslintrc.json deleted file mode 100644 index 442025c3d..000000000 --- a/src/js/packages/@reactpy/app/.eslintrc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": ["react", "@typescript-eslint"], - "rules": {} -} diff --git a/src/js/packages/@reactpy/app/bun.lockb b/src/js/packages/@reactpy/app/bun.lockb index 8275858eb..b32e03eae 100644 Binary files a/src/js/packages/@reactpy/app/bun.lockb and b/src/js/packages/@reactpy/app/bun.lockb differ diff --git a/src/js/packages/@reactpy/app/eslint.config.mjs b/src/js/packages/@reactpy/app/eslint.config.mjs new file mode 100644 index 000000000..7c41582b5 --- /dev/null +++ b/src/js/packages/@reactpy/app/eslint.config.mjs @@ -0,0 +1,42 @@ +import react from "eslint-plugin-react"; +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [ + ...compat.extends( + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", + ), + { + plugins: { + react, + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: tsParser, + ecmaVersion: "latest", + sourceType: "module", + }, + + rules: {}, + }, +]; diff --git a/src/js/packages/@reactpy/app/package.json b/src/js/packages/@reactpy/app/package.json index c0f27e92f..21e3bcd96 100644 --- a/src/js/packages/@reactpy/app/package.json +++ b/src/js/packages/@reactpy/app/package.json @@ -5,11 +5,9 @@ "dependencies": { "@reactpy/client": "file:../client", "event-to-object": "file:../../event-to-object", - "preact": "^10.7.0" + "preact": "^10.25.4" }, "devDependencies": { - "@types/react": "^17.0", - "@types/react-dom": "^17.0", "typescript": "^5.7.3" }, "scripts": { diff --git a/src/js/packages/@reactpy/client/bun.lockb b/src/js/packages/@reactpy/client/bun.lockb index 5e4b05817..35e6ef1c5 100644 Binary files a/src/js/packages/@reactpy/client/bun.lockb and b/src/js/packages/@reactpy/client/bun.lockb differ diff --git a/src/js/packages/@reactpy/client/package.json b/src/js/packages/@reactpy/client/package.json index cf97a5bff..b6b12830f 100644 --- a/src/js/packages/@reactpy/client/package.json +++ b/src/js/packages/@reactpy/client/package.json @@ -21,7 +21,7 @@ "preact": "^10.25.4" }, "devDependencies": { - "@types/json-pointer": "^1.0.31", + "@types/json-pointer": "^1.0.34", "@types/react": "^17.0", "@types/react-dom": "^17.0", "typescript": "^5.7.3" diff --git a/src/js/packages/event-to-object/bun.lockb b/src/js/packages/event-to-object/bun.lockb index e0f4b6a4b..d3ca6e7e5 100644 Binary files a/src/js/packages/event-to-object/bun.lockb and b/src/js/packages/event-to-object/bun.lockb differ diff --git a/src/js/packages/event-to-object/package.json b/src/js/packages/event-to-object/package.json index dd674d162..2f3852120 100644 --- a/src/js/packages/event-to-object/package.json +++ b/src/js/packages/event-to-object/package.json @@ -22,9 +22,9 @@ "devDependencies": { "happy-dom": "^8.9.0", "lodash": "^4.17.21", - "tsm": "^2.0.0", + "tsm": "^2.3.0", "typescript": "^5.7.3", - "uvu": "^0.5.1" + "uvu": "^0.5.6" }, "scripts": { "build": "tsc -b",