You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using ui-components with NextJs, I'm getting the following error:
It appears that Next is loading the common js bundle, when we expect it to load the ESM bundle. This problem seems related to this issue. The best solution I have found is installing next-transpile-modules and enabling the experimental esmExternal option in the next.config.js.
The next.config.js file looks like this:
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: { esmExternals: true },
};
const withTM = require("next-transpile-modules")([
"@macrostrat/hyper",
"@macrostrat/ui-components",
]); // pass the modules you would like to see transpiled
module.exports = withTM(nextConfig);
After this, we can import ui-components directly through lib/esm. For instance:
import {
ModelEditor,
useModelEditor,
ModelEditButton,
} from "@macrostrat/ui-components/lib/esm";
TL;DR:
Install next-transpile-modules and import @macrostrat/ui-components/lib/esm to fix esm error with nextjs.
The text was updated successfully, but these errors were encountered:
When using ui-components with NextJs, I'm getting the following error:
It appears that Next is loading the common js bundle, when we expect it to load the ESM bundle. This problem seems related to this issue. The best solution I have found is installing
next-transpile-modules
and enabling the experimentalesmExternal
option in thenext.config.js
.The
next.config.js
file looks like this:After this, we can import ui-components directly through
lib/esm
. For instance:TL;DR:
Install
next-transpile-modules
and import@macrostrat/ui-components/lib/esm
to fix esm error with nextjs.The text was updated successfully, but these errors were encountered: