Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports in mdx files #48

Closed
gurkerl83 opened this issue Nov 3, 2020 · 1 comment
Closed

Imports in mdx files #48

gurkerl83 opened this issue Nov 3, 2020 · 1 comment
Labels
support questions requesting support

Comments

@gurkerl83
Copy link

Hi, I have a quick question. The documentation doesn't say whether it is possible to load MDX files, which can load any React components via relative module paths.

Specifically, I get an error message with the following statement when trying to do so. MDX files that do not have any import statements are loaded.

ReferenceError: require is not defined

On Stack-Overflow, a similar problem is shown.

https://stackoverflow.com/questions/63957018/how-to-use-images-in-a-mdx-file-outside-of-public-folder-while-using-next

A commentary on the mentioned contribution says

"It's not possible, unfortunately, as next-mdx-remote treats the markdown content as data & doesn't pass through Webpack at all.

There is a merge request (https://github.com/hashicorp/next-mdx-remote/pull/39/files), which among other things, changes the function of renderToString and executes a transformation through Babel.

Does this mean that your library will support this ability in the future, or is an MDX loader required that implements all content via module-based imports?

Thx!

@jescalan
Copy link
Contributor

jescalan commented Nov 4, 2020

It will almost certainly never support this. There is a clear mention of this fact in the readme:

https://github.com/hashicorp/next-mdx-remote#caveats

If you need to use components within an mdx file, just pass them through the components argument rather than importing ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support questions requesting support
Projects
None yet
Development

No branches or pull requests

2 participants