@storybook/builder-vite 10.5.0-alpha.0 → 10.5.0-alpha.10

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_0l53r3mh1e8l from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0l53r3mh1e8l from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l from "node:module";
1
+ import CJS_COMPAT_NODE_URL_qr5xjt4odl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_qr5xjt4odl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_qr5xjt4odl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0l53r3mh1e8l.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0l53r3mh1e8l.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_qr5xjt4odl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_qr5xjt4odl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_qr5xjt4odl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -15,7 +15,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
15
  var __getOwnPropNames = Object.getOwnPropertyNames;
16
16
  var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
17
17
  var __commonJS = (cb, mod) => function() {
18
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ try {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ } catch (e) {
21
+ throw mod = 0, e;
22
+ }
19
23
  };
20
24
  var __copyProps = (to, from, except, desc) => {
21
25
  if (from && typeof from == "object" || typeof from == "function")
@@ -351,7 +355,6 @@ function genRawValue(value, indent = "", options = {}) {
351
355
  }
352
356
 
353
357
  // ../../../node_modules/pathe/dist/utils.mjs
354
- var normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
355
358
  var FILENAME_RE = /(^|[/\\])([^/\\]+?)(?=(\.[^.]+)?$)/;
356
359
  function filename(path2) {
357
360
  return path2.match(FILENAME_RE)?.[2];
package/dist/index.d.ts CHANGED
@@ -12,6 +12,13 @@ type StorybookConfigVite = {
12
12
  type BuilderOptions = {
13
13
  /** Path to `vite.config` file, relative to `process.cwd()`. */
14
14
  viteConfigPath?: string;
15
+ /**
16
+ * How Vite loads the config file. Equivalent to Vite's `--configLoader` CLI flag and the
17
+ * `configLoader` option of `loadConfigFromFile`.
18
+ *
19
+ * Requires Vite 6.1.0 or higher. On older Vite versions this option is silently ignored.
20
+ */
21
+ configLoader?: 'bundle' | 'runner' | 'native';
15
22
  };
16
23
 
17
24
  /** Recursively removes all plugins with the names given Resolves async plugins */
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0l53r3mh1e8l from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0l53r3mh1e8l from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l from "node:module";
1
+ import CJS_COMPAT_NODE_URL_qr5xjt4odl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_qr5xjt4odl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_qr5xjt4odl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0l53r3mh1e8l.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0l53r3mh1e8l.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_qr5xjt4odl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_qr5xjt4odl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_qr5xjt4odl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -24,7 +24,7 @@ import {
24
24
  normalize,
25
25
  relative,
26
26
  viteCorePlugins
27
- } from "./_node-chunks/chunk-SVSZCYZI.js";
27
+ } from "./_node-chunks/chunk-7UQ5JP7D.js";
28
28
 
29
29
  // ../../../node_modules/picocolors/picocolors.js
30
30
  var require_picocolors = __commonJS({
@@ -360,7 +360,6 @@ async function generateAddonSetupCode() {
360
360
 
361
361
  const channel = createBrowserChannel({ page: 'preview' });
362
362
  addons.setChannel(channel);
363
- window.__STORYBOOK_ADDONS_CHANNEL__ = channel;
364
363
 
365
364
  if (window.CONFIG_TYPE === 'DEVELOPMENT'){
366
365
  window.__STORYBOOK_SERVER_CHANNEL__ = channel;
@@ -1351,7 +1350,7 @@ function cache(name, options) {
1351
1350
  }
1352
1351
 
1353
1352
  // src/plugins/storybook-external-globals-plugin.ts
1354
- var escapeKeys = (key) => key.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), defaultImportRegExp = "import ([^*{}]+) from", replacementMap = /* @__PURE__ */ new Map([
1353
+ var escapeKeys = (key) => key.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), defaultImportRegExp = "import ([^*{}]+) from", emptyImportRegExp = /^import(?:\s*\{\s*\}\s*from)?\s*['"][^'"]+['"]\s*;?$/, replacementMap = /* @__PURE__ */ new Map([
1355
1354
  ["import ", "const "],
1356
1355
  ["import{", "const {"],
1357
1356
  ["* as ", ""],
@@ -1411,11 +1410,20 @@ function getDefaultImportReplacement(match) {
1411
1410
  let matched = match.match(defaultImportRegExp);
1412
1411
  return matched && `const {default: ${matched[1]}} =`;
1413
1412
  }
1413
+ function getEmptyImportReplacement(importStatement, globalReference) {
1414
+ if (!emptyImportRegExp.test(importStatement.trim()))
1415
+ return;
1416
+ let statementTerminator = importStatement.trimEnd().endsWith(";") ? ";" : "";
1417
+ return `void ${globalReference}${statementTerminator}`;
1418
+ }
1414
1419
  function getSearchRegExp(packageName) {
1415
1420
  let staticKeys = [...replacementMap.keys()].map(escapeKeys), packageNameLiteral = `.${packageName}.`, dynamicImportExpression = `await import\\(.${packageName}.\\)`, lookup = [defaultImportRegExp, ...staticKeys, packageNameLiteral, dynamicImportExpression];
1416
1421
  return new RegExp(`(${lookup.join("|")})`, "g");
1417
1422
  }
1418
1423
  function rewriteImport(importStatement, globs, packageName) {
1424
+ let emptyImportReplacement = getEmptyImportReplacement(importStatement, globs[packageName]);
1425
+ if (emptyImportReplacement)
1426
+ return emptyImportReplacement;
1419
1427
  let search = getSearchRegExp(packageName);
1420
1428
  return importStatement.replace(
1421
1429
  search,
@@ -1434,7 +1442,14 @@ var configEnvServe = {
1434
1442
  isSsrBuild: !1
1435
1443
  };
1436
1444
  async function commonConfig(options, _type) {
1437
- let configEnv = _type === "development" ? configEnvServe : configEnvBuild, { loadConfigFromFile, mergeConfig } = await import("vite"), { viteConfigPath } = await getBuilderOptions(options), projectRoot = resolve2(options.configDir, ".."), { config: { build: buildProperty = void 0, ...userConfig } = {} } = await loadConfigFromFile(configEnv, viteConfigPath, projectRoot) ?? {}, sbConfig = {
1445
+ let configEnv = _type === "development" ? configEnvServe : configEnvBuild, { loadConfigFromFile, mergeConfig } = await import("vite"), { viteConfigPath, configLoader } = await getBuilderOptions(options), projectRoot = resolve2(options.configDir, ".."), { config: { build: buildProperty = void 0, ...userConfig } = {} } = await loadConfigFromFile(
1446
+ configEnv,
1447
+ viteConfigPath,
1448
+ projectRoot,
1449
+ void 0,
1450
+ void 0,
1451
+ configLoader
1452
+ ) ?? {}, sbConfig = {
1438
1453
  configFile: !1,
1439
1454
  plugins: await pluginConfig(options),
1440
1455
  root: projectRoot,
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0l53r3mh1e8l from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0l53r3mh1e8l from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l from "node:module";
1
+ import CJS_COMPAT_NODE_URL_qr5xjt4odl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_qr5xjt4odl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_qr5xjt4odl from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0l53r3mh1e8l.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0l53r3mh1e8l.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_qr5xjt4odl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_qr5xjt4odl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_qr5xjt4odl.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,7 +12,7 @@ var require = CJS_COMPAT_NODE_MODULE_0l53r3mh1e8l.createRequire(import.meta.url)
12
12
  import {
13
13
  optimizeViteDeps,
14
14
  viteCorePlugins
15
- } from "./_node-chunks/chunk-SVSZCYZI.js";
15
+ } from "./_node-chunks/chunk-7UQ5JP7D.js";
16
16
  export {
17
17
  optimizeViteDeps,
18
18
  viteCorePlugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/builder-vite",
3
- "version": "10.5.0-alpha.0",
3
+ "version": "10.5.0-alpha.10",
4
4
  "description": "A Storybook builder to dev and build with Vite",
5
5
  "keywords": [
6
6
  "storybook",
@@ -47,7 +47,7 @@
47
47
  "!src/**/*"
48
48
  ],
49
49
  "dependencies": {
50
- "@storybook/csf-plugin": "10.5.0-alpha.0",
50
+ "@storybook/csf-plugin": "10.5.0-alpha.10",
51
51
  "ts-dedent": "^2.0.0"
52
52
  },
53
53
  "devDependencies": {
@@ -62,7 +62,7 @@
62
62
  "vite": "^7.0.4"
63
63
  },
64
64
  "peerDependencies": {
65
- "storybook": "^10.5.0-alpha.0",
65
+ "storybook": "^10.5.0-alpha.10",
66
66
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
67
67
  },
68
68
  "publishConfig": {