Open VeekeeFr opened 6 months ago
Hey! π
Did someone intentionally write require('react')
as require('/node_modules/react')
?
Additionally, the following code can works in Vite now. π
require('/node_modules/react')
// ββββ convert ββββ
import '/node_modules/react'
Hello π
Yep, in a project dependency I have no control of :(
My project architecture is not that simple :
Dependency Project A (module with 'node_modules/react')
// ββββ dependency ββββ
Dependency Project B (module => migrated to Vite)
// ββββ dependency ββββ
Project C (using Webpack)
Without the patch :
Project C is able to load/work with 'node_modules/react' (webpack / conf magic ?)
Project B can only be started/tested via StoryBook. In that environnement, StoryBook fails to load "node_modules/react". That may be caused by a Storybook default Vite settings, though I tried to remove them one by one but couldn't find the culprit.
I found easier to work with your plugin :)
Hello @yejimeiming
While converting my project packager to Vite, I encountered some issues with a CJS dependency declaring its imports with "/node_modules/..."
Example : require("/node_modules/react")
Even with your plugin, it causes some issues and I couldn't find any other options or solutions (like aliases...) other than customizing your plugin.
This MR adds a "namingRules" advanced option (function), allowing to customize any detected import to a proper value).
I hope you'll find it useful/usable and include it in your plugin.
Feel free to contact me Β²for any information
PS : Sorry if my TS code is imperfect (I'm used to JS :D )