-
Using Markdoc with NextJS If an import from Headless UI (from TailwindCSS guys) is added to a Component, the Tag using it, stops working. Here is a bare minimum sample: https://github.com/khash/markdoc-tests
In the example repo, a sample component and tag, called import { Transit } from "../components/transit";
export const transit = {
render: Transit,
attributes: {
text: { type: String }
}
}; Component: //import { Listbox } from '@headlessui/react' <- Commented out to work
export function Transit({ text }) {
return (
<div>This is from transit: {text}</div>
)
} Markdoc: ---
title: Get started with Markdoc
description: How to get started with Markdoc
---
# Get started with Markdoc
{% transit text="hello" /%} |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
I think this is not as niche as it sounds and might be affecting other libraries as well. I'm going to bring in Headless UI's dependencies one by one into the component and see which one is causing this issue. |
Beta Was this translation helpful? Give feedback.
-
@mfix-stripe perhaps I'm missing something. The way I've arranged the imports is through an ...
export { default as transit } from './transit.markdoc';
... and in export default {
...
} Changing the Also, I'm unsure as to what the change you mentioned in the versions can be used (I can't see any package version changes as a result of that). |
Beta Was this translation helpful? Give feedback.
-
I want to check some possibly related issue with imports in Markdoc and NextJS: There are two projects I've referred to in this thread: one sample project I put together (above repo) and one that's my real project where I stumbled upon this issue. This issue gets resolved in the sample project if have an import in the component, before I start the project, but in my real project that doesn't help. When I compare those two projects, everything is the same, except that the sample project exports the tags in a single Normally, I would have not thought about this being important. However, when I run
These "errors" don't impede the app's operation, but made me thing they could be related to this issue, given its nature. Please note, that the NextJS error is on the Adding something like I took the folder pattern from https://github.com/markdoc/docs/blob/main/markdoc/tags/index.js and I'm not sure if this is an issue on that repository or not, but I thought I'd mention it here, if it helps. |
Beta Was this translation helpful? Give feedback.
-
I managed to make this work by doing the following: I moved all my Markdoc tags and nodes form individual files + I don't know why this would fix the problem and if this is a Webpack, NextJS or Markdoc issue, and I don't know why it affects some libraries like HeadlessUI but not Popper, but using single Markdoc files fixes the issue. |
Beta Was this translation helpful? Give feedback.
I managed to make this work by doing the following:
I moved all my Markdoc tags and nodes form individual files +
index.js
into two single files:nodes.js
andtags.js
with aexport default
on each one. This fixes the problem. (You'd still need to start NextJS with the import in place)I don't know why this would fix the problem and if this is a Webpack, NextJS or Markdoc issue, and I don't know why it affects some libraries like HeadlessUI but not Popper, but using single Markdoc files fixes the issue.