@storybook/svelte-vite 11.0.0-alpha.0 → 11.0.0-alpha.2

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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_703clj6tp7l from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_703clj6tp7l from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_703clj6tp7l from "node:module";
1
+ import CJS_COMPAT_NODE_URL_4e8xscswbvr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_4e8xscswbvr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_4e8xscswbvr from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_703clj6tp7l.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_703clj6tp7l.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_703clj6tp7l.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_4e8xscswbvr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_4e8xscswbvr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_4e8xscswbvr.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/preset.js CHANGED
@@ -1,15 +1,65 @@
1
- import CJS_COMPAT_NODE_URL_703clj6tp7l from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_703clj6tp7l from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_703clj6tp7l from "node:module";
1
+ import CJS_COMPAT_NODE_URL_4e8xscswbvr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_4e8xscswbvr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_4e8xscswbvr from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_703clj6tp7l.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_703clj6tp7l.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_703clj6tp7l.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_4e8xscswbvr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_4e8xscswbvr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_4e8xscswbvr.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
 
13
+ // src/preset.ts
14
+ import { assertSvelteCsfAddonNotInstalled } from "@storybook/svelte/internal/svelte-csf/addon-check";
15
+
16
+ // ../../../node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs
17
+ function exactRegex(str, flags) {
18
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
19
+ }
20
+ var escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
21
+ function escapeRegex(str) {
22
+ return str.replace(escapeRegexRE, "\\$&");
23
+ }
24
+
25
+ // src/plugins/svelte-csf.ts
26
+ import {
27
+ SVELTE_CSF_RUNTIME_STORIES_IMPORT_SOURCE,
28
+ svelteCsfRuntimeStoriesPath,
29
+ transformSvelteCsf
30
+ } from "@storybook/svelte/internal/svelte-csf/transform";
31
+ function svelteCsf() {
32
+ let sveltePlugin;
33
+ return {
34
+ name: "storybook:svelte-csf",
35
+ configResolved({ plugins }) {
36
+ sveltePlugin = plugins.find(
37
+ (plugin) => plugin.name === "vite-plugin-svelte:config" || plugin.name === "vite-plugin-svelte"
38
+ );
39
+ },
40
+ resolveId: {
41
+ // Run before Vite's resolver. When Vite resolves the import itself, its optimizer finds the
42
+ // runtime only while stories load, then pre-bundles it and reloads the page
43
+ order: "pre",
44
+ filter: { id: exactRegex(SVELTE_CSF_RUNTIME_STORIES_IMPORT_SOURCE) },
45
+ handler() {
46
+ return svelteCsfRuntimeStoriesPath;
47
+ }
48
+ },
49
+ transform: {
50
+ filter: { id: /\.stories\.svelte$/ },
51
+ handler(compiledCode, id2) {
52
+ return transformSvelteCsf({
53
+ filename: id2,
54
+ compiledCode,
55
+ compiledAST: this.parse(compiledCode),
56
+ preprocess: sveltePlugin?.api?.options?.preprocess
57
+ });
58
+ }
59
+ }
60
+ };
61
+ }
62
+
13
63
  // src/plugins/svelte-docgen.ts
14
64
  import { basename, relative } from "node:path";
15
65
  import MagicString from "magic-string";
@@ -329,22 +379,22 @@ function transformToSvelteDocParserDataItems(docgen) {
329
379
  });
330
380
  }
331
381
  async function svelteDocgen() {
332
- let cwd = process.cwd(), include = /\.svelte$/, exclude = /node_modules\/.*/, { createFilter } = await import("vite"), filter = createFilter(include, exclude), sourceFileCache = createDocgenCache();
382
+ let cwd = process.cwd(), include2 = /\.svelte$/, exclude2 = /node_modules\/.*/, { createFilter } = await import("vite"), filter = createFilter(include2, exclude2), sourceFileCache = createDocgenCache();
333
383
  return {
334
384
  name: "storybook:svelte-docgen-plugin",
335
385
  transform: {
336
- filter: { id: { include, exclude } },
337
- async handler(src, id) {
338
- if (id.startsWith("\0") || !filter(id))
386
+ filter: { id: { include: include2, exclude: exclude2 } },
387
+ async handler(src, id2) {
388
+ if (id2.startsWith("\0") || !filter(id2))
339
389
  return;
340
- let resource = relative(cwd, id), docgen = generateDocgen(resource, sourceFileCache), componentDoc = {
390
+ let resource = relative(cwd, id2), docgen = generateDocgen(resource, sourceFileCache), componentDoc = {
341
391
  data: transformToSvelteDocParserDataItems(docgen),
342
392
  name: basename(resource)
343
393
  }, s = new MagicString(src), outputAst = this.parse(src), componentName = getComponentName(outputAst);
344
394
  return s.append(`
345
395
  ;${componentName}.__docgen = ${JSON.stringify(componentDoc)}`), {
346
396
  code: s.toString(),
347
- map: s.generateMap({ hires: !0, source: id }).toString()
397
+ map: s.generateMap({ hires: !0, source: id2 }).toString()
348
398
  };
349
399
  }
350
400
  }
@@ -370,7 +420,7 @@ var core = {
370
420
  renderer: import.meta.resolve("@storybook/svelte/preset")
371
421
  }, viteFinal = async (config, options) => {
372
422
  let { plugins = [] } = config, framework = await options.presets.apply("framework");
373
- return (typeof framework == "string" ? {} : framework.options ?? {}).docgen !== !1 && plugins.push(await svelteDocgen()), await handleSvelteKit(plugins, options), {
423
+ return assertSvelteCsfAddonNotInstalled({ presetsList: options.presetsList, framework }), (typeof framework == "string" ? {} : framework.options ?? {}).docgen !== !1 && plugins.push(await svelteDocgen()), await handleSvelteKit(plugins, options), plugins.push(svelteCsf()), {
374
424
  ...config,
375
425
  plugins
376
426
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/svelte-vite",
3
- "version": "11.0.0-alpha.0",
3
+ "version": "11.0.0-alpha.2",
4
4
  "description": "Storybook for Svelte and Vite: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -52,13 +52,14 @@
52
52
  "!src/**/*"
53
53
  ],
54
54
  "dependencies": {
55
- "@storybook/builder-vite": "11.0.0-alpha.0",
56
- "@storybook/svelte": "11.0.0-alpha.0",
55
+ "@storybook/builder-vite": "11.0.0-alpha.2",
56
+ "@storybook/svelte": "11.0.0-alpha.2",
57
57
  "magic-string": "^1.1.0",
58
58
  "svelte2tsx": "^0.7.55",
59
- "typescript": "^4.9.4 || ^5.0.0"
59
+ "typescript": "^5.9.0 || ^6.0.0"
60
60
  },
61
61
  "devDependencies": {
62
+ "@rolldown/pluginutils": "^1.0.1",
62
63
  "@sveltejs/vite-plugin-svelte": "^6.2.0",
63
64
  "@types/node": "^22.19.1",
64
65
  "svelte": "^5.39.5",
@@ -68,9 +69,10 @@
68
69
  },
69
70
  "peerDependencies": {
70
71
  "@sveltejs/vite-plugin-svelte": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
71
- "storybook": "^11.0.0-alpha.0",
72
+ "storybook": "^11.0.0-alpha.2",
72
73
  "svelte": "^5.0.0",
73
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
74
+ "typescript": "^5.9.0 || ^6.0.0",
75
+ "vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
74
76
  },
75
77
  "publishConfig": {
76
78
  "access": "public"
@@ -1,5 +1,5 @@
1
1
  <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import { defineMeta } from '@storybook/svelte-vite';
3
3
  import Button from './Button.svelte';
4
4
  import { fn } from 'storybook/test';
5
5
 
@@ -1,5 +1,5 @@
1
1
  <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import { defineMeta } from '@storybook/svelte-vite';
3
3
  import Header from './Header.svelte';
4
4
  import { fn } from 'storybook/test';
5
5
 
@@ -1,5 +1,5 @@
1
1
  <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import { defineMeta } from '@storybook/svelte-vite';
3
3
  import { expect, userEvent, waitFor, within } from 'storybook/test';
4
4
  import Page from './Page.svelte';
5
5
  import { fn } from 'storybook/test';
@@ -1,5 +1,5 @@
1
1
  <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import { defineMeta } from '@storybook/svelte-vite';
3
3
  import Button from './Button.svelte';
4
4
  import { fn } from 'storybook/test';
5
5
 
@@ -1,5 +1,5 @@
1
1
  <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import { defineMeta } from '@storybook/svelte-vite';
3
3
  import Header from './Header.svelte';
4
4
  import { fn } from 'storybook/test';
5
5
 
@@ -1,5 +1,5 @@
1
1
  <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import { defineMeta } from '@storybook/svelte-vite';
3
3
  import { expect, userEvent, waitFor, within } from 'storybook/test';
4
4
  import Page from './Page.svelte';
5
5
  import { fn } from 'storybook/test';