Skip to content

Add an option for overriding the file system module in the JS API #20200

@EggDice

Description

@EggDice

Description

When we write plugins or build tools using Vite's JS API, it would be nice to write in-memory e2e tests to check what is generated from a certain input. Now the Vite codebase is hardwired with the node:fs module. Therefore, we cannot replace it with an in-memory implementation like memfs to run our tools with an in-memory representation of files, then verify the results.

Suggested solution

Rollup just introduced this feature in: rollup@4.43.0
The corresponding issue and PR:
rollup/rollup#5880
rollup/rollup#5944

The solution could be that build function could also take an fs option, similarly to rollup:
https://rollupjs.org/configuration-options/#fs
Also, rollup is providing the fs option to the plugins in the context. It would be nice to have it in Vite as well.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions