You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
svelte-preprocess does not remove lang="ts" from generated files - only lang="typescript". This differs from vitePreprocess as it expects lang="ts" and is confusing for users who might need svelte-preprocess after starting with vitePreprocess.
Generated svelte components do not have a line break following the opening <script> tag.
Generated svelte components do not have the generics attribute removed from <script> tags.
Generated svelte components do not apply prettier configuration. While we can manually run prettier on the dist folder but it would be nice if svelte-preprocess followed the configured rules.
To Reproduce
Create a Svelte component with the following code:
<scriptlang="typescript"generics="T extends BaseChartOptions">
import { onMount, afterUpdate, onDestroy, createEventDispatcher } from'svelte'importtype { Charts, ChartConfig, BaseChartOptions, ChartTabularData } from'@carbon/charts'interfaceDispatchedEvents { load:null update: { data:ChartTabularData; options:T } destroy:null }typeCoreChartClass=new (holder:HTMLDivElement, chartConfigs:ChartConfig<T>) =>Chartsconst chartHolderCssClass ='cds--chart-holder'// Used by Carbon Charts CSSexportlet data:ChartTabularData= [] // Chart data, default is emptyexportlet options:T= {} asT// Specific chart option type, default is emptyexportlet Chart:CoreChartClass// Used to instantiate next propertyexportlet chart:Charts|undefined// Instance of the chart classexportlet ref:HTMLDivElement|undefined// Binding to chart 'holder' in template belowexportlet id =`chart-${Math.random().toString(36)}`// id for chart holder elementconst dispatch =createEventDispatcher<DispatchedEvents>()onMount(() => {try {chart=newChart(refasHTMLDivElement, { data, options })dispatch('load') } catch (error) {console.error('Failed to initialize chart:', error) } })afterUpdate(() => {if (chart) {try {chart.model.setData(data)chart.model.setOptions(options)dispatch('update', { data, options }) } catch (error) {console.error('Failed to update chart:', error) } } })onDestroy(() => {if (chart) {dispatch('destroy')// Like core's Chart.destroy() but keeps div chart holder bound to ref as it's part of this templatechart.components.forEach(component=>component.destroy())chart.model.set({ destroyed: true }, { skipUpdate: true })chart=undefined } })
</script>
<div {id} bind:this={ref} class={chartHolderCssClass} {...$$restProps}></div>
Build with svelte-preprocess.
Look at output...
<scriptgenerics="T extends BaseChartOptions">import { onMount, afterUpdate, onDestroy, createEventDispatcher } from'svelte';constchartHolderCssClass='cds--chart-holder'; // Used by Carbon Charts CSSexportlet data = []; // Chart data, default is emptyexportlet options = {}; // Specific chart option type, default is emptyexportlet Chart; // Used to instantiate next propertyexportlet chart; // Instance of the chart classexportlet ref; // Binding to chart 'holder' in template belowexportlet id =`chart-${Math.random().toString(36)}`; // id for chart holder elementconstdispatch=createEventDispatcher();onMount(() => {try { chart =newChart(ref, { data, options });dispatch('load'); }catch (error) {console.error('Failed to initialize chart:', error); }});afterUpdate(() => {if (chart) {try {chart.model.setData(data);chart.model.setOptions(options);dispatch('update', { data, options }); }catch (error) {console.error('Failed to update chart:', error); } }});onDestroy(() => {if (chart) {dispatch('destroy');// Like core's Chart.destroy() but keeps div chart holder bound to ref as it's part of this templatechart.components.forEach(component=>component.destroy());chart.model.set({ destroyed:true }, { skipUpdate:true }); chart =undefined; }});
</script>
<div {id} bind:this={ref} class={chartHolderCssClass} {...$$restProps}></div>
Expected behavior
Expected generics="T extends BaseChartOptions" to be removed from line 1.
Expected there to be a line break before the first import statement.
Expected lang="ts" would be removed (my example uses lang="typescript" which is removed)
Expected formatting to use prettier
Information about your project:
Your browser and the version: Google Chrome 133
Your operating system: macOS 15.3.1
svelte-preprocess version: 6.0.3
Svelte 5.20.1 (compatibility mode), SvelteKit 2.17.2 (building with svelte-package)
The text was updated successfully, but these errors were encountered:
Describe the design limitations
lang="ts"
from generated files - onlylang="typescript"
. This differs from vitePreprocess as it expectslang="ts"
and is confusing for users who might need svelte-preprocess after starting with vitePreprocess.<script>
tag.generics
attribute removed from<script>
tags.To Reproduce
Expected behavior
generics="T extends BaseChartOptions"
to be removed from line 1.lang="ts"
would be removed (my example useslang="typescript"
which is removed)Information about your project:
Your browser and the version: Google Chrome 133
Your operating system: macOS 15.3.1
svelte-preprocess
version: 6.0.3Svelte 5.20.1 (compatibility mode), SvelteKit 2.17.2 (building with svelte-package)
The text was updated successfully, but these errors were encountered: