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

Import of the remark-gfm, rehype-slug and next-mdx-remote/serialize produce an error #94

Open
mavr1k opened this issue Apr 11, 2022 · 3 comments

Comments

@mavr1k
Copy link

mavr1k commented Apr 11, 2022

I'm working on processing MD and MDX content using remark-gfm, rehype-slug and next-mdx-remote/serialize but I'm receiving an error shown below. Any variation of import (import from, dynamic import and require) doesn't change the behavior.

[next-plugin-preval] Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/user/projects/project/node_modules/remark-gfm/index.js from /Users/user/projects/project/src/preval/partials.preval.ts not supported.
Instead change the require of index.js in /Users/user/projects/project/src/preval/partials.preval.ts to a dynamic import() which is available in all CommonJS modules.
    at Object.newLoader [as .js] (/Users/user/projects/project/node_modules/pirates/lib/index.js:141:7)
    at /Users/user/projects/project/src/preval/partials.preval.ts:2:75
    at async serializeContentTest (/Users/user/projects/project/src/preval/partials.preval.ts:2:18)
    at async Promise.all (index 0)
    at async getPartials (/Users/user/projects/project/src/preval/partials.preval.ts:4:461)
    at async getPartialsConfigs (/Users/user/projects/project/src/preval/partials.preval.ts:5:240)
    at async /Users/user/projects/project/node_modules/next-plugin-preval/dist/loader.js:106:14
    at async _prevalLoader (/Users/user/projects/project/node_modules/next-plugin-preval/dist/loader.js:98:16)
error - ./src/preval/partials.preval.ts
Error: Failed to pre-evaluate "/Users/user/projects/project/src/preval/partials.preval.ts". Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/user/projects/project/node_modules/remark-gfm/index.js from /Users/user/projects/project/src/preval/partials.preval.ts not supported.
Instead change the require of index.js in /Users/user/projects/project/src/preval/partials.preval.ts to a dynamic import() which is available in all CommonJS modules. See above for full stack trace.
@1OGAG
Copy link

1OGAG commented Apr 14, 2022

I have the same issue when using next-mdx-remote and serialize.

"next": "12.1.4",
"next-mdx-remote": "^4.0.2",
"next-plugin-preval": "^1.2.4",
"react": "^17.0.2",
"react-dom": "^17.0.2"

@1OGAG
Copy link

1OGAG commented May 17, 2022

@mavr1k Did you get it to work? I am having the same problem.

@getellez
Copy link

same problem here

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

3 participants