#10879 Vite plugin breaks `.html` subpath imports
Bug confirmed in current codebase. cleanUrl() regex /[?#].*$/ strips entire subpath import specifiers starting with #, breaking imports like #path/to/file.html.
Keep open - valid bug with clear root cause and fix approach identified.
Analysis Report
Issue Review: cloudflare/workers-sdk#10879
Summary
Vite plugin crashes when processing HTML files imported via subpath imports (e.g., import("#path/to/file.html")) because cleanUrl() strips the entire path starting with #.
Findings
- Created: 2025-10-05
- Updated: 2026-01-01
- Version: wrangler 4.40.3 (current: 4.60.0)
- Component: vite-plugin-cloudflare
- Labels:
bug,vite-plugin - Comments: 1 (reporter's workaround)
Key Evidence
- Root cause identified by reporter: The
cleanUrl()regex/[?#].*$/inpackages/vite-plugin-cloudflare/src/utils.tsstrips everything from#onwards, which breaks subpath imports that begin with# - Bug still present: Verified that
cleanUrl()at utils.ts:45-47 still uses the problematic regex - No related PRs found: Searched for PRs mentioning #10879, "cleanUrl", "subpath", and "additional-modules" - no fix has been merged
- Not in changelog: Issue number and related keywords not found in vite-plugin-cloudflare CHANGELOG.md
- Reporter provided workaround: Filtering out the
vite-plugin-cloudflare:additional-modulesplugin works around the issue - Feature request included: Reporter suggests making the
.html/.txthandling configurable (similar to Vite'sassetsInclude)
Recommendation
Status: KEEP OPEN
Reasoning: This is a confirmed, unfixed bug with a clear root cause identified. The cleanUrl() function incorrectly handles subpath imports (which start with #) because the regex /[?#].*$/ was designed to strip URL query parameters and hash fragments, not handle import specifiers. The fix would require distinguishing between URL hash fragments and subpath import prefixes.
Action: Keep open - this is a valid bug that needs to be fixed. A potential fix could:
- Check if the URL starts with
#(subpath import) before applyingcleanUrl() - Or modify the regex to only match
?and#that appear after path characters - Or skip
cleanUrl()for subpath imports entirely since they shouldn't have query/hash suffixes
Notes & Feedback (0)
No notes yet.