Skip to content

fix(core): resolve from a directory parent URL, not the folder above it - #869

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/directory-parent-url
Oct 20, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/directory-parent-url

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Fixes #862.

Node.js resolves --import preloads from the working directory as a directory URL, pathToFileURL(cwd + "/"). resolve() read every parent URL as a file and resolved from its parent folder, so:

  • --import ./setup looked for setup in the folder above the working directory and missed setup.ts (ERR_MODULE_NOT_FOUND).
  • With the working directory at /, the parent file:/// has no parent, so every preload failed with Parent URL is not a file URL.

A parent URL whose path ends in / is now the directory to resolve from:

parent is a file parent is a directory (new)
resolve from the file's folder the directory itself (file:/// β†’ /)
tsconfig discovery (Auto) the file none, as for the entry point
symlinks --preserve-symlinks --preserve-symlinks (Node: isMain = parentURL === undefined)

Tests: directory-parent-url.spec.ts covers --import ./setup, --import ./lib/setup, and a working directory at the file-system root. All three fail before the fix. I also checked both cases from the issue by hand on Node.js 22.18.0, 24.12.0 and 24.22.0.

πŸ€– Generated with Claude Code

Node.js resolves --import preloads from pathToFileURL(cwd + "/"). resolve()
read that URL as a file and resolved from its parent, so --import ./setup
missed setup.ts, and with the working directory at / the parent file:///
had no parent and every preload failed with "Parent URL is not a file URL".

A parent URL that ends in / is now the directory to resolve from. It has
no file for tsconfig discovery, as the entry point has not, and it still
counts as a parent, so --preserve-symlinks (not -main) applies, as in
Node.js.

Fixes #862

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review ⚠️ Failed 2026-10-20T04:55:11.705253Z 4726049 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Brooooooklyn
Brooooooklyn merged commit ce22828 into main Oct 20, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/directory-parent-url branch October 20, 2026 06:59
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.

A parent URL that ends in / (the working directory) is resolved as a file

1 participant