Skip to content

Relative JS imports with a query string (./foo.js?v=123) are not resolved #4860

Closed

Description

@urieeluscanga-del

Version: graphify 0.9.93 (graphifyy), extract --code-only, GRAPHIFY_BACKEND=none

Description
ES module imports that include a cache-busting query string are not resolved to the target file:

import { foo } from './lib/foo.js?v=134';

Instead of an imports_from edge to lib/foo.js, graphify creates a phantom node (e.g. ref_foo_js_v_134) and the real file gets no inbound edge. Symbol imports and cross-file calls are lost as well, since they depend on the module resolving.

Impact (real project, 93 JS files)

  • Phantom _v_ nodes: 96 → 0 after stripping the suffix
  • Inbound imports_from edges for the most-used module: 0 → 29
  • Symbol imports: 30 → 413
  • About 400 cross-file calls edges recovered

Root cause
extractors/resolution.py, lines 855-856 (_resolve_js_module_path): relative specifiers are resolved with start_dir / raw without stripping the ?query / #fragment part. The Markdown extractor already strips it (extractors/markdown.py:289), so applying the same normalization to relative JS/TS specifiers should fix it.

Also present on v8 (default branch) as of 0a8cd4e (resolution.py lines 868-869).

Current workaround
Copy the tree to a temp dir, strip the suffix with sed -E 's/(\.js)\?v=[0-9]+/\1/g', and extract from the copy.

Expected behavior
./foo.js?v=123 resolves to ./foo.js, as browsers and bundlers do for module resolution.

Related: #2849 lists one ../styles.css?url import under "Resource-query import is unresolved". It looks like the same root cause.

Activity

  1. github-actions commented on Oct 29, 2026

    @github-actions

    Thanks for opening this issue, @urieeluscanga-del. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. mirzasnowy commented on Oct 29, 2026

    @mirzasnowy

    Hi, I'd like to pick this up. Plan is pretty simple: strip the ?query and #fragment suffix off relative JS/TS specifiers before resolving, in _resolve_js_module_path, so a Vite-style import lands on the real file instead of minting a phantom node. Hash subpath imports, bare specifiers, and aliases stay untouched, and I'll add tests per specifier shape.

  3. AdapaRohith commented on Oct 29, 2026

    @AdapaRohith

    Hi! I'd like to work on this issue. I’ll investigate the JavaScript/TypeScript module resolution logic, add regression tests for imports containing query strings and URL fragments, and submit a fix while ensuring existing import resolution continues to work.

  4. added a commit that references this issue on Oct 30, 2026
  5. added a commit that references this issue on Oct 30, 2026
    fe55ad7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions