Closed 0xtimsb closed 6 months ago
I'm afraid I'm not familiar with the Astro stack to help you with this. Vanilla Vite works out of the box, you can check some of the adjustments that were made for Next and Remix - perhaps this will give you some clue.
@petyosi https://github.com/withastro/astro/issues/10353#issuecomment-1983613912 can you look into this?
@petyosi withastro/astro#10353 (comment) can you look into this?
I gave you directions in my previous reply, which you did not take into account.
If you expect me to support you and find solutions for your technology of choice, sponsor the project.
Thank you for your work here, @petyosi.
I think this might become a common issue you'll see listed here. This issue isn't isolated to Astro. I've replicated this via remix-vite
:
vite-plugin-cjs-interop
=> same errorClientOnly
via remix-utils
=> same errornoExternal
gives a different error, but it's faulty because (as what @smitbarmase references): I don't think this is an Astro issue. When you
noExternal
a dependency in Vite (especially in dev), you're also saying that the dependency is entirely written in ESM, however@lexical/react
isn't written in ESM, so the issue arises.I think we should fix step 1 first (Initial Issue with Named Export), instead of making the rest work. The issue can be replicated by creating a
test.mjs
file with:import "@mdxeditor/editor";
And running
node test.mjs
. The@mdxeditor/editor
package is not Node-friendly and should be fixed instead.
@the-wc I'm not following the latest development of remix closely, noticed that they're moving to vite. There's a working mdxeditor in remix setup, https://github.com/mdx-editor/mdx-editor-in-remix. As far as I can tell, ClientOnly works as expected. You can fork that example and show me what's going on to help further.
Up to your quote above, this package is unlikely to be node friendly anytime soon, for a few reasons:
I greatly appreciate effective help and contributions on the matter in the sense of concrete, reproducible issues that take into account the directions I've given so far. "Does not work" and "same error" are not enough, unfortunately.
@petyosi
I am also getting this issue with a project I am working on and I have pushed a PR to upgrade lexical
. Hopefully it fixes the problem but it might not be as simple as that and the fix might need to happen in the lexical
library.
https://github.com/mdx-editor/editor/pull/402
Look forward to any feedback.
Cheers
If you want to ask for support or request features, sponsor the project and contact me over email.
Describe the bug SyntaxError An error occurred. Named export '$isElementNode' not found. The requested module 'lexical' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:
import pkg from 'lexical'; const { $isElementNode } = pkg; Stack Trace file:///Users/smitbarmase/site/node_modules/@mdxeditor/editor/dist/exportMarkdownFromLexical.js:1 import { $isElementNode } from "lexical"; ^^^^^^^^^^^^^^ SyntaxError: Named export '$isElementNode' not found. The requested module 'lexical' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:
import pkg from 'lexical'; const { $isElementNode } = pkg;
Reproduction Codesandbox link
To Reproduce Steps to reproduce the behavior:
import { MDXEditor, headingsPlugin } from "@mdxeditor/editor";
npm run dev
Expected behavior It should build on dev.
Screenshots
Desktop (please complete the following information):
Additional context Add any other context about the problem here.