Skip to content

Conversation

@robertsLando
Copy link
Member

@robertsLando robertsLando commented Oct 7, 2025

This pull request introduces several significant updates across the codebase, primarily focused on modernizing the Node.js environment, allow code sharing between backend and UI, improving TypeScript usage, and enhancing import consistency. The most notable changes include upgrading to Node.js 22, transitioning all imports to use explicit .ts extensions and more precise type-only imports, and updating workflow and configuration files to align with these changes.

Node.js and Tooling Upgrades:

  • Upgraded Node.js version from 20 to 22 in both the GitHub Actions workflow (.github/workflows/test-application.yml) and .nvmrc, ensuring the project uses the latest LTS features and performance improvements. [1] [2]
  • Updated the workflow to build the backend before starting it, and adjusted process checks and log outputs to match the new start command. [1] [2]

TypeScript and Import Improvements:

  • Converted all internal imports to use explicit .ts extensions and transitioned to type-only imports where appropriate, improving type safety and compatibility with ES module standards. This affects nearly all files in the api/ directory, including app.ts, config/store.ts, lib/Gateway.ts, and others. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

Configuration and Linting Updates:

  • Changed .prettierrc.js to use ES module export syntax, aligning with modern JavaScript module standards.
  • Removed the watch-files option from .mocharc.yml, possibly to streamline or fix test runner behavior.

Codebase Consistency and Minor Fixes:

  • Standardized usage of Node.js built-in modules by using the node: prefix (e.g., node:fs, node:path) across the codebase. [1] [2] [3] [4] [5]
  • Added or updated utility exports and constants, such as introducing deviceConfigPriorityDir in Constants.ts and updating its usage in config/store.ts. [1] [2]

These changes collectively modernize the codebase, improve maintainability, and ensure compatibility with the latest Node.js and TypeScript features.

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Fixes #4401

@coveralls
Copy link

coveralls commented Oct 7, 2025

Pull Request Test Coverage Report for Build 18403500992

Details

  • 112 of 386 (29.02%) changed or added relevant lines in 25 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 20.492%

Changes Missing Coverage Covered Lines Changed/Added Lines %
.prettierrc.js 0 1 0.0%
vite.config.mjs 0 1 0.0%
server_config.js 0 3 0.0%
api/bin/www.ts 0 4 0.0%
api/lib/CustomPlugin.ts 0 4 0.0%
api/lib/jsonStore.ts 25 29 86.21%
api/config/store.ts 0 5 0.0%
api/lib/PkgFsBindings.ts 0 5 0.0%
api/lib/SocketManager.ts 0 6 0.0%
api/lib/BackupManager.ts 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
api/lib/logger.ts 1 89.1%
Totals Coverage Status
Change from base Build 18340663185: 0.2%
Covered Lines: 4033
Relevant Lines: 20865

💛 - Coveralls

@robertsLando robertsLando marked this pull request as ready for review October 7, 2025 12:20
@robertsLando robertsLando requested review from AlCalzone and Copilot and removed request for Copilot October 7, 2025 12:20
Copy link
Member

@AlCalzone AlCalzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a couple of things.

In addition it might be a good time to ditch fs-extra in favor of node:fs/promises. Only requires two helper functions for deleting and creating directories, but Copilot is pretty good at replacing fs-extra I've noticed.


const url = require('native-url')
import { join } from 'node:path'
import url from 'native-url'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the browser-compatible WhatWG URL API instead of an extra dependency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every time I tried using that I ended up reverting my changes as them are not 100% compatibile

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I did this in Z-Wave JS to enable browser support and it worked just fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the URL API would also prevent the need for this patch.

@robertsLando robertsLando merged commit deddc1b into master Oct 14, 2025
11 of 12 checks passed
@robertsLando robertsLando deleted the move-to-esm branch October 14, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 11.4.0 vite.config.mjs Alias Path Change Breaks Docker Installs

4 participants