Skip to content

Links to local directories with dots in filename break docusaurus build #11940

@thanasis2028

Description

@thanasis2028

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Hello,

I have ran into the following issue when generating documentation for some projects:
If one of the md files contains a link to a local directory that has a dot . in its name AND that directory exists, then the docusaurus default mdx plugins will try to parse it using require(), and break the build with the following message:

Module not found: Error: Can't resolve './../directory-with.dot' in '/home/projects/pariqjjolg.github/docs'

Link to repro URL: https://stackblitz.com/edit/github-c3qe69at?file=docs%2Fintro.mdx

Offending line:

[This link breaks the build](../directory-with.dot/)

Probable Cause

The code at transformLinks seems to try to parse the file path and if it has a md-like extension, it calls toAssetRequireNode().

There should probably be added a directory check somewhere here. I am no javascript expert but I can attempt to create a MR if it helps.

Reproducible demo

https://stackblitz.com/edit/github-c3qe69at?file=docs%2Fintro.mdx

Steps to reproduce

  1. From the provided demo just run yarn build.

Or alternatively from a clean repo:

  1. Add this to a parsed md file: [This link breaks the build](../directory-with.dot/)
  2. Create the directory and put a dummy md file in it.
  3. Run yarn build

Expected behavior

The build should pass and link to directory created.

Actual behavior

The following error is produced:

Module not found: Error: Can't resolve './../directory-with.dot' in '/home/projects/pariqjjolg.github/docs'

Your environment

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionstatus: needs triageThis issue has not been triaged by maintainers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions