Skip to content

Build fails when blog is a subdirectory of the docs #11607

@Salamandar

Description

@Salamandar

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

For corporate reasons™ I need to store the blog posts in a subdirectory of the docs (actually, in my specific case, docs path = '..', and blog path = '../release_notes', but I can reproduce the bug without '..' in the paths for a more standard installation).

The build fails with a kinda weird error.

Reproducible demo

No response

Steps to reproduce

npx create-docusaurus@latest my-website classic --typescript
cd my-website
mv blog docs

Then patch docusaurus.config.ts:

  • Add the line exclude: ['blog'], in the docs preset
  • Add the line path: 'docs/blog', in the blog preset

Then yarn build.

Expected behavior

A perfectly indistinguishable build from the example

Actual behavior

A bunch of those errors:

lient bundle compiled with errors therefore further build is impossible.
Error: MDX compilation failed for file "/home/felix/tmp/my-website/docs/blog/2019-05-28-first-blog-post.md"
Cause: Unexpected `FunctionDeclaration` in code: only import/exports are supported
Details:
{
  "column": 1,
  "file": "",
  "message": "Unexpected `FunctionDeclaration` in code: only import/exports are supported",
  "line": 24,
  "name": "24:1-33:2",
  "place": {
    "start": {
      "line": 24,
      "column": 1,
      "offset": 564
    },
    "end": {
      "line": 33,
      "column": 2,
      "offset": 778
    }
  },
  "reason": "Unexpected `FunctionDeclaration` in code: only import/exports are supported",
  "ruleId": "non-esm",
  "source": "micromark-extension-mdxjs-esm",
  "url": "https://github.com/micromark/micromark-extension-mdxjs-esm#unexpected-type-in-code-only-importexports-are-supported"
}

--------------------------

Your environment

  • Docusaurus version used: 3.9.2
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Nodejs 22.21.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Ubuntu 24.04

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 execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions