Skip to content

Conversation

@muuim
Copy link

@muuim muuim commented Jan 31, 2026

What

Add documentation for environment.fetchModule in the Environment API docs.

Why

Issue #21500 requested documentation for this API, which is currently undocumented.
This function allows plugins and custom environments to dynamically load modules by ID.

Changes

Example

const mod = await environment.fetchModule('/src/foo.js')
console.log(mod.default)

Notes


`environment.fetchModule`

`fetchModule` is an internal utility available on environmetances in Vite.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'environmetances' should be 'environment instances' or 'environments'.

-`fetchModule` is an internal utility available on environmetances in Vite.
+`fetchModule` is an internal utility available on environment instances in Vite.

This typo will make the documentation confusing and unprofessional.

Suggested change
`fetchModule` is an internal utility available on environmetances in Vite.
`fetchModule` is an internal utility available on environment instances in Vite.

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

`environment.fetchModule`

`fetchModule` is an internal utility available on environmetances in Vite.
It allows plor custom environments to dynamically load a module by ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'plor' should be 'plugins or'.

-It allows plor custom environments to dynamically load a module by ID,
+It allows plugins or custom environments to dynamically load a module by ID,

This typo breaks the sentence readability and will confuse users reading the documentation.

Suggested change
It allows plor custom environments to dynamically load a module by ID,
It allows plugins or custom environments to dynamically load a module by ID,

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment on lines 230 to 231
const mod = await environment.fetchModule('/src/foo.js')
console.log(mod.default)
Copy link

@ematipico ematipico Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this AI generated? Because this is wrong. FetchResult is a union of three types, so using this code isn't type safe and you'll get a compiler error.

EDIT: after checking the second edit, I can confirm this is AI generated, with poor prompting given to the agent. I suggest the intervention of a human. One thing I'd like to see addressed is how to interpret the different variants of FetchResult, and make it type safe

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I understand. I'll correct it immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants