storybookjs / addon-svelte-csf

[Incubation] CSF using Svelte components.
MIT License
103 stars 32 forks source link

Restore & add support for legacy syntax #186

Open xeho91 opened 3 months ago

xeho91 commented 3 months ago

Dependencies

Requires #181 to be merged first.

Objectives

Support for legacy components for backward compatibility:

  1. <Meta>

    • [x] codemod - <Meta> to defineMeta & insertion into <script context="module">
    • [x] tests
  2. <Story>

    • [x] tests
    • [x] codemods:
      • [x] transform let:args & let:context directives to inner children snippet block
      • [x] transform autodocs prop to tags={["autodocs"]}
      • [x] transform source by removing when is a shorthand or to parameters.docs.source.code
      • [x] transform template prop to children={<template identifier>}
  3. <Template>

    • [x] codemods - replace component with snippet block
    • [x] tests

Add addon options - StorybookAddonSvelteCsfOptions

Deprecation warnings, errors, messages

Update stories tests

Update indexer

TODO


📦 Published PR as canary version: 4.2.0--canary.186.b543003.0
:sparkles: Test out this PR locally via: ```bash npm install @storybook/addon-svelte-csf@4.2.0--canary.186.b543003.0 # or yarn add @storybook/addon-svelte-csf@4.2.0--canary.186.b543003.0 ```
xeho91 commented 2 months ago

@JReinhold

I got tests working. I'm encountering the issue with Chromatic CI which I can't figure out. I don't believe it's related to my changes.

What left is:

  1. updating documentation - Most importantly change wording where we declared 'removed' legacy API to 'deprecated'. Also, Highlighting usage of the option legacyTemplate.
  2. Logging deprecation warnings when the user uses legacy API, e.g. here, and perhaps in the indexer's parser, when he finds legacy AST nodes.

And maybe improve test (stories) for legacy API, because I got a feeling you don't want to provide examples for legacy API, right?

xeho91 commented 1 month ago

@JReinhold PR is ready for review. Phew, there were some issues so hard to spot, because of missing type support from svelte/compiler on their AST nodes (reference)

Two requests to put attention to:

  1. If you could find any spots where we can emit warnings about using legacy syntax, it'll be awesome!
  2. https://github.com/storybookjs/addon-svelte-csf/pull/186#discussion_r1685643713 This one is too hard for me to figure out at this moment. As discussed in private, is better left to user to fix very advanced cases on their own.