devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Vite: Avoid reading node_modules after building

Open liangmiQwQ opened this issue 10 months ago • 5 comments

Related https://github.com/vitejs/devtools/pull/151#pullrequestreview-3615746309

Since it is an after-build analyze devtools, I think it is also important to make display effect to be the same after building no matter what actions you have done except editing the files in .rolldown dir, there are two ways to implement:

  • Since we only require the package name and its version, I think we can do something at rolldown side to save the metadata in the logs, and read the metadata rather than node_modules. It is an easy but a little breaking way since the data struct is changed
  • Another workaround is try to get the the information required from the file URL, it is a little bit hacky and different package manager can have different path format for parsing.

liangmiQwQ avatar Jan 07 '26 10:01 liangmiQwQ

The current solution is temporary, I will communicate with the rolldown side to see if it is possible to provide the packages info. I think this would be a better solution.

webfansplz avatar Jan 07 '26 13:01 webfansplz

Okay, and I think it is not very difficult, I will also try to take part in implementing it. Thanks!

liangmiQwQ avatar Jan 07 '26 13:01 liangmiQwQ

Note after viewing the code logic: the current logic uses chunks from ChunkGraph and cut the path to get the package path, we can just add the similar logic and package.json file reads there. and I think we should add packages object in ChunkGraphReady hook (like { action: "ChunkGraphReady", chunks: chunk_infos, packages: package_infos }) or others.

https://github.com/rolldown/rolldown/blob/b381fe6ab9931bde102ef2282617233824bceb1c/crates/rolldown/src/stages/generate_stage/mod.rs#L609-611

liangmiQwQ avatar Jan 07 '26 14:01 liangmiQwQ

I have communicated and confirmed that rolldown will take over support for this.

webfansplz avatar Jan 08 '26 12:01 webfansplz

Okay, thanks!

liangmiQwQ avatar Jan 08 '26 12:01 liangmiQwQ