From 7a8273cc3fe95a7d2d013f5b6f337edf00231d3e Mon Sep 17 00:00:00 2001 From: milahu Date: Wed, 30 Nov 2022 20:51:38 +0100 Subject: [PATCH 1/3] fix(isTypeScriptComponent): check all script tags (#933) --- packages/core/src/parsers/svelte/typescript/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/core/src/parsers/svelte/typescript/index.ts b/packages/core/src/parsers/svelte/typescript/index.ts index 12f6f0d24a..34294bd887 100644 --- a/packages/core/src/parsers/svelte/typescript/index.ts +++ b/packages/core/src/parsers/svelte/typescript/index.ts @@ -9,9 +9,14 @@ import type { SveltosisComponent } from '../types'; export function isTypeScriptComponent(string_: string) { const regex = createTagRegex('script', 'gi'); - const match = regex.exec(string_); - const { lang } = parseAttributes((match?.length && match[1]) || ''); - return lang === 'ts'; + let isTypeScript = false; + // match all + string_.replace(regex, (...match) => { + const { lang } = parseAttributes((match?.length && match[1]) || ''); + if (lang === 'ts') isTypeScript = true; + return ''; + }); + return isTypeScript; } /** Create a tag matching regexp. */ From d5cd6a8737682315b1077c742e73d17f16bba42a Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Fri, 2 Dec 2022 17:21:57 +0100 Subject: [PATCH 2/3] svelte parser: throw: not implemented: VariableDeclaration --- packages/core/src/parsers/svelte/module/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/core/src/parsers/svelte/module/index.ts b/packages/core/src/parsers/svelte/module/index.ts index e10b1b1e7b..87acb4a29b 100644 --- a/packages/core/src/parsers/svelte/module/index.ts +++ b/packages/core/src/parsers/svelte/module/index.ts @@ -27,6 +27,15 @@ function handleExportNamedDeclaration(json: SveltosisComponent, node: ExportName } } +function handleVariableDeclaration(_json: SveltosisComponent, _node: VariableDeclaration) { + throw new Error('not implemented: VariableDeclaration in svelte