Skip to content

Conversation

@Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Jan 7, 2026

This adjusts the loc of the instance/module Program to correspond to the inside of the <script> tag, rather than always being 0. Though I've just realised that this won't actually fix the related issue (#17003) because the problem is the end rather than the start — may need to come up with a different solution. Fixes #17003

The nub of the problem is this — we're setting the bounds of the default-export function body to the bounds of the instance Program so that comments are inserted correctly:

// trick esrap into including comments
component_block.loc = instance.loc;

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2026

🦋 Changeset detected

Latest commit: 9fa846e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Playground

pnpm add https://pkg.pr.new/svelte@17428

@dominikg
Copy link
Member

dominikg commented Jan 7, 2026

ran the tests that were failing in vite-plugin-svelte with vite8 using this PR and they passed. 🥳

do you want to merge #17167 after this as well or close it?

@Rich-Harris Rich-Harris merged commit 044dce9 into main Jan 7, 2026
18 checks passed
@Rich-Harris Rich-Harris deleted the fix-sourcemaps branch January 7, 2026 18:37
@github-actions github-actions bot mentioned this pull request Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid sourcemap when there's \n in the script block

3 participants