Skip to content

fix(mdx-loader): avoid transforming dotted directory links into asset…#11944

Open
thanasis2028 wants to merge 1 commit intofacebook:mainfrom
thanasis2028:fix-11940
Open

fix(mdx-loader): avoid transforming dotted directory links into asset…#11944
thanasis2028 wants to merge 1 commit intofacebook:mainfrom
thanasis2028:fix-11940

Conversation

@thanasis2028
Copy link
Copy Markdown

@thanasis2028 thanasis2028 commented Apr 16, 2026

… fixes (#11940)

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

This PR fixes a bug in markdown link asset detection for local links that point to existing directories whose names contain a dot.

Today, transformLinks uses path.extname() to decide whether a local link looks asset-like. Because of that, links such as ../Project.Tests are treated as file assets instead of directory links. When such a path exists on disk as a directory, Docusaurus rewrites it to a webpack require(), which later fails during the build with a Module not found error.

This pattern is common in ecosystems that use dotted directory names, such as .NET test projects (Project.Tests).
This PR updates transformLinks so that existing local directories are not transformed into asset requires.

Test Plan

I added a regression test in packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/index.test.ts covering an existing dotted directory link.

I verified the change with:

corepack yarn test packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/index.test.ts --runInBand
corepack yarn test packages/docusaurus-mdx-loader/src/remark/resolveMarkdownLinks/__tests__/index.test.ts --runInBand

Both test suites passed.

I also verified the behavior manually with a local reproduction using a markdown link like:

[Some.Directory](../Some.Directory)

pointing to an existing directory named Some.Directory.

Before this change, that kind of link could be turned into a webpack asset require and fail the build with Module not found.
After this change, Docusaurus no longer treats the existing dotted directory as an asset. The link remains a normal link and is handled by the regular broken-link pipeline instead of crashing during asset resolution.

Test links

No UI changes

Related issues/PRs

#11940

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 16, 2026

Hi @thanasis2028!

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!

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 16, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit f0b075b
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69e0c3fe6f17db0008edb850
😎 Deploy Preview https://deploy-preview-11944--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Apr 16, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Apr 16, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant