Skip to content

fix(core): resolve docs.mjs package dir with fileURLToPath so component docs work on Windows#3331

Open
arham766 wants to merge 1 commit into
facebook:mainfrom
arham766:fix/core-docs-mjs-windows
Open

fix(core): resolve docs.mjs package dir with fileURLToPath so component docs work on Windows#3331
arham766 wants to merge 1 commit into
facebook:mainfrom
arham766:fix/core-docs-mjs-windows

Conversation

@arham766

@arham766 arham766 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

docs.mjs resolved its package directory with new URL(import.meta.url).pathname, which returns /D:/... for drive-letter paths on Windows. srcDir then pointed at a nonexistent D:\D:\... path, so --list silently printed nothing (the existsSync guard returned an empty catalog) and single-component lookup crashed with ENOENT. Switching to fileURLToPath fixes both and makes directory resolution symmetric with the existing pathToFileURL use in loadDoc().

Adds subprocess smoke tests that spawn the script from a neutral cwd (os.tmpdir()), so resolution can only come from the module URL. The test lives in src/ (not next to docs.mjs) because the vitest include glob only picks up packages/**/src/**; noted in the file header. No overlap with #3234 (CLI test paths) or #3305 (core build script).

Test plan

  • npx vitest run packages/core/src/docs-script.test.mjs passes on Windows (2/2); the fix is a no-op on POSIX where fileURLToPath also correctly decodes percent-encoded paths.
  • Manual on Windows: node packages/core/docs.mjs --list now prints the full catalog; node packages/core/docs.mjs Button renders full docs. Before the fix, the former printed nothing and the latter exited with ENOENT.
  • Full monorepo suite run on Windows and diffed against a main-branch baseline: no new failures introduced.
  • node scripts/check-changesets.mjs passes.

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@arham766 is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla

meta-cla Bot commented Jul 1, 2026

Copy link
Copy Markdown

Hi @arham766!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@arham766 arham766 force-pushed the fix/core-docs-mjs-windows branch from bcfb037 to ceba940 Compare July 1, 2026 22:57
@arham766 arham766 marked this pull request as ready for review July 1, 2026 23:01
…s on Windows

URL.pathname returns /D:/... for drive-letter paths, so --list printed
nothing and component lookup crashed with ENOENT. Adds subprocess smoke
tests that pin the behavior on all platforms.
@arham766

arham766 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@cixzhang gentle ping when you have a minute. Small fix, unblocks Windows users of the core docs script (both --list and single-component lookup are broken there today).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant