diff --git a/package.json b/package.json index a06703e..bfda38a 100644 --- a/package.json +++ b/package.json @@ -65,10 +65,11 @@ "@storybook/node-logger": "^8.0.0", "@storybook/types": "^8.0.0", "dedent": "^1.5.3", + "es-toolkit": "^1.13.1", "esrap": "^1.2.2", "lodash-es": "^4.17.21", - "svelte-ast-print": "0.2.3", "magic-string": "^0.30.10", + "svelte-ast-print": "0.2.3", "zimmerframe": "^1.1.2" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eb788a9..86c65ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: dedent: specifier: ^1.5.3 version: 1.5.3 + es-toolkit: + specifier: ^1.13.1 + version: 1.13.1 esrap: specifier: ^1.2.2 version: 1.2.2 @@ -2752,6 +2755,9 @@ packages: resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} engines: {node: '>= 0.4'} + es-toolkit@1.13.1: + resolution: {integrity: sha512-tGsgoI8DfU0yrZI7w97aYVMZJU5sjpXC+HK8aYf3pmLQRNHMleiJN5ud21dA/IHKkTDFY5jcDMQcLs0A21LtAg==} + esbuild-register@3.5.0: resolution: {integrity: sha512-+4G/XmakeBAsvJuDugJvtyF1x+XJT4FMocynNpxrvEBViirpfUn2PgNpCHedfWhF4WokNsO/OvMKrmJOIJsI5A==} peerDependencies: @@ -9654,6 +9660,8 @@ snapshots: is-date-object: 1.0.5 is-symbol: 1.0.4 + es-toolkit@1.13.1: {} + esbuild-register@3.5.0(esbuild@0.21.5): dependencies: debug: 4.3.5 diff --git a/src/compiler/pre-transform/codemods/legacy-story.ts b/src/compiler/pre-transform/codemods/legacy-story.ts index 9e7c528..b3f78d3 100644 --- a/src/compiler/pre-transform/codemods/legacy-story.ts +++ b/src/compiler/pre-transform/codemods/legacy-story.ts @@ -7,6 +7,7 @@ import type { LetDirective, SnippetBlock, } from 'svelte/compiler'; +import { camelCase } from 'es-toolkit/string'; import { createASTAttribute, @@ -229,9 +230,7 @@ function templateToChildren(attribute: Attribute, filename?: string): Attribute createASTExpressionTag({ type: 'Identifier', name: - // NOTE: Transform name to be snakeCase or valid JavaScript syntax for naming variables - // TODO: change function name, because it does the same job? - storyNameToExportName( + camelCase( value[0].type === 'Text' ? value[0].data : ((value[0].expression as Literal).value as string)