fix(mdx-loader): avoid transforming dotted directory links into asset…#11944
fix(mdx-loader): avoid transforming dotted directory links into asset…#11944thanasis2028 wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @thanasis2028! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
… fixes (#11940)
Pre-flight checklist
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,
transformLinksusespath.extname()to decide whether a local link looks asset-like. Because of that, links such as../Project.Testsare treated as file assets instead of directory links. When such a path exists on disk as a directory, Docusaurus rewrites it to a webpackrequire(), which later fails during the build with aModule not founderror.This pattern is common in ecosystems that use dotted directory names, such as
.NETtest projects (Project.Tests).This PR updates
transformLinksso 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.tscovering an existing dotted directory link.I verified the change with:
Both test suites passed.
I also verified the behavior manually with a local reproduction using a markdown link like:
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