Skip to content

fix: Use correct version resolution (like src/server.ts) in the tracing state#113

Merged
Winify merged 1 commit into
mainfrom
fix/tracing-version
May 25, 2026
Merged

fix: Use correct version resolution (like src/server.ts) in the tracing state#113
Winify merged 1 commit into
mainfrom
fix/tracing-version

Conversation

@Winify
Copy link
Copy Markdown
Collaborator

@Winify Winify commented May 25, 2026

Proposed changes

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have squashed commits that belong together
  • I have tested with Claude Desktop (or another MCP-compatible client)
  • I have read the CONTRIBUTING doc
  • I have added the necessary documentation for new/changed tools (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 25, 2026

Greptile Summary

This PR replaces the createRequire-based runtime require() call in src/trace/state.ts with a native ESM import assertion (import pkg from '../../package.json' with { type: 'json' }) to read the package version, exactly mirroring the pattern already in src/server.ts.

  • The old approach used createRequire(import.meta.url) to shim CommonJS require() inside an ESM module; the new import assertion is idiomatic for this ESM-first, tsup-bundled codebase.
  • The relative path ../../package.json is correct for a file at src/trace/state.ts, and the TypeScript version (~5.9.3) fully supports the with { type: 'json' } import attribute syntax.

Confidence Score: 5/5

Safe to merge — the single-file change aligns state.ts with the established import pattern in server.ts and introduces no new logic.

The change removes a CJS-style shim in favour of a native ESM import assertion already proven to work in server.ts. The relative path is correct, the TypeScript version supports the syntax, and tsup handles JSON imports at bundle time. No behavioural differences are expected at runtime.

No files require special attention.

Important Files Changed

Filename Overview
src/trace/state.ts Replaces CJS-style createRequire hack for reading package.json with a proper ESM import assertion, matching the pattern already used in src/server.ts. Path depth is correct for the file's location.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["src/trace/state.ts"] -->|"import pkg from '../../package.json'\nwith { type: 'json' }"| B["package.json\n(version: 3.5.0)"]
    B --> C["pkg.version → libraryVersion"]
    C --> D["createTraceSession()\nevent: context-options\nlibraryVersion field"]

    E["src/server.ts"] -->|"import pkg from '../package.json'\nwith { type: 'json' }"| B

    style A fill:#d4edda,stroke:#28a745
    style E fill:#cce5ff,stroke:#004085
Loading

Reviews (1): Last reviewed commit: "fix: Use correct version resolution (lik..." | Re-trigger Greptile

@Winify Winify merged commit b7ef23c into main May 25, 2026
6 checks passed
@Winify Winify deleted the fix/tracing-version branch June 7, 2026 20:08
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] v3.5.0: require("../../package.json") resolves to wrong path in scoped package — crashes on startup

1 participant