-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)good first issueGood for newcomers. If you need additional guidance, feel free to post in #dev on DiscordGood for newcomers. If you need additional guidance, feel free to post in #dev on Discordregression
Description
Astro Info
Astro v5.16.7
Node v24.12.0
System macOS (arm64)
Package Manager bun
Output static
Adapter @astrojs/cloudflare
Integrations @astrojs/starlight
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
JSON.stringify() always returns a string, so nullish coalescing on its interpolated output is dead code.
| export const viteFSConfig = ${JSON.stringify(resolvedConfig.server.fs)} ?? {}; |
astro/packages/astro/src/assets/vite-plugin-assets.ts
Lines 157 to 160 in e73deb8
| export const safeModulePaths = new Set(${JSON.stringify( | |
| // @ts-expect-error safeModulePaths is internal to Vite | |
| Array.from(resolvedConfig.safeModulePaths), | |
| )} ?? []); |
When safeModulePaths is empty, this generates:
new Set([] ?? []);esbuild flags this during bundling (e.g., via wrangler):
▲ [WARNING] The "??" operator here will always return the left operand [suspicious-nullish-coalescing]
Likely introduced in
Runtime behavior seems correct.
This could probably be fixed by removing the ?? {} and ?? [] fallbacks entirely, or by guarding the template with emptiness checks.
What's the expected result?
No warning.
Link to Minimal Reproducible Example
decline
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
- P2: nice to haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)good first issueGood for newcomers. If you need additional guidance, feel free to post in #dev on DiscordGood for newcomers. If you need additional guidance, feel free to post in #dev on Discordregression