vite-plugin-solid icon indicating copy to clipboard operation
vite-plugin-solid copied to clipboard

During dev mode, each time node_modules package imports file internally, makes that module have unique identity.

Open minht11 opened this issue 3 years ago • 3 comments

During dev mode, each time node_modules package imports file internally, makes that module have unique identity.

// inside node_modules/some-package

// a.js
export const uniqueVariable = {}

// b.jsx
import { uniqueVariable }  from './a'
export compare = (variable) => uniqueVariable === variable

// index.jsx
import { uniqueVariable }  from './a'
import { compare }  from './b'
compare(uniqueVariable) // Produces false

After updating to latest Solid version, from Solid 1.4.4 I noticed that useContext broke with my library, and that lead me to discovering this issue. The issue only occurs during dev mode and only inside with node_modules.

Reproduction

I manually edited node_module of my package to check. Screenshot 2022-12-10 at 19 48 28

minht11 avatar Dec 10 '22 18:12 minht11

What version of the plugin are you using? And do you still have this problem? We did a lot of work to get deduping to work but I imagine there are still gaps.

ryansolid avatar Mar 21 '23 17:03 ryansolid

Tried updated everything to the latest, so plugin version would be 2.6.1, I am still experiencing this issue.

minht11 avatar Mar 21 '23 22:03 minht11

I think this might be related to https://github.com/solidjs/vite-plugin-solid/issues/80 since my context is also defined in tsx file, but I haven't tested to see if that is the root issue.

minht11 avatar Mar 21 '23 22:03 minht11