Skip to content

add transforms API and migrate all addons#1001

Open
jycouet wants to merge 11 commits intomainfrom
feat/transforms-api
Open

add transforms API and migrate all addons#1001
jycouet wants to merge 11 commits intomainfrom
feat/transforms-api

Conversation

@jycouet
Copy link
Contributor

@jycouet jycouet commented Mar 21, 2026

Summary

  • Adds typed, parser-aware transforms namespace to @sveltejs/sv-utils — wraps parse → callback(ast/data) → generateCode() into a single function
  • Adds transforms.html (new — previously only parse.html existed)
  • Engine detects transforms via isTransform() and injects workspace context (language) automatically
  • Migrates all official addons from parse.* to transforms.*
  • Net -148 lines across addons

parse is retained.

Prep for community add-on improvements.

jycouet added 2 commits March 21, 2026 18:49
Typed, parser-aware `string -> string` functions that wrap
parse -> callback(ast/data) -> generateCode(). Includes transforms
for script, svelte, css, json, yaml, toml, html, and text.

The engine detects transforms via `isTransform()` and injects
workspace context (language) automatically.
Mechanical migration: every `sv.file()` callback that followed the
parse -> mutate -> generateCode pattern now uses the typed transform.

`parse` is retained only where transforms don't fit:
- prettier.ts: try/catch around JSON parsing
- sveltekit-adapter.ts: conditional parser (json vs toml) and
  standalone parse outside sv.file
@changeset-bot
Copy link

changeset-bot bot commented Mar 21, 2026

⚠️ No Changeset found

Latest commit: 383a38d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 21, 2026

Open in StackBlitz

npx https://pkg.pr.new/svelte-migrate@1001
npx https://pkg.pr.new/sv@1001
npx https://pkg.pr.new/@sveltejs/sv-utils@1001

commit: e8bec28

@jycouet jycouet mentioned this pull request Mar 21, 2026
12 tasks
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.

1 participant