unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.29k stars 198 forks source link

Wrong hash in Vite types file when installing in a pnpm monorepo #410

Open lucastraba opened 1 year ago

lucastraba commented 1 year ago

Describe the bug

I've been trying to use this plugin in a Vite package of my pnpm monorepo, but I can't, because in the Vite plugin, the import of the types file is: import 'unimport/dist/types-XXXXXX' And the actual file is: types-YYYYYY.d.ts

This seems to only happen with a pnpm monorepo setup, not when installing with npm (path and name match there).

Reproduction steps:

Actual: Import path hash has the same hash as the file

Expected: Import path matches file name

Reproduction

https://codesandbox.io/p/sandbox/zealous-sky-hq87mv?file=%2Ftest.js%3A1%2C46

System Info

Any. This is a build problem.

Used Package Manager

pnpm

Validations

lucastraba commented 1 year ago

An update to this:

This is happening because of pnpm's hoisting. It seems that the unimport build happens separately and generates one hash and then unplugin-auto-import builds based on a different build or a different environment, and produces the wrong import.

Things I tried:

I tried to see if I could come up with a fix and make a PR, but unfortunately I don't have the time to look into it with the amount of attention it would need. For anyone trying to fix it, it's specifically that: the the build of unimport combined with the build of unplugin-auto-import happening in a disconnected way due to pnpm's hoisting.

As it is, I have no choice but to remove the package from our project, but I'll keep an eye on this issue, because I'd really, really like to use this.

lucastraba commented 1 year ago

Bump :(

toimc commented 10 months ago

same here!

lucastraba commented 9 months ago

Any news about this? I'd really really like to use this plugin!

lucastraba commented 3 weeks ago

Bump?