@storybook/builder-vite 11.0.0-alpha.8 → 11.0.0-beta.0

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_dm9z9i8b6a from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_dm9z9i8b6a from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_dm9z9i8b6a from "node:module";
1
+ import CJS_COMPAT_NODE_URL_3a6f3307qob from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_3a6f3307qob from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_3a6f3307qob from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_dm9z9i8b6a.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_dm9z9i8b6a.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_dm9z9i8b6a.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_3a6f3307qob.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_3a6f3307qob.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_3a6f3307qob.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1632,9 +1632,6 @@ var SB_VIRTUAL_FILES = {
1632
1632
  function getResolvedVirtualModuleId(virtualModuleId) {
1633
1633
  return `\0${virtualModuleId}`;
1634
1634
  }
1635
- function getOriginalVirtualModuleId(resolvedVirtualModuleId) {
1636
- return resolvedVirtualModuleId.slice(1);
1637
- }
1638
1635
 
1639
1636
  // src/plugins/storybook-project-annotations-plugin.ts
1640
1637
  var VIRTUAL_ID = "virtual:/@storybook/builder-vite/project-annotations.js", RESOLVED_VIRTUAL_ID = getResolvedVirtualModuleId(VIRTUAL_ID);
@@ -1843,7 +1840,7 @@ var builderRequire = createRequire(import.meta.url), corePath = dirname(builderR
1843
1840
 
1844
1841
  // src/vite-config.ts
1845
1842
  import { existsSync as existsSync4 } from "node:fs";
1846
- import { relative as relative4, resolve as resolve4 } from "node:path";
1843
+ import { relative as relative3, resolve as resolve4 } from "node:path";
1847
1844
  import {
1848
1845
  getBuilderOptions,
1849
1846
  getProjectRoot,
@@ -3410,59 +3407,51 @@ async function storybookEntryPlugin(options) {
3410
3407
  }
3411
3408
 
3412
3409
  // src/plugins/webpack-stats-plugin.ts
3413
- import { relative as relative3 } from "node:path";
3414
-
3415
- // ../../../node_modules/slash/index.js
3416
- function slash(path3) {
3417
- return path3.startsWith("\\\\?\\") ? path3 : path3.replace(/\\/g, "/");
3418
- }
3419
-
3420
- // src/plugins/webpack-stats-plugin.ts
3421
- function stripQueryParams(filePath) {
3422
- return filePath.split("?")[0];
3423
- }
3424
- function isUserCode(moduleName) {
3425
- return moduleName ? Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(moduleName)) ? !0 : !moduleName.startsWith("vite/") && !moduleName.startsWith("\0") && moduleName !== "react/jsx-runtime" : !1;
3410
+ var ROLLUP_VIRTUAL_PREFIX = "\0";
3411
+ function splitQuery(id) {
3412
+ let queryIndex = id.indexOf("?");
3413
+ return queryIndex === -1 ? [id, ""] : [id.slice(0, queryIndex), id.slice(queryIndex)];
3414
+ }
3415
+ function createNormalizer(workingDir, ids) {
3416
+ let filePaths = /* @__PURE__ */ new Set();
3417
+ for (let id of ids)
3418
+ id.startsWith(ROLLUP_VIRTUAL_PREFIX) || filePaths.add(splitQuery(id)[0]);
3419
+ return function(id) {
3420
+ let virtualPrefix = id.startsWith(ROLLUP_VIRTUAL_PREFIX) ? ROLLUP_VIRTUAL_PREFIX : "", unprefixed = id.slice(virtualPrefix.length);
3421
+ if (unprefixed.startsWith("virtual:"))
3422
+ return `/${unprefixed}`;
3423
+ let [path3, query] = splitQuery(unprefixed);
3424
+ return !isAbsolute(path3) || virtualPrefix && !filePaths.has(path3) ? id : `${virtualPrefix}./${relative(workingDir, path3)}${query}`;
3425
+ };
3426
3426
  }
3427
3427
  function pluginWebpackStats({ workingDir }) {
3428
- function normalize3(filename2) {
3429
- if (filename2.startsWith("virtual:"))
3430
- return `/${filename2}`;
3431
- if (Object.values(SB_VIRTUAL_FILES).includes(getOriginalVirtualModuleId(filename2)))
3432
- return `/${getOriginalVirtualModuleId(filename2)}`;
3433
- {
3434
- let relativePath = relative3(workingDir, stripQueryParams(filename2));
3435
- return `./${slash(relativePath)}`;
3436
- }
3437
- }
3438
- function createReasons(importers) {
3439
- return (importers || []).map((i) => ({ moduleName: normalize3(i) }));
3440
- }
3441
- function createStatsMapModule(filename2, importers) {
3442
- return {
3443
- id: filename2,
3444
- name: filename2,
3445
- reasons: createReasons(importers)
3446
- };
3428
+ let importersById = /* @__PURE__ */ new Map();
3429
+ function record(id, importer) {
3430
+ let importers = importersById.get(id);
3431
+ importers || (importers = /* @__PURE__ */ new Set(), importersById.set(id, importers)), importer !== void 0 && importers.add(importer);
3447
3432
  }
3448
- let statsMap = /* @__PURE__ */ new Map();
3449
3433
  return {
3450
3434
  name: "storybook:rollup-plugin-webpack-stats",
3451
3435
  // We want this to run after the vite build plugins (https://vitejs.dev/guide/api-plugin.html#plugin-ordering)
3452
3436
  enforce: "post",
3453
- moduleParsed: function(mod) {
3454
- isUserCode(mod.id) && mod.importedIds.concat(mod.dynamicallyImportedIds).filter((name) => isUserCode(name)).forEach((depIdUnsafe) => {
3455
- let depId = normalize3(depIdUnsafe);
3456
- if (!statsMap.has(depId)) {
3457
- statsMap.set(depId, createStatsMapModule(depId, [mod.id]));
3458
- return;
3459
- }
3460
- let m = statsMap.get(depId);
3461
- m && (m.reasons = (m.reasons ?? []).concat(createReasons([mod.id])).filter((r) => r.moduleName !== depId), statsMap.set(depId, m));
3462
- });
3437
+ moduleParsed(mod) {
3438
+ record(mod.id);
3439
+ for (let depId of mod.importedIds.concat(mod.dynamicallyImportedIds))
3440
+ record(depId, mod.id);
3463
3441
  },
3464
3442
  storybookGetStats() {
3465
- let stats = { modules: Array.from(statsMap.values()) };
3443
+ let normalize3 = createNormalizer(workingDir, importersById.keys()), importerNamesByName = /* @__PURE__ */ new Map();
3444
+ for (let [id, importers] of importersById) {
3445
+ let name = normalize3(id), importerNames = importerNamesByName.get(name) ?? /* @__PURE__ */ new Set();
3446
+ for (let importer of importers)
3447
+ importerNames.add(normalize3(importer));
3448
+ importerNames.delete(name), importerNamesByName.set(name, importerNames);
3449
+ }
3450
+ let stats = { modules: Array.from(importerNamesByName, ([name, importerNames]) => ({
3451
+ id: name,
3452
+ name,
3453
+ reasons: Array.from(importerNames, (moduleName) => ({ moduleName }))
3454
+ })) };
3466
3455
  return { ...stats, toJson: () => stats };
3467
3456
  }
3468
3457
  };
@@ -3620,7 +3609,7 @@ var configEnvServe = {
3620
3609
  ], warnOnce = once("warn");
3621
3610
  function reportUnloadedUserViteConfig(configDir, projectRoot) {
3622
3611
  let root = getProjectRoot();
3623
- if (relative4(root, projectRoot).startsWith(".."))
3612
+ if (relative3(root, projectRoot).startsWith(".."))
3624
3613
  return;
3625
3614
  let found = any(DEFAULT_VITE_CONFIG_FILES, {
3626
3615
  cwd: projectRoot,
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_dm9z9i8b6a from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_dm9z9i8b6a from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_dm9z9i8b6a from "node:module";
1
+ import CJS_COMPAT_NODE_URL_3a6f3307qob from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_3a6f3307qob from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_3a6f3307qob from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_dm9z9i8b6a.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_dm9z9i8b6a.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_dm9z9i8b6a.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_3a6f3307qob.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_3a6f3307qob.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_3a6f3307qob.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -15,7 +15,7 @@ import {
15
15
  bundlerOptionsKey,
16
16
  commonConfig,
17
17
  normalize
18
- } from "./_node-chunks/chunk-YTKSCPBY.js";
18
+ } from "./_node-chunks/chunk-T6VOWKXM.js";
19
19
 
20
20
  // ../../../node_modules/picocolors/picocolors.js
21
21
  var require_picocolors = __commonJS({
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_dm9z9i8b6a from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_dm9z9i8b6a from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_dm9z9i8b6a from "node:module";
1
+ import CJS_COMPAT_NODE_URL_3a6f3307qob from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_3a6f3307qob from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_3a6f3307qob from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_dm9z9i8b6a.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_dm9z9i8b6a.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_dm9z9i8b6a.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_3a6f3307qob.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_3a6f3307qob.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_3a6f3307qob.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -13,7 +13,7 @@ import {
13
13
  optimizeViteDeps,
14
14
  staticDirs,
15
15
  viteCorePlugins
16
- } from "./_node-chunks/chunk-YTKSCPBY.js";
16
+ } from "./_node-chunks/chunk-T6VOWKXM.js";
17
17
  export {
18
18
  optimizeViteDeps,
19
19
  staticDirs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/builder-vite",
3
- "version": "11.0.0-alpha.8",
3
+ "version": "11.0.0-beta.0",
4
4
  "description": "A Storybook builder to dev and build with Vite",
5
5
  "keywords": [
6
6
  "storybook",
@@ -57,11 +57,10 @@
57
57
  "knitwork": "^1.1.0",
58
58
  "magic-string": "^1.1.0",
59
59
  "pathe": "^1.1.2",
60
- "slash": "^5.0.0",
61
60
  "vite": "^7.0.4"
62
61
  },
63
62
  "peerDependencies": {
64
- "storybook": "^11.0.0-alpha.8",
63
+ "storybook": "^11.0.0-beta.0",
65
64
  "vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
66
65
  },
67
66
  "publishConfig": {