Skip to content

evaling code breaks if code contains import statements with sources that should be resolved by the bundler #9

@eps1lon

Description

@eps1lon

This is based off of vercel/next.js#76395

The concrete case used React.createElement instead of just JSX to construct elements. However, the same issue occurs if any other React API is being used.

Next.js applies aliases to certain import sources. However, this does not apply to code dynamically evaluated like eval or Reflect.construct. Since next-mdx-remote-client uses Reflect.construct to run code, imports to React will resolve to the wrong version of React. In this case it's the installed, Client React. Mixing different versions of React or Server and Client React in the same component is not supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions