From f6c8901a83ce9e1837fe038dc51cbd251bde3c0f Mon Sep 17 00:00:00 2001 From: Kartik Puri Date: Thu, 29 Jan 2026 16:41:27 -0800 Subject: [PATCH 1/2] trying out react compiler --- buildScript/webpack.config.js | 2 +- eslint.config.mjs | 3 +++ package.json | 3 ++- yarn.lock | 42 ++++++++++++++++++++++++++--------- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/buildScript/webpack.config.js b/buildScript/webpack.config.js index cb72f1dfe..6b3553317 100644 --- a/buildScript/webpack.config.js +++ b/buildScript/webpack.config.js @@ -162,7 +162,7 @@ export default function makeWebpackConfig(config) { ], '@babel/preset-react' ], - plugins: [ '@babel/plugin-transform-runtime', 'lodash' ] + plugins: [ 'react-compiler', '@babel/plugin-transform-runtime', 'lodash' ] } } }, diff --git a/eslint.config.mjs b/eslint.config.mjs index 83ab4f642..8c9bdfd20 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -92,6 +92,9 @@ export default [ "react/react-in-jsx-scope": 1, "react/self-closing-comp": 1, "react-hooks/rules-of-hooks": "error", // Checks rules of Hooks + "react-hooks/preserve-manual-memoization": "warn", + "react-hooks/static-components": "warn", + "react-hooks/incompatible-library": "warn", "jsdoc/check-param-names": 2, "jsdoc/check-tag-names": 0, "jsdoc/check-types": 0, diff --git a/package.json b/package.json index b6dfc8d54..68bf93967 100644 --- a/package.json +++ b/package.json @@ -70,12 +70,13 @@ "babel-jest": "^24.9", "babel-loader": "^9.1.3", "babel-plugin-lodash": "^3.3", + "babel-plugin-react-compiler": "^1.0.0", "css-loader": "~7.1", "eslint": "~9.38", "eslint-plugin-jsdoc": "~50.8", "eslint-plugin-jsx-a11y": "^6.9.0", "eslint-plugin-react": "~7.37", - "eslint-plugin-react-hooks": "~7.0", + "eslint-plugin-react-hooks": "^7.0.1", "globals": "~16.4", "ink-docstrap": "~1.3", "jest": "^24.9", diff --git a/yarn.lock b/yarn.lock index 312122cf7..3eb5a22fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -186,6 +186,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz#a7054dcc145a967dd4dc8fee845a57c1316c9df8" integrity sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow== +"@babel/helper-validator-identifier@^7.28.5": + version "7.28.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz#010b6938fab7cb7df74aa2bbc06aa503b8fe5fb4" + integrity sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q== + "@babel/helper-validator-option@^7.27.1": version "7.27.1" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f" @@ -916,6 +921,14 @@ "@babel/helper-string-parser" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1" +"@babel/types@^7.26.0": + version "7.28.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.28.6.tgz#c3e9377f1b155005bcc4c46020e7e394e13089df" + integrity sha512-0ZrskXVEHSWIqZM/sQZ4EV3jZJXRkio/WCxaqKZP1g//CEWEPSfeZFcms4XeKBCHU0ZKnIkdJeU/kF+eRp5lBg== + dependencies: + "@babel/helper-string-parser" "^7.27.1" + "@babel/helper-validator-identifier" "^7.28.5" + "@cnakazawa/watch@^1.0.3": version "1.0.4" resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a" @@ -2475,6 +2488,13 @@ babel-plugin-polyfill-regenerator@^0.6.5: dependencies: "@babel/helper-define-polyfill-provider" "^0.6.5" +babel-plugin-react-compiler@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/babel-plugin-react-compiler/-/babel-plugin-react-compiler-1.0.0.tgz#bdf7360a23a4d5ebfca090255da3893efd07425f" + integrity sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw== + dependencies: + "@babel/types" "^7.26.0" + babel-preset-jest@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.9.0.tgz#192b521e2217fb1d1f67cf73f70c336650ad3cdc" @@ -3649,16 +3669,16 @@ eslint-plugin-jsx-a11y@^6.9.0: safe-regex-test "^1.0.3" string.prototype.includes "^2.0.1" -eslint-plugin-react-hooks@~7.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.0.0.tgz#a255a1db826ea42b0e37f160430e4bd0b4b659f9" - integrity sha512-fNXaOwvKwq2+pXiRpXc825Vd63+KM4DLL40Rtlycb8m7fYpp6efrTp1sa6ZbP/Ap58K2bEKFXRmhURE+CJAQWw== +eslint-plugin-react-hooks@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.0.1.tgz#66e258db58ece50723ef20cc159f8aa908219169" + integrity sha512-O0d0m04evaNzEPoSW+59Mezf8Qt0InfgGIBJnpC0h3NH/WjUAR7BIKUfysC6todmtiZ/A0oUVS8Gce0WhBrHsA== dependencies: "@babel/core" "^7.24.4" "@babel/parser" "^7.24.4" hermes-parser "^0.25.1" - zod "^3.22.4 || ^4.0.0" - zod-validation-error "^3.0.3 || ^4.0.0" + zod "^3.25.0 || ^4.0.0" + zod-validation-error "^3.5.0 || ^4.0.0" eslint-plugin-react@~7.37: version "7.37.5" @@ -8761,12 +8781,12 @@ yocto-queue@^1.0.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.2.1.tgz#36d7c4739f775b3cbc28e6136e21aa057adec418" integrity sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg== -"zod-validation-error@^3.0.3 || ^4.0.0": +"zod-validation-error@^3.5.0 || ^4.0.0": version "4.0.2" resolved "https://registry.yarnpkg.com/zod-validation-error/-/zod-validation-error-4.0.2.tgz#bc605eba49ce0fcd598c127fee1c236be3f22918" integrity sha512-Q6/nZLe6jxuU80qb/4uJ4t5v2VEZ44lzQjPDhYJNztRQ4wyWc6VF3D3Kb/fAuPetZQnhS3hnajCf9CsWesghLQ== -"zod@^3.22.4 || ^4.0.0": - version "4.1.12" - resolved "https://registry.yarnpkg.com/zod/-/zod-4.1.12.tgz#64f1ea53d00eab91853195653b5af9eee68970f0" - integrity sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ== +"zod@^3.25.0 || ^4.0.0": + version "4.3.6" + resolved "https://registry.yarnpkg.com/zod/-/zod-4.3.6.tgz#89c56e0aa7d2b05107d894412227087885ab112a" + integrity sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg== From 2d17d2afd2bb78443cbfde2c63fa2d2655886660 Mon Sep 17 00:00:00 2001 From: Kartik Puri Date: Tue, 3 Feb 2026 16:08:43 -0800 Subject: [PATCH 2/2] fix tap UI bug after compiler --- eslint.config.mjs | 19 ++++++++++++++++--- src/firefly/js/ui/tap/TapViewType.jsx | 25 ++++++++++++------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 8c9bdfd20..8d82d13a6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -92,9 +92,22 @@ export default [ "react/react-in-jsx-scope": 1, "react/self-closing-comp": 1, "react-hooks/rules-of-hooks": "error", // Checks rules of Hooks - "react-hooks/preserve-manual-memoization": "warn", - "react-hooks/static-components": "warn", - "react-hooks/incompatible-library": "warn", + 'react-hooks/exhaustive-deps': 'warn', + 'react-hooks/config': 'error', + 'react-hooks/error-boundaries': 'error', + 'react-hooks/component-hook-factories': 'error', + 'react-hooks/gating': 'error', + 'react-hooks/globals': 'error', + 'react-hooks/immutability': 'error', + 'react-hooks/preserve-manual-memoization': 'error', + 'react-hooks/purity': 'error', + 'react-hooks/refs': 'error', + 'react-hooks/set-state-in-effect': 'warn', + 'react-hooks/set-state-in-render': 'error', + 'react-hooks/static-components': 'error', + 'react-hooks/unsupported-syntax': 'warn', + 'react-hooks/use-memo': 'error', + 'react-hooks/incompatible-library': 'warn', "jsdoc/check-param-names": 2, "jsdoc/check-tag-names": 0, "jsdoc/check-types": 0, diff --git a/src/firefly/js/ui/tap/TapViewType.jsx b/src/firefly/js/ui/tap/TapViewType.jsx index 501e63e94..ab90e5e67 100644 --- a/src/firefly/js/ui/tap/TapViewType.jsx +++ b/src/firefly/js/ui/tap/TapViewType.jsx @@ -92,18 +92,18 @@ const expandableTapSectionSx = { }; function AdqlUI({serviceUrl, serviceLabel, servicesShowing, setServicesShowing, setSelectBy, lockService, setError}) { - const [,setCapabilitiesChange] = useState(); // this is just to force a rerender - const capabilities= getLoadedCapability(serviceUrl); + const [capabilities, setCapabilities] = useState(() => getLoadedCapability(serviceUrl)); useEffect(() => { + if (!serviceUrl) return; + setCapabilities(getLoadedCapability(serviceUrl)); if (!isCapabilityLoaded(serviceUrl)) { loadTapCapabilities(serviceUrl) - .then((c) => setCapabilitiesChange(c??{})) - .catch( (error) => { - setError(`Fail to retrieve capability for: ${serviceUrl}`); - }); + .then((c) => setCapabilities(c ?? getLoadedCapability(serviceUrl))) + .catch(() => setError(`Fail to retrieve capability for: ${serviceUrl}`)); } }, [serviceUrl]); + return ( @@ -155,7 +155,6 @@ function BasicUI(props) { const [schemaName, schemaRef, setSchemaName] = useStateRef(lockedSchemaName || searchParams.schema || initState.schemaName || urlApi.schema); const [tableName, tableRef, setTableName] = useStateRef(lockedTableName || searchParams.table || initState.tableName || urlApi.table); const [obsCoreEnabled, setObsCoreEnabled] = useState(initState.obsCoreEnabled || initArgs.urlApi?.selectBy === 'obscore'); - const [,setCapabilitiesChange] = useState(); // this is just to force a rerender const [schemaOptions, setSchemaOptions] = useState(); const [tableOptions, setTableOptions] = useState(); const [tableTableModel, setTableTableModel] = useState(); @@ -165,19 +164,19 @@ function BasicUI(props) { const schemaIsLocked= !forceLockObsCore && Boolean(lockedSchemaName); const tableIsLocked= !forceLockObsCore && Boolean(lockedTableName); - - const capabilities= getLoadedCapability(serviceUrl); + const [capabilities, setCapabilities] = useState(() => getLoadedCapability(serviceUrl)); useEffect(() => { + if (!serviceUrl) return; + setCapabilities(getLoadedCapability(serviceUrl)); if (!isCapabilityLoaded(serviceUrl)) { loadTapCapabilities(serviceUrl) - .then((c) => setCapabilitiesChange(c??{})) - .catch( (error) => { - setError(`${SERVICE_EXIST_ERROR}: ${serviceUrl}`); - }); + .then((c) => setCapabilities(c ?? getLoadedCapability(serviceUrl))) + .catch(() => setError(`${SERVICE_EXIST_ERROR}: ${serviceUrl}`)); } }, [serviceUrl]); + const setLockToObsCore= (doLock) => { if (!hasObsCoreTable || !obsCoreTableModel?.tableData?.data) return; if (doLock) {