Skip to content

fix: use literal envPrefix queries for Vite Task#22706

Merged
sapphi-red merged 1 commit into
vitejs:mainfrom
wan9chi:codex/vite-envprefix-getenvs-prefix
Jun 19, 2026
Merged

fix: use literal envPrefix queries for Vite Task#22706
sapphi-red merged 1 commit into
vitejs:mainfrom
wan9chi:codex/vite-envprefix-getenvs-prefix

Conversation

@wan9chi

@wan9chi wan9chi commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Problem

The Vite Task integration reports envPrefix values to getEnvs as glob patterns like ${prefix}*. That creates a corner case where an envPrefix containing * is treated as a wildcard by the task client, while Vite itself treats envPrefix as a literal string prefix.

Solution

Use the literal prefix query form from @voidzero-dev/vite-task-client@0.2.0, added in voidzero-dev/vite-task#472, and call getEnvs({ prefix }) for each configured envPrefix.

Compatibility

This can move to the 0.2.0 client query form without released-compatibility fallout because no Vite Task release with vite-task-client client support has shipped yet. There is no released Vite Task version depending on the previous client query contract.

@wan9chi wan9chi force-pushed the codex/vite-envprefix-getenvs-prefix branch from e47428a to a99d301 Compare June 18, 2026 16:39
Co-authored-by: GPT-5 Codex <codex@openai.com>
@wan9chi wan9chi force-pushed the codex/vite-envprefix-getenvs-prefix branch from a99d301 to cd22bde Compare June 18, 2026 16:46
@wan9chi wan9chi marked this pull request as ready for review June 18, 2026 16:52
// the runner record each glob in the build's cache key.
// the runner record each prefix in the build's cache key.
for (const prefix of prefixes) {
Object.assign(env, getEnvs(`${prefix}*`))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of using prefix, should we escape * like FOO\*BAR* (prefix is FOO*BAR in this case)?
That would be more expressive and can support suffix or wildcard in the middle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I considered escaping on the Vite side, but that would require Vite to be aware of the full glob syntax supported by Vite Task (currently it's https://docs.rs/globset/0.4.18/globset/#syntax) and escape all the metacharacters correctly.

I think it's better to just let Vite express the intent here ("getting envs with this prefix"). Then Vite Task can handle the escaping internally alongside the glob implementation. That also leaves room for Vite Task to change the underlying matcher later, for example escaping to regex instead of glob, without breaking anything.

@sapphi-red sapphi-red added the p2-edge-case Bug, but has workaround or limited in scope (priority) label Jun 19, 2026
@sapphi-red sapphi-red merged commit da72733 into vitejs:main Jun 19, 2026
20 checks passed
@wan9chi wan9chi deleted the codex/vite-envprefix-getenvs-prefix branch June 19, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants