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

export 'serialize' (reexported as 'serialize') was not found #416

Open
Knaackee opened this issue Nov 17, 2023 · 5 comments
Open

export 'serialize' (reexported as 'serialize') was not found #416

Knaackee opened this issue Nov 17, 2023 · 5 comments

Comments

@Knaackee
Copy link

At first, thanks for this repo and the hard work!

I am using the new React Server Component on Next.js 14. No problem here.

But I also want to use the client component for live preview on a different page.
The problem is that the client component does throw

../../../node_modules/next-mdx-remote/serialize.js
export 'serialize' (reexported as 'serialize') was not found in './dist/serialize.js' (module has no exports)

Here is my client component:

"use client";

import { MDXRemote as MDXRemoteClientComponent } from "next-mdx-remote";
import { serialize } from "next-mdx-remote/serialize";
import { useEffect, useState } from "react";

export const MDXClientComponent = ({
  body,
  components,
}: React.PropsWithoutRef<{
  body: string;
  components: any;
}>) => {
  const [state, setState] = useState<{
    source: any;
  }>({
    source: undefined,
  });

  useEffect(() => {
    serialize(body, {
      mdxOptions: {
        development: true,
        format: "mdx",
      },
    }).then((source) => {
      setState({ source });
    });
  }, [body]);

  return (
    <div className="prose xl:prose-lg mx-auto max-w-5xl">
      {state.source && (
        <MDXRemoteClientComponent {...state.source} components={components} />
      )}
    </div>
  );
};

Any idea?

@vannyle
Copy link

vannyle commented Dec 1, 2023

Hi, I got the same issue when updating Next.js to v14. Did you figure out how to fix it or maybe any workaround?

@olayway
Copy link

olayway commented Dec 13, 2023

I have the same issue.

@paramaggarwal
Copy link

#307

@stellarsite
Copy link

#307

I do not see an awnser for this specific issue in 307

@dstaley
Copy link
Contributor

dstaley commented Apr 1, 2024

@Knaackee Thank you for reporting this! I believe this should be fixed in v5, which is available as a canary release in this PR.

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

No branches or pull requests

6 participants