@storybook/builder-vite 11.0.0-beta.2 → 11.0.0-beta.3
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_k7rdtjz7yld from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k7rdtjz7yld from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k7rdtjz7yld from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k7rdtjz7yld.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k7rdtjz7yld.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k7rdtjz7yld.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -2351,11 +2351,17 @@ async function storybookEntryPlugin(options) {
|
|
|
2351
2351
|
}
|
|
2352
2352
|
|
|
2353
2353
|
// src/plugins/webpack-stats-plugin.ts
|
|
2354
|
+
import { statSync as statSync2 } from "node:fs";
|
|
2354
2355
|
var ROLLUP_VIRTUAL_PREFIX = "\0";
|
|
2355
2356
|
function splitQuery(id) {
|
|
2356
2357
|
let queryIndex = id.indexOf("?");
|
|
2357
2358
|
return queryIndex === -1 ? [id, ""] : [id.slice(0, queryIndex), id.slice(queryIndex)];
|
|
2358
2359
|
}
|
|
2360
|
+
var STYLESHEET_EXTENSIONS = "css|scss|sass|less|styl|stylus|pcss|postcss|sss", STYLESHEET_PATH = new RegExp(`\\.(${STYLESHEET_EXTENSIONS})$`), STYLESHEET_QUERY = new RegExp(`[?&]lang\\.(${STYLESHEET_EXTENSIONS})\\b`);
|
|
2361
|
+
function isStylesheet(id) {
|
|
2362
|
+
let [path3, query] = splitQuery(id);
|
|
2363
|
+
return STYLESHEET_PATH.test(path3) || STYLESHEET_QUERY.test(query);
|
|
2364
|
+
}
|
|
2359
2365
|
function createNormalizer(workingDir, ids) {
|
|
2360
2366
|
let filePaths = /* @__PURE__ */ new Set();
|
|
2361
2367
|
for (let id of ids)
|
|
@@ -2368,20 +2374,58 @@ function createNormalizer(workingDir, ids) {
|
|
|
2368
2374
|
return !isAbsolute(path3) || virtualPrefix && !filePaths.has(path3) ? id : `${virtualPrefix}./${relative(workingDir, path3)}${query}`;
|
|
2369
2375
|
};
|
|
2370
2376
|
}
|
|
2371
|
-
function pluginWebpackStats({
|
|
2372
|
-
|
|
2377
|
+
function pluginWebpackStats({
|
|
2378
|
+
workingDir,
|
|
2379
|
+
recordWatchFiles = !1
|
|
2380
|
+
}) {
|
|
2381
|
+
let importersById = /* @__PURE__ */ new Map(), watchFilesById = /* @__PURE__ */ new Map(), isFileById = /* @__PURE__ */ new Map();
|
|
2382
|
+
function interceptWatchFiles(plugin, hookName) {
|
|
2383
|
+
let hook = plugin[hookName];
|
|
2384
|
+
if (!hook)
|
|
2385
|
+
return;
|
|
2386
|
+
let handler = typeof hook == "function" ? hook : hook.handler, wrapped = function(...args) {
|
|
2387
|
+
let id = args[hookName === "load" ? 0 : 1], context = new Proxy(this, {
|
|
2388
|
+
get(target, key) {
|
|
2389
|
+
if (key === "addWatchFile")
|
|
2390
|
+
return (file) => {
|
|
2391
|
+
let files = watchFilesById.get(id) ?? /* @__PURE__ */ new Set();
|
|
2392
|
+
return files.add(file), watchFilesById.set(id, files), target.addWatchFile(file);
|
|
2393
|
+
};
|
|
2394
|
+
let value = Reflect.get(target, key, target);
|
|
2395
|
+
return typeof value == "function" ? value.bind(target) : value;
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
return Reflect.apply(handler, context, args);
|
|
2399
|
+
};
|
|
2400
|
+
try {
|
|
2401
|
+
plugin[hookName] = typeof hook == "function" ? wrapped : { ...hook, handler: wrapped };
|
|
2402
|
+
} catch {
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2373
2405
|
function record(id, importer) {
|
|
2374
|
-
let importers = importersById.get(id);
|
|
2375
|
-
|
|
2406
|
+
let importers = importersById.get(id) ?? /* @__PURE__ */ new Set();
|
|
2407
|
+
importersById.set(id, importers), importer !== void 0 && importers.add(importer);
|
|
2376
2408
|
}
|
|
2377
2409
|
return {
|
|
2378
2410
|
name: "storybook:rollup-plugin-webpack-stats",
|
|
2379
2411
|
// We want this to run after the vite build plugins (https://vitejs.dev/guide/api-plugin.html#plugin-ordering)
|
|
2380
2412
|
enforce: "post",
|
|
2413
|
+
configResolved(config) {
|
|
2414
|
+
if (!(!recordWatchFiles || config.command !== "build"))
|
|
2415
|
+
for (let plugin of config.plugins)
|
|
2416
|
+
interceptWatchFiles(plugin, "load"), interceptWatchFiles(plugin, "transform");
|
|
2417
|
+
},
|
|
2381
2418
|
moduleParsed(mod) {
|
|
2382
2419
|
record(mod.id);
|
|
2383
2420
|
for (let depId of mod.importedIds.concat(mod.dynamicallyImportedIds))
|
|
2384
2421
|
record(depId, mod.id);
|
|
2422
|
+
let keepsOnlyStylesheets = isStylesheet(mod.id);
|
|
2423
|
+
for (let file of watchFilesById.get(mod.id) ?? []) {
|
|
2424
|
+
if (keepsOnlyStylesheets && !isStylesheet(file))
|
|
2425
|
+
continue;
|
|
2426
|
+
let isFile = isFileById.get(file) ?? (isAbsolute(file) && statSync2(file, { throwIfNoEntry: !1 })?.isFile() === !0);
|
|
2427
|
+
isFileById.set(file, isFile), isFile && record(file, mod.id);
|
|
2428
|
+
}
|
|
2385
2429
|
},
|
|
2386
2430
|
storybookGetStats() {
|
|
2387
2431
|
let normalize3 = createNormalizer(workingDir, importersById.keys()), importerNamesByName = /* @__PURE__ */ new Map();
|
|
@@ -2619,7 +2663,10 @@ async function pluginConfig(options) {
|
|
|
2619
2663
|
// Entry plugin: virtual modules for stories, addon setup, and main app entry
|
|
2620
2664
|
...await storybookEntryPlugin(options),
|
|
2621
2665
|
// Builder-specific: webpack-compatible stats for turbosnap/chromatic
|
|
2622
|
-
pluginWebpackStats({
|
|
2666
|
+
pluginWebpackStats({
|
|
2667
|
+
workingDir: process.cwd(),
|
|
2668
|
+
recordWatchFiles: !!(options.webpackStatsJson || options.statsJson)
|
|
2669
|
+
})
|
|
2623
2670
|
];
|
|
2624
2671
|
}
|
|
2625
2672
|
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k7rdtjz7yld from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k7rdtjz7yld from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k7rdtjz7yld from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k7rdtjz7yld.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k7rdtjz7yld.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k7rdtjz7yld.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
commonConfig,
|
|
17
17
|
normalize,
|
|
18
18
|
require_dist
|
|
19
|
-
} from "./_node-chunks/chunk-
|
|
19
|
+
} from "./_node-chunks/chunk-U4FBKTBH.js";
|
|
20
20
|
|
|
21
21
|
// ../../../node_modules/picocolors/picocolors.js
|
|
22
22
|
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_k7rdtjz7yld from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k7rdtjz7yld from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k7rdtjz7yld from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k7rdtjz7yld.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k7rdtjz7yld.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k7rdtjz7yld.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-U4FBKTBH.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-beta.
|
|
3
|
+
"version": "11.0.0-beta.3",
|
|
4
4
|
"description": "A Storybook builder to dev and build with Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"vite": "^7.0.4"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"storybook": "^11.0.0-beta.
|
|
61
|
+
"storybook": "^11.0.0-beta.3",
|
|
62
62
|
"vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|