Skip to content

fix(extract/transpile): retains svelte(5+) dependencies used exclusively outside <script> sections#1046

Merged
sverweij merged 1 commit intomainfrom
fix/retain-svelte-dependencies-used-outside-script-sections
Feb 6, 2026
Merged

fix(extract/transpile): retains svelte(5+) dependencies used exclusively outside <script> sections#1046
sverweij merged 1 commit intomainfrom
fix/retain-svelte-dependencies-used-outside-script-sections

Conversation

@sverweij
Copy link
Copy Markdown
Owner

@sverweij sverweij commented Feb 5, 2026

Description

  • retains svelte dependencies used exclusively outside <script> sections

Motivation and Context

addresses #1045

How Has This Been Tested?

  • green ci

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where Svelte 5 components lose dependency information for imports used exclusively in template markup (outside <script> sections). The issue occurred because TypeScript preprocessing removed "unused" imports before the Svelte compiler could analyze the template.

Changes:

  • Modified svelte-wrap.mjs to skip TypeScript preprocessing for Svelte 5+, leveraging its native TypeScript support
  • Updated test expectations to verify that component imports are now properly preserved in the transpiled output
  • Added version detection logic to conditionally apply preprocessing only for Svelte 4 and earlier

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/extract/transpile/svelte-wrap.mjs Added major version detection and conditional preprocessing logic to skip TypeScript transpilation for Svelte 5+, which has native TypeScript support
test/extract/transpile/svelte-wrap.spec.mjs Removed test transformation that was stripping the Header import, as it should now be preserved
test/extract/transpile/__fixtures__/svelte.js Added the expected Header import to the fixture to reflect correct dependency detection

@sverweij sverweij changed the title fix(extract/transpile): retains svelte(5) dependencies used exclusively outside <script> sections fix(extract/transpile): retains svelte(5+) dependencies used exclusively outside <script> sections Feb 5, 2026
@sverweij sverweij force-pushed the fix/retain-svelte-dependencies-used-outside-script-sections branch from 153cef6 to 4a1c36b Compare February 6, 2026 19:58
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 6, 2026

@sverweij sverweij merged commit 273581d into main Feb 6, 2026
4 checks passed
@sverweij sverweij deleted the fix/retain-svelte-dependencies-used-outside-script-sections branch February 6, 2026 20:03
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.

2 participants