Repository navigation
Description
Vue version
3.5.45 (latest) and 3.6.0-rc.14 (rc), checked on 2026-11-09.
Link to minimal reproduction
https://gist.github.com/satouriko/57bd11242488e19fb6db428805d18c3a
Steps to reproduce
git clone https://gist.github.com/57bd11242488e19fb6db428805d18c3a.git vue-handler-map-repro
cd vue-handler-map-repro
npm install
npm testThe reproduction installs the two unmodified official npm compiler packages under aliases, calls parse() and compileScript() with inlineTemplate: true, and queries the emitted map using SourceMapConsumer.originalPositionFor().
It checks three small event handlers: a multiline arrow, a nested function declaration, and a statement containing only literals. npm test intentionally exits with status 1 when their mapped locations differ from their actual source positions.
The same results occur with default template compiler options:
node repro.mjs --defaultsWhat is expected?
Authored expressions and statements inside an inline event handler should map to their locations in the original SFC. In particular, a nested declaration and a literal-only return statement should retain their own source line rather than being unmapped or pointing back to the event attribute.
For example, this is the literal-only fixture (the first line is line 1):
<script setup>
import { ref } from 'vue';
const flag = ref(false);
const count = ref(0);
</script>
<template>
<button @click="() => {
return true ? 1 : 2;
}">click</button>
</template>The generated return, true, 1, and 2 should map to line 8 at their respective source columns.
What is actually happening?
Both published versions produce the following results. Lines are 1-based and columns are 0-based. Each row refers to the corresponding fixture in repro.mjs.
| Authored token | Expected source position | Actual, 3.5.45 | Actual, 3.6.0-rc.14 |
|---|---|---|---|
Event arrow () => { |
7:18 |
7:16 |
7:16 |
Nested const inner = () => { |
8:4 |
unmapped | unmapped |
return |
8:4 |
unmapped | unmapped |
true |
8:11 |
unmapped | unmapped |
1 |
8:18 |
unmapped | unmapped |
2 |
8:22 |
unmapped | unmapped |
The event arrow starts at column 18, but its generated position maps two characters earlier, to the = of the event attribute. The nested declaration and literal-only statement have no original position at all.
System Info
macOS / arm64
Node.js 24.10.0
npm 11.6.1
@vue/compiler-sfc 3.5.45 and 3.6.0-rc.14
source-map-js 1.2.1Any additional comments?
This is a direct compiler/source-map reproduction. It does not require a bundler, test runner, coverage instrumentation, or a chain of source-map transforms. The concern here is source-location accuracy.
I also ran the same probes against the source of #16126 at c38da1cc2c947418fc6e104df52edf5c4e598f22. That branch improves the missing mappings, but these locations still differ:
| Token | Expected | Actual on #16126 |
|---|---|---|
Event arrow () => { |
7:18 |
7:16 |
Nested const inner = () => { |
8:4 |
7:16 |
return / true / 1 / 2 |
line 8, columns 4 / 11 / 18 / 22 |
all 7:18 |
The reproduction also accepts EXTRA_COMPILER_PATH=/absolute/path/to/core/packages/compiler-sfc to run the same probes against a locally built compiler.
Activity
fix(compiler-core): preserve template expression maps