@storybook/builder-vite 11.0.0-alpha.7 → 11.0.0-alpha.8
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
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);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1261,7 +1261,7 @@ function storybookConfigPlugin(options) {
|
|
|
1261
1261
|
|
|
1262
1262
|
// src/plugins/storybook-optimize-deps-plugin.ts
|
|
1263
1263
|
import { loadPreviewOrConfigFile } from "storybook/internal/common";
|
|
1264
|
-
import {
|
|
1264
|
+
import { extractMockCalls, findMockRedirect } from "storybook/internal/mocking-utils";
|
|
1265
1265
|
|
|
1266
1266
|
// node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
1267
1267
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
@@ -1382,7 +1382,6 @@ function storybookOptimizeDepsPlugin(options) {
|
|
|
1382
1382
|
coreOptions: { disableTelemetry: !0 },
|
|
1383
1383
|
configDir: options.configDir
|
|
1384
1384
|
},
|
|
1385
|
-
babelParser,
|
|
1386
1385
|
projectRoot,
|
|
1387
1386
|
findMockRedirect
|
|
1388
1387
|
)
|
|
@@ -1735,7 +1734,6 @@ var ENTRY_PATH = "/vite-inject-mocker-entry.js", viteInjectMockerRuntime = (opti
|
|
|
1735
1734
|
// src/plugins/vite-mock/plugin.ts
|
|
1736
1735
|
import { readFileSync } from "node:fs";
|
|
1737
1736
|
import {
|
|
1738
|
-
babelParser as babelParser2,
|
|
1739
1737
|
extractMockCalls as extractMockCalls2,
|
|
1740
1738
|
findMockRedirect as findMockRedirect2,
|
|
1741
1739
|
getAutomockCode,
|
|
@@ -1763,13 +1761,13 @@ function viteMockPlugin(options) {
|
|
|
1763
1761
|
viteConfig = config;
|
|
1764
1762
|
},
|
|
1765
1763
|
buildStart() {
|
|
1766
|
-
mockCalls = extractMockCalls2(options,
|
|
1764
|
+
mockCalls = extractMockCalls2(options, viteConfig.root, findMockRedirect2);
|
|
1767
1765
|
},
|
|
1768
1766
|
configureServer(server) {
|
|
1769
1767
|
async function invalidateAffectedFiles(file) {
|
|
1770
1768
|
if (file === options.previewConfigPath || file.includes("__mocks__")) {
|
|
1771
1769
|
let oldMockCalls = mockCalls;
|
|
1772
|
-
mockCalls = extractMockCalls2(options,
|
|
1770
|
+
mockCalls = extractMockCalls2(options, viteConfig.root, findMockRedirect2);
|
|
1773
1771
|
let previewMod = server.moduleGraph.getModuleById(options.previewConfigPath);
|
|
1774
1772
|
previewMod && server.moduleGraph.invalidateModule(previewMod);
|
|
1775
1773
|
for (let call of mockCalls)
|
|
@@ -1807,7 +1805,7 @@ function viteMockPlugin(options) {
|
|
|
1807
1805
|
}
|
|
1808
1806
|
try {
|
|
1809
1807
|
if (!call.redirectPath) {
|
|
1810
|
-
let automockedCode = getAutomockCode(code, call.spy,
|
|
1808
|
+
let automockedCode = getAutomockCode(code, call.spy, id);
|
|
1811
1809
|
return {
|
|
1812
1810
|
code: automockedCode.toString(),
|
|
1813
1811
|
map: automockedCode.generateMap().toString()
|
|
@@ -1828,7 +1826,7 @@ function viteMockPlugin(options) {
|
|
|
1828
1826
|
handler(code, id) {
|
|
1829
1827
|
if (id === normalizedPreviewConfigPath)
|
|
1830
1828
|
try {
|
|
1831
|
-
return rewriteSbMockImportCalls(code);
|
|
1829
|
+
return rewriteSbMockImportCalls(code, id);
|
|
1832
1830
|
} catch (e) {
|
|
1833
1831
|
return logger.debug(`Could not transform sb.mock(import(...)) calls in ${id}: ${e}`), null;
|
|
1834
1832
|
}
|
|
@@ -1845,8 +1843,56 @@ var builderRequire = createRequire(import.meta.url), corePath = dirname(builderR
|
|
|
1845
1843
|
|
|
1846
1844
|
// src/vite-config.ts
|
|
1847
1845
|
import { existsSync as existsSync4 } from "node:fs";
|
|
1848
|
-
import { resolve as resolve4 } from "node:path";
|
|
1849
|
-
import {
|
|
1846
|
+
import { relative as relative4, resolve as resolve4 } from "node:path";
|
|
1847
|
+
import {
|
|
1848
|
+
getBuilderOptions,
|
|
1849
|
+
getProjectRoot,
|
|
1850
|
+
resolvePathInStorybookCache
|
|
1851
|
+
} from "storybook/internal/common";
|
|
1852
|
+
import { once } from "storybook/internal/node-logger";
|
|
1853
|
+
|
|
1854
|
+
// ../../../node_modules/empathic/find.mjs
|
|
1855
|
+
import { join as join3 } from "node:path";
|
|
1856
|
+
import { existsSync, statSync } from "node:fs";
|
|
1857
|
+
|
|
1858
|
+
// ../../../node_modules/empathic/walk.mjs
|
|
1859
|
+
import { dirname as dirname2 } from "node:path";
|
|
1860
|
+
|
|
1861
|
+
// ../../../node_modules/empathic/resolve.mjs
|
|
1862
|
+
import { isAbsolute as isAbsolute2, join as join2, resolve as resolve2 } from "node:path";
|
|
1863
|
+
function absolute(input, root) {
|
|
1864
|
+
return isAbsolute2(input) ? input : resolve2(root || ".", input);
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
// ../../../node_modules/empathic/walk.mjs
|
|
1868
|
+
function up(base, options) {
|
|
1869
|
+
let { last, cwd: cwd2 } = options || {}, tmp = absolute(base, cwd2), root = absolute(last || "/", cwd2), prev, arr = [];
|
|
1870
|
+
for (; prev !== root && (arr.push(tmp), tmp = dirname2(prev = tmp), tmp !== prev); )
|
|
1871
|
+
;
|
|
1872
|
+
return arr;
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// ../../../node_modules/empathic/find.mjs
|
|
1876
|
+
function up2(name, options) {
|
|
1877
|
+
let dir, tmp, start = options && options.cwd || "";
|
|
1878
|
+
for (dir of up(start, options))
|
|
1879
|
+
if (tmp = join3(dir, name), existsSync(tmp)) return tmp;
|
|
1880
|
+
}
|
|
1881
|
+
function any(names, options) {
|
|
1882
|
+
let dir, start = options && options.cwd || "", j = 0, len = names.length, tmp, stats, type = options?.type, kind = type ? type === "dir" ? 1 : -1 : 0;
|
|
1883
|
+
for (dir of up(start, options))
|
|
1884
|
+
for (j = 0; j < len; j++)
|
|
1885
|
+
if (tmp = join3(dir, names[j]), kind)
|
|
1886
|
+
try {
|
|
1887
|
+
if (stats = statSync(tmp), kind === 1 ? stats.isDirectory() : stats.isFile()) return tmp;
|
|
1888
|
+
} catch {
|
|
1889
|
+
}
|
|
1890
|
+
else if (existsSync(tmp))
|
|
1891
|
+
return tmp;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// src/vite-config.ts
|
|
1895
|
+
import { dedent as dedent4 } from "ts-dedent";
|
|
1850
1896
|
|
|
1851
1897
|
// src/plugins/code-generator-plugin.ts
|
|
1852
1898
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
@@ -3446,34 +3492,6 @@ function writable(path3) {
|
|
|
3446
3492
|
return ok(path3, constants.W_OK);
|
|
3447
3493
|
}
|
|
3448
3494
|
|
|
3449
|
-
// ../../../node_modules/empathic/find.mjs
|
|
3450
|
-
import { join as join4 } from "node:path";
|
|
3451
|
-
import { existsSync, statSync } from "node:fs";
|
|
3452
|
-
|
|
3453
|
-
// ../../../node_modules/empathic/walk.mjs
|
|
3454
|
-
import { dirname as dirname3 } from "node:path";
|
|
3455
|
-
|
|
3456
|
-
// ../../../node_modules/empathic/resolve.mjs
|
|
3457
|
-
import { isAbsolute as isAbsolute3, join as join3, resolve as resolve3 } from "node:path";
|
|
3458
|
-
function absolute(input, root) {
|
|
3459
|
-
return isAbsolute3(input) ? input : resolve3(root || ".", input);
|
|
3460
|
-
}
|
|
3461
|
-
|
|
3462
|
-
// ../../../node_modules/empathic/walk.mjs
|
|
3463
|
-
function up(base, options) {
|
|
3464
|
-
let { last, cwd: cwd2 } = options || {}, tmp = absolute(base, cwd2), root = absolute(last || "/", cwd2), prev, arr = [];
|
|
3465
|
-
for (; prev !== root && (arr.push(tmp), tmp = dirname3(prev = tmp), tmp !== prev); )
|
|
3466
|
-
;
|
|
3467
|
-
return arr;
|
|
3468
|
-
}
|
|
3469
|
-
|
|
3470
|
-
// ../../../node_modules/empathic/find.mjs
|
|
3471
|
-
function up2(name, options) {
|
|
3472
|
-
let dir, tmp, start = options && options.cwd || "";
|
|
3473
|
-
for (dir of up(start, options))
|
|
3474
|
-
if (tmp = join4(dir, name), existsSync(tmp)) return tmp;
|
|
3475
|
-
}
|
|
3476
|
-
|
|
3477
3495
|
// ../../../node_modules/empathic/package.mjs
|
|
3478
3496
|
function up3(options) {
|
|
3479
3497
|
return up2("package.json", options);
|
|
@@ -3592,17 +3610,48 @@ var configEnvServe = {
|
|
|
3592
3610
|
mode: "production",
|
|
3593
3611
|
command: "build",
|
|
3594
3612
|
isSsrBuild: !1
|
|
3595
|
-
}
|
|
3613
|
+
}, DEFAULT_VITE_CONFIG_FILES = [
|
|
3614
|
+
"vite.config.js",
|
|
3615
|
+
"vite.config.mjs",
|
|
3616
|
+
"vite.config.ts",
|
|
3617
|
+
"vite.config.cjs",
|
|
3618
|
+
"vite.config.mts",
|
|
3619
|
+
"vite.config.cts"
|
|
3620
|
+
], warnOnce = once("warn");
|
|
3621
|
+
function reportUnloadedUserViteConfig(configDir, projectRoot) {
|
|
3622
|
+
let root = getProjectRoot();
|
|
3623
|
+
if (relative4(root, projectRoot).startsWith(".."))
|
|
3624
|
+
return;
|
|
3625
|
+
let found = any(DEFAULT_VITE_CONFIG_FILES, {
|
|
3626
|
+
cwd: projectRoot,
|
|
3627
|
+
last: root
|
|
3628
|
+
});
|
|
3629
|
+
if (!found)
|
|
3630
|
+
return;
|
|
3631
|
+
let unloadedConfig = normalize(found);
|
|
3632
|
+
warnOnce(
|
|
3633
|
+
dedent4`
|
|
3634
|
+
No user Vite config was loaded: Storybook auto-discovers a Vite config file in "${projectRoot}" (the directory above your Storybook config dir "${configDir}"), and none was found there.
|
|
3635
|
+
A Vite config was found at "${unloadedConfig}", but it is outside of that directory and was not loaded.
|
|
3636
|
+
To load it, point the "viteConfigPath" builder option at it, e.g. core: { builder: { options: { viteConfigPath: '${unloadedConfig}' } } }.
|
|
3637
|
+
To keep it unloaded and silence this warning, set "viteConfigPath" to null, e.g. core: { builder: { options: { viteConfigPath: null } } }.
|
|
3638
|
+
See: https://storybook.js.org/docs/builders/vite#override-the-default-configuration
|
|
3639
|
+
`
|
|
3640
|
+
);
|
|
3641
|
+
}
|
|
3596
3642
|
async function loadUserViteConfig(options, type) {
|
|
3597
3643
|
let configEnv = type === "development" ? configEnvServe : configEnvBuild, { loadConfigFromFile } = await import("vite"), { viteConfigPath, configLoader } = await getBuilderOptions(options), projectRoot = resolve4(options.configDir, "..");
|
|
3598
|
-
|
|
3644
|
+
if (viteConfigPath === null)
|
|
3645
|
+
return {};
|
|
3646
|
+
let loaded = await loadConfigFromFile(
|
|
3599
3647
|
configEnv,
|
|
3600
3648
|
viteConfigPath,
|
|
3601
3649
|
projectRoot,
|
|
3602
3650
|
void 0,
|
|
3603
3651
|
void 0,
|
|
3604
3652
|
configLoader
|
|
3605
|
-
)
|
|
3653
|
+
);
|
|
3654
|
+
return !loaded && viteConfigPath === void 0 && reportUnloadedUserViteConfig(options.configDir, projectRoot), loaded?.config ?? {};
|
|
3606
3655
|
}
|
|
3607
3656
|
async function resolveVitePublicDir(options, type) {
|
|
3608
3657
|
let { publicDir } = await loadUserViteConfig(options, type);
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,13 @@ type StorybookConfigVite = {
|
|
|
11
11
|
viteFinal?: ViteFinal;
|
|
12
12
|
};
|
|
13
13
|
type BuilderOptions = {
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Path to `vite.config` file, relative to `process.cwd()`.
|
|
16
|
+
*
|
|
17
|
+
* Set to `null` to not load any Vite config file. Use this to keep a config file that
|
|
18
|
+
* Storybook's auto-discovery does not see unloaded, and to silence the matching warning.
|
|
19
|
+
*/
|
|
20
|
+
viteConfigPath?: string | null;
|
|
15
21
|
/**
|
|
16
22
|
* How Vite loads the config file. Equivalent to Vite's `--configLoader` CLI flag and the
|
|
17
23
|
* `configLoader` option of `loadConfigFromFile`.
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
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);
|
|
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-
|
|
18
|
+
} from "./_node-chunks/chunk-YTKSCPBY.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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
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);
|
|
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-
|
|
16
|
+
} from "./_node-chunks/chunk-YTKSCPBY.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.
|
|
3
|
+
"version": "11.0.0-alpha.8",
|
|
4
4
|
"description": "A Storybook builder to dev and build with Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"vite": "^7.0.4"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"storybook": "^11.0.0-alpha.
|
|
64
|
+
"storybook": "^11.0.0-alpha.8",
|
|
65
65
|
"vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|