Skip to content

chore: build with node 22 - #937

Merged
tbouffard merged 10 commits into
mainfrom
chore/bulid_with_node_22
Nov 18, 2025
Merged

chore: build with node 22#937
tbouffard merged 10 commits into
mainfrom
chore/bulid_with_node_22

Conversation

@tbouffard

@tbouffard tbouffard commented Nov 5, 2025

Copy link
Copy Markdown
Member

Make the Client class initialization more robust.
On node 22, there were some errors when running js-example-nodejs.

Notes

Covers #67

Summary by CodeRabbit

  • Chores

    • Updated the required Node.js version to 22.
    • Lowered build chunk-size warning thresholds in example projects.
  • Refactor

    • Made browser feature-detection more robust to avoid errors in non-browser environments.

@tbouffard tbouffard added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Nov 5, 2025
@coderabbitai

coderabbitai Bot commented Nov 5, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Updates the Node.js runtime target in .nvmrc and refactors browser feature-detection in Client.ts to use guarded helpers; three Vite example configs adjust chunkSizeWarningLimit numbers.

Changes

Cohort / File(s) Change Summary
Node.js version configuration
.nvmrc
Bumped Node.js version from 20 to 22.
Browser feature-detection refactor
packages/core/src/Client.ts
Replaced direct window/navigator access with guard helper functions (e.g., isWindowObjectAvailable, isUserAgentAvailable, isAppVersionAvailable) and updated many static detection flags to use those guards; preserved public/static property names and types.
Example Vite config tweaks
packages/ts-example-selected-features/vite.config.js, packages/ts-example-without-defaults/vite.config.js, packages/ts-example/vite.config.js
Minor reductions to chunkSizeWarningLimit values for example builds (370→368, 310→307, 436→433 respectively).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Init as App initialization
    participant Client as Client.static init
    participant Guards as Guard helpers (isWindow..., isUserAgent...)
    Note over Client: Old flow: direct access to window/navigator
    Init->>Client: trigger static initializers
    Client->>Guards: call isWindowObjectAvailable()
    Guards-->>Client: true/false
    alt window available
        Client->>Guards: call isUserAgentIncludes(...)/isAppVersionIncludes(...)
        Guards-->>Client: boolean results
        Client-->Init: set static flags (IS_EDGE, IS_SF, IS_ANDROID, ...)
    else non-browser context
        Client-->Init: set static flags to safe defaults (false/undefined)
    end
    Note over Guards: Guards avoid direct undefined property access and use optional chaining where applicable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Reasoning: logic-level changes in a core Client initialization file plus small config edits across multiple packages—requires reading the guard implementations and verifying each static flag mapping.
  • Pay extra attention to:
    • packages/core/src/Client.ts — correctness of guard implementations and any edge cases (SSR/non-browser environments).
    • Preservation of public/static property semantics and types.
    • No regressions from Vite config numeric tweaks (build warnings only).

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing entirely. The template requires an overview explaining the change details, rationale, and issue references. Add a pull request description following the provided template, including an Overview section that explains why the Node.js version is being updated to 22 and references any related issue if applicable.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: build with node 22' clearly and concisely describes the main change—updating the Node.js version to 22.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3de0f42 and 5dc8aab.

📒 Files selected for processing (4)
  • packages/core/src/Client.ts (3 hunks)
  • packages/ts-example-selected-features/vite.config.js (1 hunks)
  • packages/ts-example-without-defaults/vite.config.js (1 hunks)
  • packages/ts-example/vite.config.js (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tbouffard
tbouffard marked this pull request as draft November 5, 2025 15:35
@tbouffard

Copy link
Copy Markdown
Member Author

⚠️ when running js-example-nodejs with node 22, an error occurs on macos and ubuntu. This works well with node 20

$ npm run build

> build
> run-s build:*


> build:esm
> node src/index.mjs

file:///maxGraph/maxGraph/packages/core/lib/esm/Client.js:84
Client.IS_ANDROID = typeof window !== 'undefined' && navigator.appVersion.indexOf('Android') >= 0;
                                                                          ^

TypeError: Cannot read properties of undefined (reading 'indexOf')
    at file://maxGraph/maxGraph/packages/core/lib/esm/Client.js:84:75
    at ModuleJob.run (node:internal/modules/esm/module_job:345:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@tbouffard
tbouffard marked this pull request as ready for review November 18, 2025 11:22
@tbouffard
tbouffard merged commit 9d9b769 into main Nov 18, 2025
7 of 9 checks passed
@tbouffard
tbouffard deleted the chore/bulid_with_node_22 branch November 18, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant