docusaurus-protobuffet icon indicating copy to clipboard operation
docusaurus-protobuffet copied to clipboard

MDX compilation failed

Open dhia-gharsallaoui opened this issue 2 years ago • 4 comments

Hello, I am trying to setup docusaurus-protobuffet to my docusaurus website.

After adding the docusaurus-protobuffet config to my docusaurus.config.js file

{
  presets: [
    [
      'classic',
      /** @type {import('@docusaurus/preset-classic').Options} */
      ({
        docs: {
          sidebarPath: './sidebars.ts',
	  routeBasePath: '/',
        },
        blog: false,
      }),
    ],
    [
      'docusaurus-protobuffet',
      {
        protobuffet: {
          fileDescriptorsPath: '/protos/protos.json',
	  protoDocsPath: './docs',
          sidebarPath: './sidebars.ts'
        },
        docs: {
          routeBasePath: 'docs',
          sidebarPath: './sidebars.ts',
        }
      }
    ]
  ]
}

I got this error for all generated and old files even the .md file.

Error: MDX compilation failed for file "/site/docs/01_architecture/01_database.md"
Cause: Unexpected `FunctionDeclaration` in code: only import/exports are supported
Details:
{
  "column": 1,
  "message": "Unexpected `FunctionDeclaration` in code: only import/exports are supported",
  "line": 52,
  "name": "52:1-168:2",
  "place": {
    "start": {
      "line": 52,
      "column": 1,
      "offset": 1468
    },
    "end": {
      "line": 168,
      "column": 2,
      "offset": 8120
    }
  },
  "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"
}

dhia-gharsallaoui avatar Dec 07 '23 09:12 dhia-gharsallaoui

same here

Cause: Unexpected `FunctionDeclaration` in code: only import/exports are supported
Details:
{
  "column": 1,
  "message": "Unexpected `FunctionDeclaration` in code: only import/exports are supported",
  "line": 48,
  "name": "48:1-123:2",
  "place": {
    "start": {
      "line": 48,
      "column": 1,
      "offset": 1298
    },
    "end": {
      "line": 123,
      "column": 2,
      "offset": 7515
    }
  },
  "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"
}

zsedem avatar Dec 20 '23 16:12 zsedem

Please share generated md if possible

lpicchi avatar Aug 12 '24 14:08 lpicchi

Same here. Did you find the fix so far? @dhia-gharsallaoui @zsedem

@AnthonyBobsin Can you please tell us if you are still maintaining this repo or not?

dsha256 avatar Feb 08 '25 02:02 dsha256

Hey @lpicchi, I'm getting the same error:

Error: MDX compilation failed for file "/Users/*/js/docs/docs/Nexus gRPC/Payment Service/proto/common/v1/banks.proto.mdx"
Cause: Unexpected `FunctionDeclaration` in code: only import/exports are supported
Details:
{
  "column": 1,
  "message": "Unexpected `FunctionDeclaration` in code: only import/exports are supported",
  "line": 25,
  "name": "25:1-153:2",
  "place": {
    "start": {
      "line": 25,
      "column": 1,
      "offset": 695
    },
    "end": {
      "line": 153,
      "column": 2,
      "offset": 4178
    }
  },
  "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"
}

Here is the banks.proto.mdx:

---
title: banks.proto
hide_title: true
---

import { ProtoMessage, ProtoServiceMethod, ProtoEnum } from '@theme/ProtoFile';

# `banks.proto`
_**path** proto/common/v1/banks.proto_

_**package** common.v1_



---

## Enums


### `BIC`
<ProtoEnum key={0} enumb={{"name":"BIC","longName":"BIC","fullName":"common.v1.BIC","description":"BIC is a uniq identifier of financial institutions.","values":[{"name":"BIC_UNSPECIFIED","number":"0","description":""},{"name":"BNLNGE22","number":"1","description":"National Bank"},{"name":"BAGAGE22","number":"2","description":"Bank of Georgia"},{"name":"CBASGE22","number":"3","description":"BasisBank"},{"name":"DISNGE22","number":"4","description":"Silk Bank"},{"name":"CRTUGE22","number":"5","description":"Cartu Bank"},{"name":"HABGGE22","number":"6","description":"Halyk Bank Georgia"},{"name":"TEBAGE22","number":"7","description":"Terabank"},{"name":"LBRTGE22","number":"8","description":"Liberty Bank"},{"name":"MIBGGE22","number":"9","description":"ProCredit Bank"},{"name":"TBCBGE22","number":"10","description":"TBC Bank"},{"name":"UGEBGE22","number":"11","description":"VTB Bank Georgia"},{"name":"TCZBGE22","number":"12","description":"Ziraat Bank Georgia"},{"name":"PAHAGE22","number":"13","description":"Pasha Bank Georgia"},{"name":"ISBKGE22","number":"14","description":"Isbank Georgia"},{"name":"JSCRGE22","number":"15","description":"Credo Bank"},{"name":"PSRAGE22","number":"16","description":"Paysera Bank Georgia"},{"name":"HAJSGE22","number":"17","description":"HASH Bank"},{"name":"PAVEGE22","number":"18","description":"Pave Bank"}]}} />

---

dsha256 avatar Feb 08 '25 03:02 dsha256