-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
How to use codeHike with esm import in next.js #156
Comments
Hmm, nextjs isn't loading codehike as an es module. I'm going to rename codehike index.esm.js to .mjs and publish a new version. |
You can try this version for now: npm install @code-hike/mdx@0.4.0-next.3 |
I tried with But i got some new errors when i visit my mdx page:
Here is call stack:
Seems when i use .mjs file, the sandpcak-client is a CommonJS module. it's cannot work with My mdx file just have basic markdown syntax. and i am not use another highlight plugin. Here is my import remarkFrontmatter from 'remark-frontmatter';
import mdx from '@next/mdx';
// import rehypePrism from '@mapbox/rehype-prism';
import composePlugins from 'next-compose-plugins';
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';
import { remarkCodeHike } from '@code-hike/mdx';
const composedConfig = composePlugins([
mdx({
extension: /\.mdx?$/,
options: {
remarkPlugins: [remarkFrontmatter, remarkGfm, [remarkCodeHike]],
rehypePlugins: [
// rehypePrism,
rehypeSlug,
],
providerImportSource: '@mdx-js/react',
},
}),
/** @type {import('next').NextConfig} */
{
reactStrictMode: true,
// experimental: {
// reactMode: 'concurrent',
// },
experimental: {
outputStandalone: true,
},
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
},
]);
export default composedConfig; I don't know how rollup work with .mjs, hope these information can provide a littile help |
I couldn't reproduce it. It will help if you can create a minimal repo so I can debug it. |
Hi, i create a minimal repo, https://github.com/DefectingCat/code-hike-test. It's installed mdx plugin and Please visit |
Ok, |
It;s works with React 17. Thank you. |
🚀 Issue was released in |
The next.js config is cjs file. But some remark plugins only provide esm packages, so i change my
next.config.js
tonext.config.mjs
and use it like:I need use codeHike with remark plugins together, i tried:
Well, import is OK, but i got erros:
I need a little help
The text was updated successfully, but these errors were encountered: