[PR #354] [MERGED] Add TypeScript Runtime Support and add Prisma 7 Compatibility #383

Closed
opened 2026-02-26 12:41:12 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/community-scripts/ProxmoxVE-Local/pull/354
Author: @MickLesk
Created: 11/28/2025
Status: Merged
Merged: 11/28/2025
Merged by: @michelroegl-brunner

Base: mainHead: bugfixing_bumps


📝 Commits (10+)

  • 40805f3 Update dependencies and adjust TypeScript JSX setting
  • f467b9a fix vulnerabilities
  • 9c759ba fix: ESLint/TypeScript fixes - nullish coalescing, regexp-exec, optional-chain, unescaped-entities, unused-vars, type-safety
  • d40aeb6 Refactor scripts grid and filter handling for robustness
  • 48cf86a Refactor nullish checks and add type safety
  • b5bce88 Refactor InstalledScriptsTab for code style consistency
  • c266c4c Refactor InstalledScriptsTab for code style consistency
  • 41a9c0a Switch to ESLint CLI (Deprecation of ESLint)
  • ec23600 Switch ESLint config to eslint-config-next/core-web-vitals
  • 1945b14 Update ESLint config to use FlatCompat and expand ignores

📊 Changes

53 files changed (+9546 additions, -4969 deletions)

View changed files

📝 .gitignore (+3 -0)
📝 eslint.config.js (+15 -12)
📝 next.config.js (+14 -24)
📝 package-lock.json (+1178 -204)
📝 package.json (+42 -37)
prisma.config.ts (+20 -0)
📝 prisma/schema.prisma (+2 -2)
📝 server.js (+220 -39)
📝 src/app/_components/AuthProvider.tsx (+45 -30)
📝 src/app/_components/BackupWarningModal.tsx (+27 -20)
📝 src/app/_components/BackupsTab.tsx (+172 -130)
📝 src/app/_components/DownloadedScriptsTab.tsx (+226 -157)
📝 src/app/_components/FilterBar.tsx (+337 -306)
📝 src/app/_components/GeneralSettingsModal.tsx (+968 -576)
📝 src/app/_components/HelpModal.tsx (+1614 -604)
📝 src/app/_components/InstalledScriptsTab.tsx (+1264 -836)
📝 src/app/_components/LoadingModal.tsx (+42 -27)
📝 src/app/_components/PBSCredentialsModal.tsx (+133 -86)
📝 src/app/_components/ScriptCard.tsx (+66 -40)
📝 src/app/_components/ScriptCardList.tsx (+142 -65)

...and 33 more files

📄 Description

Closes: #347 #346 #345 #344 #343


✍️ Description

This PR introduces comprehensive TypeScript runtime support via tsx and resolves critical compatibility issues with Prisma 7, enabling the application to run successfully in production. The changes span type safety improvements, module resolution fixes, and production deployment readiness.


📋 Changes Summary (30 Commits)

🔧 Core Infrastructure Changes

TypeScript Runtime Support

  • Added tsx@^4.19.4 as a production dependency
  • Updated start script: node server.jsnode --import tsx server.js
  • Updated dev:server script for consistency: node --import tsx server.js
  • Enables native TypeScript execution without compilation step
  • Supports .ts file loading in production environment

Module Resolution & Imports

  • Fixed import paths across all service files for ESM compatibility
  • Added .ts extensions to TypeScript imports where required
  • Updated relative imports to work with tsx loader
  • Ensured consistent import patterns across codebase

🐛 Bug Fixes

Prisma 7 Compatibility

  • Updated src/server/db.js to properly import Prisma 7 client
  • Fixed path resolution for prisma/generated/prisma/client.ts
  • Handled ESM/CJS interoperability issues with Prisma
  • Resolved module resolution errors in generated Prisma types

Server Initialization Issues

  • Added missing initializeRepositories() export to src/server/lib/autoSyncInit.ts
  • Fixed repository initialization on server startup
  • Resolved TypeError: autoSyncModule.initializeRepositories is not a function
  • Ensured default repositories are loaded before API requests

Service Module Exports

  • Fixed exports in src/server/services/autoSyncService.js
  • Fixed exports in src/server/services/repositoryService.js
  • Fixed exports in src/server/services/githubJsonService.js
  • Ensured all service modules properly export their functions

Dynamic Import Implementation

  • Converted static imports to dynamic imports for autoSyncInit module
  • Added comprehensive logging for debugging module loading
  • Implemented error handling for failed module imports
  • Better error messages during server initialization

Features & Improvements

Development Experience

  • dev:server command for development with TypeScript support
  • Detailed logging for module initialization debugging
  • Better error messages showing available vs. requested exports
  • Improved troubleshooting for module resolution issues

Production Readiness

  • Full TypeScript support in production environment
  • Proper module caching and tsx handling
  • Graceful error handling during server startup
  • WebSocket server initialization logging

Type Safety

  • TypeScript strict mode compatible code
  • Proper type definitions for all service modules
  • Better IDE support with TypeScript paths
  • Type checking via npm run typecheck

📝 Files Modified

Category Files Changes
Configuration package.json Added tsx dependency; Updated start/dev scripts
Core Server server.js Added dynamic imports with detailed logging
Database src/server/db.js Fixed Prisma client import paths
Initialization src/server/lib/autoSyncInit.ts Added initializeRepositories() export; Added TypeScript definitions
Services src/server/services/autoSyncService.js Fixed import paths and exports
Services src/server/services/repositoryService.js Fixed import paths and exports
Services src/server/services/githubJsonService.js Fixed import paths and exports
Type Definitions src/server/database-prisma.ts Fixed any type issues; Added explicit return types

🔍 Technical Details

What Was Wrong

  1. Prisma 7 generates TypeScript but production was trying to run JavaScript
  2. Module exports were missing from some .ts files while .js versions had them
  3. Import paths were inconsistent - some with extensions, some without
  4. Static imports failed due to tsx caching issues
  5. No logging made debugging difficult

How It Was Fixed

  1. Added tsx runtime to handle TypeScript in production
  2. Synced .ts and .js exports to match
  3. Standardized import paths for ESM compatibility
  4. Switched to dynamic imports for better module loading
  5. Added comprehensive logging for troubleshooting

Testing & Verification

  • npm install completes without errors
  • npm run build completes successfully
  • npm run typecheck passes with no errors
  • npm run lint and npm run format:check pass
  • npm start runs without errors
  • Server initializes all services (WebSocket, auto-sync, repositories)

📊 Commit Overview

30 commits across:

  • Type safety improvements (6 commits)
  • Import path fixes (8 commits)
  • Module export fixes (7 commits)
  • Service configuration (5 commits)
  • Documentation and logging (4 commits)

  • Production deployment failures with Prisma 7
  • TypeScript/ESM module resolution
  • Server initialization on startup
  • Missing service exports

Prerequisites

  • Self-review completed – Code follows project standards
  • Tested thoroughly – Verified on multiple environments
  • No security risks – No hardcoded secrets or privilege escalations

🛠️ Type of Change

  • 🐞 Bug fix only
  • New feature – TypeScript runtime support via tsx
  • 💥 Breaking change – Production startup mechanism changed

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/community-scripts/ProxmoxVE-Local/pull/354 **Author:** [@MickLesk](https://github.com/MickLesk) **Created:** 11/28/2025 **Status:** ✅ Merged **Merged:** 11/28/2025 **Merged by:** [@michelroegl-brunner](https://github.com/michelroegl-brunner) **Base:** `main` ← **Head:** `bugfixing_bumps` --- ### 📝 Commits (10+) - [`40805f3`](https://github.com/community-scripts/ProxmoxVE-Local/commit/40805f39f7b7ccc32c650e8bd8a20a88841231b3) Update dependencies and adjust TypeScript JSX setting - [`f467b9a`](https://github.com/community-scripts/ProxmoxVE-Local/commit/f467b9ad7b7338a7673763f5aba2b9b88458115d) fix vulnerabilities - [`9c759ba`](https://github.com/community-scripts/ProxmoxVE-Local/commit/9c759ba99bfac3e2971b041db8a2c7b586dc3eb7) fix: ESLint/TypeScript fixes - nullish coalescing, regexp-exec, optional-chain, unescaped-entities, unused-vars, type-safety - [`d40aeb6`](https://github.com/community-scripts/ProxmoxVE-Local/commit/d40aeb6c8264be625d4a4c874ec3af482fe12a24) Refactor scripts grid and filter handling for robustness - [`48cf86a`](https://github.com/community-scripts/ProxmoxVE-Local/commit/48cf86a449451099cfe37fe22afa54c837371ca2) Refactor nullish checks and add type safety - [`b5bce88`](https://github.com/community-scripts/ProxmoxVE-Local/commit/b5bce883986eb74ab7f3a01609b51983fd9965f3) Refactor InstalledScriptsTab for code style consistency - [`c266c4c`](https://github.com/community-scripts/ProxmoxVE-Local/commit/c266c4cb3c8bf709a4603a37a00de4de8f1ce816) Refactor InstalledScriptsTab for code style consistency - [`41a9c0a`](https://github.com/community-scripts/ProxmoxVE-Local/commit/41a9c0ae116983f4a6e0b88a32f7de7c92cc284a) Switch to ESLint CLI (Deprecation of ESLint) - [`ec23600`](https://github.com/community-scripts/ProxmoxVE-Local/commit/ec236008619b6009be15c27328e2b846581c9f26) Switch ESLint config to eslint-config-next/core-web-vitals - [`1945b14`](https://github.com/community-scripts/ProxmoxVE-Local/commit/1945b14694953849a88439133153e120cf19417b) Update ESLint config to use FlatCompat and expand ignores ### 📊 Changes **53 files changed** (+9546 additions, -4969 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -0) 📝 `eslint.config.js` (+15 -12) 📝 `next.config.js` (+14 -24) 📝 `package-lock.json` (+1178 -204) 📝 `package.json` (+42 -37) ➕ `prisma.config.ts` (+20 -0) 📝 `prisma/schema.prisma` (+2 -2) 📝 `server.js` (+220 -39) 📝 `src/app/_components/AuthProvider.tsx` (+45 -30) 📝 `src/app/_components/BackupWarningModal.tsx` (+27 -20) 📝 `src/app/_components/BackupsTab.tsx` (+172 -130) 📝 `src/app/_components/DownloadedScriptsTab.tsx` (+226 -157) 📝 `src/app/_components/FilterBar.tsx` (+337 -306) 📝 `src/app/_components/GeneralSettingsModal.tsx` (+968 -576) 📝 `src/app/_components/HelpModal.tsx` (+1614 -604) 📝 `src/app/_components/InstalledScriptsTab.tsx` (+1264 -836) 📝 `src/app/_components/LoadingModal.tsx` (+42 -27) 📝 `src/app/_components/PBSCredentialsModal.tsx` (+133 -86) 📝 `src/app/_components/ScriptCard.tsx` (+66 -40) 📝 `src/app/_components/ScriptCardList.tsx` (+142 -65) _...and 33 more files_ </details> ### 📄 Description Closes: #347 #346 #345 #344 #343 --- ## ✍️ Description This PR introduces comprehensive TypeScript runtime support via `tsx` and resolves critical compatibility issues with Prisma 7, enabling the application to run successfully in production. The changes span type safety improvements, module resolution fixes, and production deployment readiness. --- ## 📋 Changes Summary (30 Commits) ### 🔧 Core Infrastructure Changes #### TypeScript Runtime Support - Added `tsx@^4.19.4` as a production dependency - Updated `start` script: `node server.js` → `node --import tsx server.js` - Updated `dev:server` script for consistency: `node --import tsx server.js` - Enables native TypeScript execution without compilation step - Supports `.ts` file loading in production environment #### Module Resolution & Imports - Fixed import paths across all service files for ESM compatibility - Added `.ts` extensions to TypeScript imports where required - Updated relative imports to work with tsx loader - Ensured consistent import patterns across codebase --- ### 🐛 Bug Fixes #### Prisma 7 Compatibility - Updated `src/server/db.js` to properly import Prisma 7 client - Fixed path resolution for `prisma/generated/prisma/client.ts` - Handled ESM/CJS interoperability issues with Prisma - Resolved module resolution errors in generated Prisma types #### Server Initialization Issues - Added missing `initializeRepositories()` export to `src/server/lib/autoSyncInit.ts` - Fixed repository initialization on server startup - Resolved `TypeError: autoSyncModule.initializeRepositories is not a function` - Ensured default repositories are loaded before API requests #### Service Module Exports - Fixed exports in `src/server/services/autoSyncService.js` - Fixed exports in `src/server/services/repositoryService.js` - Fixed exports in `src/server/services/githubJsonService.js` - Ensured all service modules properly export their functions #### Dynamic Import Implementation - Converted static imports to dynamic imports for `autoSyncInit` module - Added comprehensive logging for debugging module loading - Implemented error handling for failed module imports - Better error messages during server initialization --- ### ✨ Features & Improvements #### Development Experience - `dev:server` command for development with TypeScript support - Detailed logging for module initialization debugging - Better error messages showing available vs. requested exports - Improved troubleshooting for module resolution issues #### Production Readiness - Full TypeScript support in production environment - Proper module caching and tsx handling - Graceful error handling during server startup - WebSocket server initialization logging #### Type Safety - TypeScript strict mode compatible code - Proper type definitions for all service modules - Better IDE support with TypeScript paths - Type checking via `npm run typecheck` --- ### 📝 Files Modified | Category | Files | Changes | |----------|-------|---------| | **Configuration** | `package.json` | Added `tsx` dependency; Updated start/dev scripts | | **Core Server** | `server.js` | Added dynamic imports with detailed logging | | **Database** | `src/server/db.js` | Fixed Prisma client import paths | | **Initialization** | `src/server/lib/autoSyncInit.ts` | Added `initializeRepositories()` export; Added TypeScript definitions | | **Services** | `src/server/services/autoSyncService.js` | Fixed import paths and exports | | **Services** | `src/server/services/repositoryService.js` | Fixed import paths and exports | | **Services** | `src/server/services/githubJsonService.js` | Fixed import paths and exports | | **Type Definitions** | `src/server/database-prisma.ts` | Fixed `any` type issues; Added explicit return types | --- ### 🔍 Technical Details #### What Was Wrong 1. **Prisma 7 generates TypeScript** but production was trying to run JavaScript 2. **Module exports were missing** from some `.ts` files while `.js` versions had them 3. **Import paths were inconsistent** - some with extensions, some without 4. **Static imports failed** due to tsx caching issues 5. **No logging** made debugging difficult #### How It Was Fixed 1. **Added tsx runtime** to handle TypeScript in production 2. **Synced `.ts` and `.js` exports** to match 3. **Standardized import paths** for ESM compatibility 4. **Switched to dynamic imports** for better module loading 5. **Added comprehensive logging** for troubleshooting --- ## ✅ Testing & Verification - ✅ `npm install` completes without errors - ✅ `npm run build` completes successfully - ✅ `npm run typecheck` passes with no errors - ✅ `npm run lint` and `npm run format:check` pass - ✅ `npm start` runs without errors - ✅ Server initializes all services (WebSocket, auto-sync, repositories) --- ## 📊 Commit Overview **30 commits across:** - Type safety improvements (6 commits) - Import path fixes (8 commits) - Module export fixes (7 commits) - Service configuration (5 commits) - Documentation and logging (4 commits) --- ## 🔗 Related Issues - Production deployment failures with Prisma 7 - TypeScript/ESM module resolution - Server initialization on startup - Missing service exports --- ## ✅ Prerequisites - [x] **Self-review completed** – Code follows project standards - [x] **Tested thoroughly** – Verified on multiple environments - [x] **No security risks** – No hardcoded secrets or privilege escalations --- ## 🛠️ Type of Change - [ ] 🐞 **Bug fix only** - [x] ✨ **New feature** – TypeScript runtime support via `tsx` - [x] 💥 **Breaking change** – Production startup mechanism changed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 12:41:12 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ProxmoxVE-Local#383
No description provided.