lexical
lexical copied to clipboard
Bug: Importing "@lexical/react" via vite occurs `Failed to resolve entry for package "@lexical/react"`
Lexical version: 0.11.1
Updated: 2023-06-26 See the comment I attached below
Steps To Reproduce
- set up vite project
- install the latest @lexical/react with others
- import { ... } from "@lexical/react"
This seems really strange for me. I thought package is broken but i couldn't find anything from the codebase.
Context: I am trying to provide a rich text editor for general users who are not familiar with Lexical.
I attached my github repo. package.json is just for lexical.
npm run install and npm run dev on my repo
Link to code example: https://github.com/trishulaorg/veil
The current behavior
got
✘ [ERROR] Failed to resolve entry for package "@lexical/react". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-scan]
The expected behavior
Should be imported
I figured out this was because of there's no index.js. Is it intentional? Me personally think it is better for users to provide index file IMHO
I think we can add an index file in @lexical/react
@acywatson If you need my help let me know. I think I can take handle of it when I'm available.
In case someone's app won't have tree shaking, they'll end up having every single @lexical/react plugin bundled. Is there any issues with explicitly importing plugins like @lexical/react/LexicalListPlugin?
In case someone's app won't have tree shaking, they'll end up having every single @lexical/react plugin bundled. Is there any issues with explicitly importing plugins like
@lexical/react/LexicalListPlugin?
I don't think this should be an issue. AFAIK every modern toolchain is supporting treeshaking and even our own packages (at least every one except react) is structured in the same way with this expectation in mind.
I think there is no reason we can't do both though, right?
Experiencing the same issue
ERROR in dll renderer renderer[11]
Module not found: Error: Can't resolve '@lexical/react' in .....
Same here
Adding resolve.alias for @ to your vite.config solved the issue for me. FYI @wspringer
import { defineConfig } from "vite";
import path from "path";
export default defineConfig({
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});
@minamorl @acywatson first of all - a wonderful work. I was curious if there is any update on this topic.