Last 12 weeks · 303 commits
5 of 6 standards met
Describe the bug As https://github.com/vitejs/vite/blob/dcf88bd2ad2b1a8845f9029587cc8c825e382d42/packages/vite/src/node/plugins/css.ts#L2910 shows, the css adapter requires the less API . However, less 5 removes this API (https://github.com/less/less.js/commit/937d1e44e875e361135f0bb94221d409c1afaa58), result in the following error: Reproduction https://stackblitz.com/edit/vitejs-vite-392jf7f8 Steps to reproduce Run followed by System Info Used Package Manager npm Logs Click to expand! Validations [x] Follow our Code of Conduct [x] Read the Contributing Guidelines. [x] Read the docs. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead. [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server. [x] The provided reproduction is a minimal reproducible example of the bug.
Description deletes a real newline instead of collapsing it to a space, so any / candidate whose URL and descriptor are separated only by a newline gets glued together. This is not cosmetic: runs on every and writes the result back with , so is handed to , which cannot resolve it — the build logs an unresolvable-asset warning and emits HTML pointing at a 404 URL. The CSS path uses the same helper. Cause In : Those are literal backslash sequences — the HTML-escaped whitespace forms — so this regex never matches a real newline. A real newline therefore reaches the next line, , which deletes it (and, being non-global, only the first one). The immediately after already normalizes and correctly, so the deleting line is both wrong and unnecessary — this PR removes it. The line was introduced in #18242 while making srcset parsing spec compliant. Why it went unnoticed: the common multi-line is indented, so the indentation spaces collapse to a separator that survives. Only a newline used as the sole separator corrupts the value. Tests Two cases added to the existing suite in (LF and CRLF). Both fail on () and pass with this change. Full is green (922 passed, 4 skipped); and oxfmt/eslint on the changed files are clean. Possible follow-up (not included) The adjacent is also non-global and made redundant by the collapse that follows. Left untouched to keep this a strict fix.
Describe the bug For string interpolation with valid expression, dollar sign concat with string happen to be invalid expression. In dev server , this runs correctly, renders expression, and string . however succeeds, without producing any javascript output, no In my tests, below will not trigger the problem: 1. valid object 2. escape dollar 2. only dollar without first valid expression Reproduction https://stackblitz.com/edit/vitejs-vite-xhnudkqg?file=src%2FApp.tsx&terminal=dev Steps to reproduce Use stackblitz, new terminal, run System Info Used Package Manager npm Logs Click to expand! Validations [x] Follow our Code of Conduct [x] Read the Contributing Guidelines. [x] Read the docs. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead. [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server. [x] The provided reproduction is a minimal reproducible example of the bug.
Describe the bug in decides where hoisted statements may be inserted by matching the hashbang with: In a JavaScript regex, matches no line terminator — including . So for a module whose first line ends in CRLF (), stops before the , the required can't match, and the regex fails as a whole: then returns , and ( — ) hoists the statements to position 0, above the hashbang, stranding in the middle of the module: A hashbang is only legal at offset 0, so V8 rejects the module with a bare — no file position, no code frame — which makes the failure very hard to attribute. With LF endings the regex matches and imports are hoisted after the shebang, as intended. That behavior was fixed for LF in #12976 by #12985 (the PR that introduced ); the CRLF case was left behind. Code (v8.0.16): https://github.com/vitejs/vite/blob/v8.0.16/packages/vite/src/node/utils.ts#L1830-L1835 https://github.com/vitejs/vite/blob/v8.0.16/packages/vite/src/node/ssr/ssrTransform.ts#L94-L95 Still present on (791843e1591e): https://github.com/vitejs/vite/blob/791843e1591e/packages/vite/src/node/utils.ts#L1992-L1997 is also used by to anchor hoisted assignments (https://github.com/vitejs/vite/blob/791843e1591e/packages/vite/src/node/plugins/importAnalysis.ts#L993), so any consumer mis-anchors on CRLF hashbang files; the practical hit is the SSR / module-runner path. Practical impact: a Vitest test importing a shebang'd CLI entry passes on Linux CI but fails to collect on a Windows checkout with (repo stores LF, working tree gets CRLF). Likely earlier sighting of this exact variant: vitest-dev/vitest#3244 — Windows paths in the log, filed right as Vite 4.3's import hoisting shipped, closed as a duplicate of #12976, but the LF-only fix in #12985 would not have helped a CRLF checkout. Suggested fix: accept an optional (and, while at it, a hashbang line with no trailing newline): Or, to follow the ECMAScript HashbangComment grammar exactly (the comment runs to any LineTerminator: , , , ), something like . Either way the insertion point must land after the full terminator sequence — after the of a pair, never between and . Reproduction https://github.com/laurentminguez/vite-crlf-hashbang-repro → . The repro commits with byte-exact CRLF (marked in ) and re-asserts the bytes in a step, so it reproduces on any OS — including StackBlitz: https://stackblitz.com/github/laurentminguez/vite-crlf-hashbang-repro (run in the terminal). A fully scripted equivalent is below. Steps to reproduce Self-contained — the script writes the CRLF bytes explicitly, so it reproduces on any OS; no git or involvement needed: How this is hit in real projects: a shebang'd CLI entry is stored with LF in git and checked out on Windows with , so the working-tree file has CRLF — the module then fails to import under vitest / vite-node / the module runner on that machine only, while Linux CI stays green. Workaround until fixed: force LF via (e.g. ). System Info Used Package Manager npm Logs CRLF run: LF control run (only line endings changed): Validations [x] Follow our Code of Conduct [x] Read the Contributing Guidelines. [x] Read the docs. [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [x] Make sure this is a Vite issue and not a framework-specific issue. [x] Check that this is a concrete bug. [x] The provided reproduction is a minimal reproducible example of the bug.
Repository: vitejs/vite. Description: Next generation frontend tooling. It's fast! Stars: 82356, Forks: 8651. Primary language: TypeScript. Languages: TypeScript (83%), JavaScript (9.4%), HTML (4.4%), CSS (2.6%), Vue (0.2%). License: MIT. Homepage: http://vite.dev Topics: build-tool, dev-server, frontend, hmr, vite. Latest release: plugin-legacy@8.2.3 (1w ago). Open PRs: 100, open issues: 690. Last activity: 6h ago. Community health: 87%. Top contributors: yyx990803, sapphi-red, patak-cat, bluwy, renovate[bot], antfu, btea, hi-ogawa, underfin, shulaoda and others.