Pārlūkot izejas kodu

do not run nextjs check on import (#5352)

* do not run nextjs check on import

* dang it darglint
Khaleel Al-Adhami 1 dienu atpakaļ
vecāks
revīzija
71fa6a9f7e
2 mainītis faili ar 26 papildinājumiem un 15 dzēšanām
  1. 4 2
      reflex/app.py
  2. 22 13
      reflex/constants/installer.py

+ 4 - 2
reflex/app.py

@@ -1019,11 +1019,13 @@ class App(MiddlewareMixin, LifespanMixin):
         Example:
             >>> _get_frontend_packages({"react": "16.14.0", "react-dom": "16.14.0"})
         """
+        dependencies = constants.PackageJson.DEPENDENCIES
+        dev_dependencies = constants.PackageJson.DEV_DEPENDENCIES
         page_imports = {
             i
             for i, tags in imports.items()
-            if i not in constants.PackageJson.DEPENDENCIES
-            and i not in constants.PackageJson.DEV_DEPENDENCIES
+            if i not in dependencies
+            and i not in dev_dependencies
             and not any(i.startswith(prefix) for prefix in ["/", "$/", ".", "next/"])
             and i != ""
             and any(tag.install for tag in tags)

+ 22 - 13
reflex/constants/installer.py

@@ -113,19 +113,28 @@ class PackageJson(SimpleNamespace):
 
     _react_version = _determine_react_version()
 
-    DEPENDENCIES = {
-        "@emotion/react": "11.14.0",
-        "axios": "1.9.0",
-        "json5": "2.2.3",
-        "next": _determine_nextjs_version(),
-        "next-sitemap": "4.2.3",
-        "next-themes": "0.4.6",
-        "react": _react_version,
-        "react-dom": _react_version,
-        "react-focus-lock": "2.13.6",
-        "socket.io-client": "4.8.1",
-        "universal-cookie": "7.2.2",
-    }
+    @classproperty
+    @classmethod
+    def DEPENDENCIES(cls) -> dict[str, str]:
+        """The dependencies to include in package.json.
+
+        Returns:
+            A dictionary of dependencies with their versions.
+        """
+        return {
+            "@emotion/react": "11.14.0",
+            "axios": "1.9.0",
+            "json5": "2.2.3",
+            "next": _determine_nextjs_version(),
+            "next-sitemap": "4.2.3",
+            "next-themes": "0.4.6",
+            "react": cls._react_version,
+            "react-dom": cls._react_version,
+            "react-focus-lock": "2.13.6",
+            "socket.io-client": "4.8.1",
+            "universal-cookie": "7.2.2",
+        }
+
     DEV_DEPENDENCIES = {
         "autoprefixer": "10.4.21",
         "postcss": "8.5.3",