rollup-plugin-visualizer icon indicating copy to clipboard operation
rollup-plugin-visualizer copied to clipboard

`visualize()` returns wrong type when loading from `vite` in TypeScript.

Open ennioVisco opened this issue 3 years ago • 4 comments

OS & Node info



Screenshot of the problem

image

I guess this is missing the Rollup config, which I'm not sure how to extract from nuxt, but I guess I can work on it if found helpful.

ennioVisco avatar Sep 14 '22 14:09 ennioVisco

Hi. Thanks for report. Need some details. There was similar issue recently. Can you please run yarn ls rollup and yarn ls rollup-plugin-visualizer. I do not remember if yarn has ls command, if not try with npm pls.

btd avatar Sep 14 '22 16:09 btd

Hello. I had the same phenomenon here. It seems to be caused by a change in the Rollup Plugin type at some point and older versions of Vite cannot handle it. In my environment, lowering the Rollup version to <=2.77.3 or raising the Vite version to >=3.1.0 works fine.

npm i -D [email protected]

or

npm i -D [email protected]

n4o847 avatar Sep 14 '22 17:09 n4o847

Hello, thanks @btd for the quick reply! Here are the reports:

npm ls rollup: image

npm ls rollup-plugin-visualizer: image

@n4o847 It doesn't seem to work unfortunately... Here is the current vite I am using: image

ennioVisco avatar Sep 15 '22 06:09 ennioVisco

Problem is that you have 2 rollup versions, and it seems 2.79 are in root. I hoped vite 3.1 will update rollup, but it seem they did not. That change created so much mess. I will see if i can reorganize type structure, but i am worry it will be not possible until vite will align with last version of rollup. As workaround you can pin rollup to 2.78 or just cast plugin to PluginOptions

btd avatar Sep 18 '22 10:09 btd

I will probably close this as on my side there is no anything i can do for now. This issue actually must be created on vite+rollup side as they created mess with last releases. Vite 3.1 limit rollup version to 2.78.x Most of rollup plugins has rollup in peerDependencies, and a lot of them do not have complimentary meta entry to mark it optional. This causes always 2 rollup installations. One for vite and one for plugin. I fixed this in this plugin, but this could be caused now by any plugin now it seems. Which one will install rollup in the root first. If never installed in the root, when ts will see config for vite will use it its types.

btd avatar Sep 25 '22 14:09 btd