datopian / datahub

🌀 Rapidly build rich data portals using a modern frontend framework
https://datahub.io/opensource
MIT License
2.17k stars 322 forks source link

[components] Build fails with "Uncaught SyntaxError: Identifier 'eh' has already been declared" when using the components imported from @portaljs/components with next-mdx-remote #1058

Closed olayway closed 1 month ago

olayway commented 5 months ago

Issue

Build fails with "Uncaught SyntaxError: Identifier 'eh' has already been declared" when using the components imported from @portaljs/components with next-mdx-remote:

import { MDXRemote, MDXRemoteProps } from "next-mdx-remote";
import {
        Vega,
        VegaLite,
        FlatUiTable,
        LineChart,
} from "@portaljs/components"

export default function MDX({
    source,
}: {
    source: MDXRemoteProps,
}) {

    const components = {
        Vega,
        VegaLite,
        FlatUiTable,
        LineChart,
    };

    return (
        <article suppressHydrationWarning={true}>
            <MDXRemote {...source} components={components} />
        </article>
    );
}

However, when copying over the components' code directly to the project, there is no error:

import { MDXRemote, MDXRemoteProps } from "next-mdx-remote";
import { Vega, VegaLite } from "react-vega";
import { LineChart } from "./LineChart";
import { FlatUiTable } from "./FlatUiTable";

export default function MDX({
    source,
}: {
    source: MDXRemoteProps,
}) {

    const components = {
        Vega,
        VegaLite,
        FlatUiTable,
        LineChart,
    };

    return (
        <article suppressHydrationWarning={true}>
            <MDXRemote {...source} components={components} />
        </article>
    );
}

I suspect there must be something off with the build settings of the @portaljs/components package?

Reproduction

  1. Get this repo https://github.com/datopian/datarich-app/tree/portaljs-components-error
  2. npm i
  3. npm run build && npm start
  4. Open the browser console to see the error (it also makes the dynamic preview component stuck at "Loading...")
olayway commented 5 months ago

This doesn't happen when using mdx-bundler.

olayway commented 1 month ago

It's not an issue anymore so closing as WONTFIX