@storybook/sveltekit 7.0.0-beta.2 β†’ 7.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,116 @@
1
- # Storybook for SvelteKit
1
+ # Storybook for SvelteKit <!-- omit in toc -->
2
+
3
+ Our goal is to help you use the tools you love together with Storybook. That’s why Storybook has zero-config support for SvelteKit with the `@storybook/sveltekit` package.
4
+
5
+ Check out our [Frameworks API](https://storybook.js.org/blog/framework-api/) announcement for what this all means for you and our continued efforts to make Storybook a seamless integration for any project.
6
+
7
+ ## Table of Contents <!-- omit in toc -->
8
+
9
+ - [Supported features](#supported-features)
10
+ - [Requirements](#requirements)
11
+ - [Getting Started](#getting-started)
12
+ - [In a project without Storybook](#in-a-project-without-storybook)
13
+ - [In a project with Storybook](#in-a-project-with-storybook)
14
+ - [Automatic migration](#automatic-migration)
15
+ - [Manual migration](#manual-migration)
16
+ - [Troubleshooting](#troubleshooting)
17
+ - [Error: `ERR! SyntaxError: Identifier '__esbuild_register_import_meta_url__' has already been declared` when starting Storybook](#error-err-syntaxerror-identifier-__esbuild_register_import_meta_url__-has-already-been-declared-when-starting-storybook)
18
+ - [Acknowledgements](#acknowledgements)
19
+
20
+ ## Supported features
21
+
22
+ All Svelte language features are supported out of the box, as Storybook uses the Svelte compiler underneath.
23
+ However SvelteKit has some [Kit-specific modules](https://kit.svelte.dev/docs/modules) that currently aren't supported. It's on our roadmap to support most of them soon:
24
+
25
+ | **Module** | **Status** |
26
+ | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
27
+ | [`$app/environment`](https://kit.svelte.dev/docs/modules#$app-environment) | πŸ”œ Coming in 7.0 |
28
+ | [`$app/forms`](https://kit.svelte.dev/docs/modules#$app-forms) | ⏳ Planned for 7.1 |
29
+ | [`$app/navigation`](https://kit.svelte.dev/docs/modules#$app-navigation) | ⏳ Planned for 7.1. With mocks so the Actions addon will display when the hooks are being called. |
30
+ | [`$app/paths`](https://kit.svelte.dev/docs/modules#$app-paths) | ⏳ Planned for 7.1 |
31
+ | [`$app/stores`](https://kit.svelte.dev/docs/modules#$app-stores) | πŸ”œ Coming in 7.0. Mocks are planned for 7.1 so you can set different store values per story. |
32
+ | [`$env/dynamic/private`](https://kit.svelte.dev/docs/modules#$env-dynamic-private) | β›” Not supported. They are meant to only be available server-side, and Storybook renders all components on the client. |
33
+ | [`$env/dynamic/public`](https://kit.svelte.dev/docs/modules#$env-dynamic-public) | πŸ”œ Coming in 7.0 |
34
+ | [`$env/static/private`](https://kit.svelte.dev/docs/modules#$env-static-private) | β›” Not supported. They are meant to only be available server-side, and Storybook renders all components on the client. |
35
+ | [`$env/static/public`](https://kit.svelte.dev/docs/modules#$env-static-public) | πŸ”œ Coming in 7.0 |
36
+ | [`$lib`](https://kit.svelte.dev/docs/modules#$lib) | πŸ”œ Coming in 7.0 |
37
+ | [`$service-worker`](https://kit.svelte.dev/docs/modules#$service-worker) | β›” Not supported. They are only meant to be used in service workers |
38
+ | [`@sveltejs/kit/*`](https://kit.svelte.dev/docs/modules#sveltejs-kit) | βœ… Supported |
39
+
40
+ This is just the beginning. We're close to adding basic support for many of the SvelteKit features. Longer term we're planning on making it an even better experience to [build](https://storybook.js.org/docs/7.0/react/writing-stories/introduction), [test](https://storybook.js.org/docs/7.0/react/writing-tests/introduction) and [document](https://storybook.js.org/docs/7.0/react/writing-docs/introduction) all the SvelteKit goodies like [pages](https://kit.svelte.dev/docs/routing), [forms](https://kit.svelte.dev/docs/form-actions) and [layouts](https://kit.svelte.dev/docs/routing#layout) in Storybook, while still integrating with all the addons and workflows you know and love.
41
+
42
+ ## Requirements
43
+
44
+ - [SvelteKit](https://kit.svelte.dev/) >= 1.0.0 (not including beta versions)
45
+ - [Storybook](https://storybook.js.org/) >= 7.x
46
+
47
+ ## Getting Started
48
+
49
+ ### In a project without Storybook
50
+
51
+ Run the following command in your SvelteKit project's root directory, and follow the prompts:
52
+
53
+ ```bash
54
+ npx storybook@next init
55
+ ```
56
+
57
+ [More on getting started with Storybook](https://storybook.js.org/docs/7.0/svelte/get-started/install)
58
+
59
+ ### In a project with Storybook
60
+
61
+ This framework is designed to work with Storybook 7. If you’re not already using v7, upgrade with this command:
62
+
63
+ ```bash
64
+ npx storybook@next upgrade --prerelease
65
+ ```
66
+
67
+ #### Automatic migration
68
+
69
+ When running the `upgrade` command above you should get a prompt asking you to migrate to `@storybook/sveltekit`, which should handle everything for you. In some cases it can't migrate for you, eg. if your existing Storybook setup is based on Webpack. In such cases, refer to the manual migration below.
70
+
71
+ Storybook 7.0 automatically loads your Vite config, and by extension your Svelte config. If you had a `svelteOptions` property in `.storybook/main.cjs` the automigration will have removed it, as it is no longer supported.
72
+
73
+ #### Manual migration
74
+
75
+ Install the framework:
76
+
77
+ ```bash
78
+ yarn add -D @storybook/sveltekit@next
79
+ ```
80
+
81
+ Update your `main.cjs` to change the framework property:
82
+
83
+ ```js
84
+ // .storybook/main.cjs
85
+ module.exports = {
86
+ ...
87
+ framework: '@storybook/sveltekit',
88
+ };
89
+ ```
90
+
91
+ Storybook 7.0 automatically loads your Vite config, and by extension your Svelte config. If you have a `svelteOptions` property in `.storybook/main.cjs` you need to remove that. See [Troubleshooting](#error-about-__esbuild_register_import_meta_url__-when-starting-storybook) below.
92
+
93
+ Remove any redundant dependencies, if you have them:
94
+
95
+ ```bash
96
+ yarn remove @storybook/svelte-vite
97
+ yarn remove @storybook/svelte-webpack5
98
+ yarn remove storybook-builder-vite
99
+ yarn remove @storybook/builder-vite
100
+ ```
101
+
102
+ ## Troubleshooting
103
+
104
+ ### Error: `ERR! SyntaxError: Identifier '__esbuild_register_import_meta_url__' has already been declared` when starting Storybook
105
+
106
+ > When starting Storybook after upgrading to v7.0, it breaks with the following error:
107
+ >
108
+ > ```
109
+ > ERR! SyntaxError: Identifier '__esbuild_register_import_meta_url__' has already been declared
110
+ > ```
111
+
112
+ You'll get this error when manually upgrading from 6.5 to 7.0. You need to remove the `svelteOptions` property in `.storybook/main.cjs`, as that is not supported by Storybook 7.0 + SvelteKit. The property is also not necessary anymore because the Vite and Svelte configurations are loaded automatically in Storybook 7.0.
113
+
114
+ ## Acknowledgements
115
+
116
+ Integrating with SvelteKit would not have been possible if it weren't for the fantastic efforts by the Svelte core team - especially [Ben McCann](https://twitter.com/benjaminmccann) - to make integrations with the wider ecosystem possible.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("@storybook/svelte-vite"),module.exports);
1
+ var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default"));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};module.exports=__toCommonJS(src_exports);__reExport(src_exports,require("@storybook/svelte-vite"),module.exports);
package/dist/preset.js CHANGED
@@ -1 +1 @@
1
- var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(t,o)=>{for(var e in o)n(t,e,{get:o[e],enumerable:!0})},v=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of b(o))!p.call(t,r)&&r!==e&&n(t,r,{get:()=>o[r],enumerable:!(i=a(o,r))||i.enumerable});return t};var f=t=>v(n({},"__esModule",{value:!0}),t);var c={};u(c,{core:()=>g,viteFinal:()=>y});module.exports=f(c);var l=require("@storybook/svelte-vite/preset"),s=require("@storybook/builder-vite"),g={builder:"@storybook/builder-vite",renderer:"@storybook/svelte"},y=async(t,o)=>{let e=await(0,l.viteFinal)(t,o),{plugins:i=[]}=e;return i=(0,s.withoutVitePlugins)(i,["vite-plugin-svelte-kit"]),{...e,plugins:i}};0&&(module.exports={core,viteFinal});
1
+ var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_preset=require("@storybook/svelte-vite/preset"),import_builder_vite=require("@storybook/builder-vite"),core={builder:"@storybook/builder-vite",renderer:"@storybook/svelte"},viteFinal=async(config,options)=>{let baseConfig=await(0,import_preset.viteFinal)(config,options),{plugins=[]}=baseConfig;return plugins=await(0,import_builder_vite.withoutVitePlugins)(plugins,["vite-plugin-svelte-kit","vite-plugin-sveltekit-setup","vite-plugin-sveltekit-compile"]),{...baseConfig,plugins}};0&&(module.exports={core,viteFinal});
package/dist/preset.mjs CHANGED
@@ -1 +1 @@
1
- import{viteFinal as svelteViteFinal}from"@storybook/svelte-vite/preset";import{withoutVitePlugins}from"@storybook/builder-vite";var core={builder:"@storybook/builder-vite",renderer:"@storybook/svelte"},viteFinal=async(config,options)=>{let baseConfig=await svelteViteFinal(config,options),{plugins=[]}=baseConfig;return plugins=withoutVitePlugins(plugins,["vite-plugin-svelte-kit"]),{...baseConfig,plugins}};export{core,viteFinal};
1
+ import{viteFinal as svelteViteFinal}from"@storybook/svelte-vite/preset";import{withoutVitePlugins}from"@storybook/builder-vite";var core={builder:"@storybook/builder-vite",renderer:"@storybook/svelte"},viteFinal=async(config,options)=>{let baseConfig=await svelteViteFinal(config,options),{plugins=[]}=baseConfig;return plugins=await withoutVitePlugins(plugins,["vite-plugin-svelte-kit","vite-plugin-sveltekit-setup","vite-plugin-sveltekit-compile"]),{...baseConfig,plugins}};export{core,viteFinal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/sveltekit",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.20",
4
4
  "description": "Storybook for SvelteKit",
5
5
  "keywords": [
6
6
  "storybook",
@@ -24,6 +24,7 @@
24
24
  "license": "MIT",
25
25
  "exports": {
26
26
  ".": {
27
+ "node": "./dist/index.js",
27
28
  "require": "./dist/index.js",
28
29
  "import": "./dist/index.mjs",
29
30
  "types": "./dist/index.d.ts"
@@ -41,7 +42,6 @@
41
42
  "files": [
42
43
  "dist/**/*",
43
44
  "template/**/*",
44
- "types/**/*",
45
45
  "README.md",
46
46
  "*.js",
47
47
  "*.d.ts"
@@ -51,20 +51,17 @@
51
51
  "prep": "../../../scripts/prepare/bundle.ts"
52
52
  },
53
53
  "dependencies": {
54
- "@storybook/builder-vite": "7.0.0-beta.2",
55
- "@storybook/svelte-vite": "7.0.0-beta.2"
54
+ "@storybook/builder-vite": "7.0.0-beta.20",
55
+ "@storybook/svelte": "7.0.0-beta.20",
56
+ "@storybook/svelte-vite": "7.0.0-beta.20"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@types/node": "^16.0.0",
59
- "typescript": "^4.9.3"
60
+ "typescript": "^4.9.3",
61
+ "vite": "^4.0.0"
60
62
  },
61
63
  "peerDependencies": {
62
- "@storybook/addon-svelte-csf": "^2.0.0"
63
- },
64
- "peerDependenciesMeta": {
65
- "@storybook/addon-svelte-csf": {
66
- "optional": true
67
- }
64
+ "vite": "^4.0.0"
68
65
  },
69
66
  "engines": {
70
67
  "node": "^14.18 || >=16"
@@ -79,5 +76,5 @@
79
76
  ],
80
77
  "platform": "node"
81
78
  },
82
- "gitHead": "66a0d588184add900c48d49f3a62743fa9cc5185"
79
+ "gitHead": "22701aedf564e467511887eb041f32ae0c96bcde"
83
80
  }
@@ -1,39 +0,0 @@
1
- import Button from './Button.svelte';
2
-
3
- // More on how to set up stories at: https://storybook.js.org/docs/7.0/svelte/writing-stories/introduction
4
- export default {
5
- title: 'Example/Button',
6
- component: Button,
7
- tags: ['docsPage'],
8
- argTypes: {
9
- backgroundColor: { control: 'color' },
10
- },
11
- };
12
-
13
- // More on writing stories with args: https://storybook.js.org/docs/7.0/svelte/writing-stories/args
14
- export const Primary = {
15
- args: {
16
- primary: true,
17
- label: 'Button',
18
- },
19
- };
20
-
21
- export const Secondary = {
22
- args: {
23
- label: 'Button',
24
- },
25
- };
26
-
27
- export const Large = {
28
- args: {
29
- size: 'large',
30
- label: 'Button',
31
- },
32
- };
33
-
34
- export const Small = {
35
- args: {
36
- size: 'small',
37
- label: 'Button',
38
- },
39
- };
@@ -1,34 +0,0 @@
1
- <script>
2
- import './button.css';
3
-
4
- /**
5
- * Is this the principal call to action on the page?
6
- */
7
- export let primary = false;
8
-
9
- /**
10
- * What background color to use
11
- */
12
- export let backgroundColor = undefined;
13
- /**
14
- * How large should the button be?
15
- */
16
- export let size = 'medium';
17
- /**
18
- * Button contents
19
- */
20
- export let label;
21
-
22
- $: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
23
-
24
- $: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
25
- </script>
26
-
27
- <button
28
- type="button"
29
- class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
30
- {style}
31
- on:click
32
- >
33
- {label}
34
- </button>