Add a way to add description to virtual modules
Clear and concise description of the problem
I think it would be helpful for users if there's a description for each virtual modules. For example:
rolldown/runtime.js: rolldown's utilty functions that are used in the bundlevite/modulepreload-polyfill.js: Vite's modulepreload polyfill. See https://vite.dev/config/build-options#build-modulepreload./src/App.vue?vue&type=script&setup=true&lang.ts:<script>block of./src/App.vue
Suggested solution
Recommend plugins to add meta.devtools.description values in load hook.
const p = {
name: 'foo',
load(id) {
return { code: content, meta: { devtools: { description: 'Vite's modulepreload polyfill. See https://vite.dev/config/build-options#build-modulepreload' } } }
}
}
and make devtools will read that information.
Alternative
Add the metadata on plugin object:
const p = {
name: 'foo',
meta: {
devtools: {
virtualmodulesDescription: {
'vite/modulepreload-polyfill.js': 'Vite's modulepreload polyfill. See https://vite.dev/config/build-options#build-modulepreload',
}
}
}
}
This does not allow setting the description for dynamic virtual modules.
Additional context
No response
Validations
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guide.
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
I would be up to have the load return approach. but as such data is collected by rolldown, and the description is actually not specific to devtools, I wonder if it should be directly description instead of meta.devtools.description
The type was added to Rolldown. https://rolldown.rs/apis/plugin-api/inter-plugin-communication#descriptive-metadata