Open mjwsteenbergen opened 4 months ago
Start a new pull request in StackBlitz Codeflow.
I didn't even know such symlink outside of vite.config.ts
root would work, but for this specific peculiar behavior is probably coming from react
plugin automatically adding resolve.dedupe: ["react", ...]
https://github.com/vitejs/vite-plugin-react/blob/814ed8043d321f4b4679a9f4a781d1ed14f185e4/packages/plugin-react/src/index.ts#L273 which allows resolving project/node_modules/react
from anywhere (which is not a standard NodeJs node_modules resolution).
Technically your repro can be fixed if you add 'iconoir-react'
there, but I think what you're trying to do is unusual vite setup, so it wouldn't be surprising if something else breaks and requires more workaround later on.
https://stackblitz.com/edit/vitejs-vite-61deqy?file=project%2Fvite.config.ts
export default defineConfig({
plugins: [react()],
resolve: {
dedupe: ['iconoir-react']
}
})
so it wouldn't be surprising if something else breaks and requires more workaround later on
Yeah, I'll try something else then. If you're interested, I tried your workaround and it did not work
Describe the bug
I am very confused. I have the following folder structure:
Without using any libraries in
content-folder
, vite compiles everything correctly. Using any library will give the error:There is one exception: React. Imports from React, like
useState
are fine to use and will not break. Are you confused too? Do you not believe me (I wouldn't either)? Use the stackblitz with the steps to reproduce below.Why do I want to do this weird stuff
I have multiple little react applications. I do not want to have to update them seperately. So I want to create a main repo with all the vite, tailwind, typescript, eslint and other configuration, I can clone as a submodule, so I don't have to keep 5 different projects updated.Reproduction
https://stackblitz.com/edit/vitejs-vite-tjryyi
Steps to reproduce
In the stackblitz, execute the following commands:
Failed to resolve import "iconoir-react" from "../code/App.tsx". Does the file exist?
<QuestionMark />
on line 22 in `code/App.tsxuseState
are correctly resolvedSystem Info
Used Package Manager
npm
Logs
No response
Validations