vitejs / vitejs/devtools

Add a way to add description to virtual modules

Open
#171 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.2k
Forks
89
Avg merge
18h 46m
Merged PRs (30d)
24

Description

Clear and concise description of the problem
Image Image

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 bundle
  • vite/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the plugin load hook and the devtools handling of module metadata, focusing on the proposed meta.devtools.description value and the virtualmodulesDescription alternative. The work is done when virtual modules can expose descriptions, including dynamically created modules, and devtools display those descriptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
api, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.