Skip to content

feat(twoslash-svelte): markup cutting - #91

Merged
antfu merged 15 commits into
twoslashes:mainfrom
Hugos68:feature/twoslash-svelte-html-cuts
Jun 22, 2026
Merged

feat(twoslash-svelte): markup cutting#91
antfu merged 15 commits into
twoslashes:mainfrom
Hugos68:feature/twoslash-svelte-html-cuts

Conversation

@Hugos68

@Hugos68 Hugos68 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

This PR adds the possibility to do cuts like // ---cut-before--- but inside markup using HTML style comments:

<!-- ---cut-start--- -->
<script>
    let count = $state(0);
    
    function increment() {
        count++;
    }

</script>
<!-- ---cut-end--- -->

<button onclick={increment}>
    Count is: {count}
</button>

Outputs:

{
  "code": "\n<button onclick={increment}>\n    Count is: {count}\n</button>",
  "nodes": [
    {
      "type": "hover",
      "text": "(local function) increment(): void",
      "start": 18,
      "length": 9,
      "target": "increment",
      "line": 1,
      "character": 17
    },
    {
      "type": "hover",
      "text": "let count: number",
      "start": 45,
      "length": 5,
      "target": "count",
      "line": 2,
      "character": 15
    }
  ],
  "flags": []
}

This is useful for example on the Svelte docsite where this will be implemented to cut out bloated scripts that setup some javascript to showcase markup functionality while still being able to typecheck and twoslash those.

@netlify

netlify Bot commented Jun 7, 2026

Copy link
Copy Markdown

Deploy Preview for twoslash ready!

Name Link
🔨 Latest commit 001f53e
🔍 Latest deploy log https://app.netlify.com/projects/twoslash/deploys/6a3886682783900008534639
😎 Deploy Preview https://deploy-preview-91--twoslash.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.57%. Comparing base (f86ad13) to head (001f53e).

Files with missing lines Patch % Lines
packages/twoslash-svelte/src/index.ts 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   90.50%   90.57%   +0.07%     
==========================================
  Files          17       17              
  Lines        1043     1072      +29     
  Branches      333      352      +19     
==========================================
+ Hits          944      971      +27     
- Misses         93       95       +2     
  Partials        6        6              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Hugos68
Hugos68 marked this pull request as draft June 7, 2026 16:52
@Hugos68
Hugos68 marked this pull request as ready for review June 7, 2026 20:17
Hugos68 and others added 5 commits June 7, 2026 22:35
…te-html-cuts

# Conflicts:
#	packages/twoslash-svelte/package.json
#	packages/twoslash-svelte/src/index.ts
@antfu
antfu merged commit 5649061 into twoslashes:main Jun 22, 2026
11 checks passed
@antfu

antfu commented Jun 22, 2026

Copy link
Copy Markdown
Member

Thanks!

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.

3 participants