@storybook/builder-vite 11.0.0-alpha.5 → 11.0.0-alpha.7
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_w6355p49d7o from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_w6355p49d7o from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_w6355p49d7o from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_w6355p49d7o.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_w6355p49d7o.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_w6355p49d7o.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -2068,14 +2068,15 @@ async function generateAddonSetupCode() {
|
|
|
2068
2068
|
// src/transform-iframe-html.ts
|
|
2069
2069
|
import { normalizeStories } from "storybook/internal/common";
|
|
2070
2070
|
async function transformIframeHtml(html, options) {
|
|
2071
|
-
let { configType, features, presets } = options, build = await presets.apply("build"), frameworkOptions = await presets.apply("frameworkOptions"), headHtmlSnippet = await presets.apply("previewHead"), bodyHtmlSnippet = await presets.apply("previewBody"), logLevel = await presets.apply("logLevel", void 0), docsOptions = await presets.apply("docs"), tagsOptions = await presets.apply("tags"), coreOptions = await presets.apply("core"), stories = normalizeStories(await options.presets.apply("stories", [], options), {
|
|
2071
|
+
let { configType, features, presets } = options, build = await presets.apply("build"), frameworkOptions = await presets.apply("frameworkOptions"), headHtmlSnippet = await presets.apply("previewHead"), bodyHtmlSnippet = await presets.apply("previewBody"), logLevel = await presets.apply("logLevel", void 0), docsOptions = await presets.apply("docs"), tagsOptions = await presets.apply("tags"), security = await presets.apply("security"), coreOptions = await presets.apply("core"), stories = normalizeStories(await options.presets.apply("stories", [], options), {
|
|
2072
2072
|
configDir: options.configDir,
|
|
2073
2073
|
workingDir: process.cwd()
|
|
2074
2074
|
}).map((specifier) => ({
|
|
2075
2075
|
...specifier,
|
|
2076
2076
|
importPathMatcher: specifier.importPathMatcher.source
|
|
2077
2077
|
})), otherGlobals = {
|
|
2078
|
-
...build?.test?.disableBlocks ? { __STORYBOOK_BLOCKS_EMPTY_MODULE__: {} } : {}
|
|
2078
|
+
...build?.test?.disableBlocks ? { __STORYBOOK_BLOCKS_EMPTY_MODULE__: {} } : {},
|
|
2079
|
+
...security?.insecureIframeMessaging ? { INSECURE_IFRAME_MESSAGING: !0 } : {}
|
|
2079
2080
|
}, transformedHtml = html.replace("[CONFIG_TYPE HERE]", configType || "").replace("[LOGLEVEL HERE]", logLevel || "").replace("'[FRAMEWORK_OPTIONS HERE]'", JSON.stringify(frameworkOptions)).replace(
|
|
2080
2081
|
"('OTHER_GLOBALS HERE');",
|
|
2081
2082
|
Object.entries(otherGlobals).map(([k, v]) => `window["${k}"] = ${JSON.stringify(v)};`).join("")
|
|
@@ -2090,6 +2091,7 @@ async function transformIframeHtml(html, options) {
|
|
|
2090
2091
|
}
|
|
2091
2092
|
|
|
2092
2093
|
// src/utils/vite-features.ts
|
|
2094
|
+
import { basename as basename3 } from "node:path";
|
|
2093
2095
|
import { version } from "vite";
|
|
2094
2096
|
var shouldUseRolldownOptions = () => {
|
|
2095
2097
|
try {
|
|
@@ -2105,6 +2107,35 @@ function ensureRolldownOptions(config) {
|
|
|
2105
2107
|
let rolldown = config.build.rolldownOptions ??= {}, output = rolldown.output ??= {};
|
|
2106
2108
|
output.strictExecutionOrder = !0;
|
|
2107
2109
|
}
|
|
2110
|
+
var MAX_CHUNK_BYTES = 500 * 1024, PREVIEW_CHUNK = /[/\\]preview[/\\]_chunks[/\\]/;
|
|
2111
|
+
function eachOutput(config, useRolldown, fn) {
|
|
2112
|
+
config.build ??= {};
|
|
2113
|
+
let key = useRolldown ? "rolldownOptions" : "rollupOptions", build = config.build, options = build[key] ??= {};
|
|
2114
|
+
if (Array.isArray(options.output)) {
|
|
2115
|
+
options.output.length === 0 && options.output.push({});
|
|
2116
|
+
for (let output of options.output)
|
|
2117
|
+
fn(output);
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
options.output ??= {}, fn(options.output);
|
|
2121
|
+
}
|
|
2122
|
+
function applyChunkedPreviewRuntime(config, useRolldown = shouldUseRolldownOptions()) {
|
|
2123
|
+
eachOutput(config, useRolldown, (output) => {
|
|
2124
|
+
if (useRolldown) {
|
|
2125
|
+
output.strictExecutionOrder = !0;
|
|
2126
|
+
let splitting = output.codeSplitting, base = splitting && typeof splitting == "object" ? splitting : {};
|
|
2127
|
+
output.codeSplitting = {
|
|
2128
|
+
...base,
|
|
2129
|
+
groups: [...base.groups ?? [], { name: "sb", maxSize: MAX_CHUNK_BYTES }]
|
|
2130
|
+
};
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
2133
|
+
if (output.manualChunks && typeof output.manualChunks != "function")
|
|
2134
|
+
return;
|
|
2135
|
+
let previous = output.manualChunks;
|
|
2136
|
+
output.manualChunks = (id, meta) => PREVIEW_CHUNK.test(id) ? basename3(id, ".js") : previous?.(id, meta);
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2108
2139
|
|
|
2109
2140
|
// src/plugins/code-generator-plugin.ts
|
|
2110
2141
|
function codeGeneratorPlugin(options) {
|
|
@@ -2127,7 +2158,7 @@ function codeGeneratorPlugin(options) {
|
|
|
2127
2158
|
build[bundlerOptionsKey] = {
|
|
2128
2159
|
...build[bundlerOptionsKey],
|
|
2129
2160
|
input: iframePath
|
|
2130
|
-
}, ensureRolldownOptions(config);
|
|
2161
|
+
}, ensureRolldownOptions(config), options.features?.experimentalChunkedPreviewRuntime && applyChunkedPreviewRuntime(config);
|
|
2131
2162
|
}
|
|
2132
2163
|
},
|
|
2133
2164
|
configResolved(config) {
|
|
@@ -3504,21 +3535,29 @@ async function storybookExternalGlobalsPlugin(options) {
|
|
|
3504
3535
|
async handler(code, id) {
|
|
3505
3536
|
if (globalsList.every((glob) => !code.includes(glob)))
|
|
3506
3537
|
return;
|
|
3507
|
-
let [imports] = parse3(code), src = new MagicString(code);
|
|
3508
|
-
|
|
3538
|
+
let [imports] = parse3(code), src = new MagicString(code), didRewrite = !1;
|
|
3539
|
+
imports.forEach(({ n: path3, ss: startPosition, se: endPosition }) => {
|
|
3509
3540
|
let packageName = path3;
|
|
3510
3541
|
if (packageName && globalsList.includes(packageName)) {
|
|
3511
3542
|
let importStatement = src.slice(startPosition, endPosition), transformedImport = rewriteImport(importStatement, externals, packageName);
|
|
3512
|
-
src.update(startPosition, endPosition, transformedImport);
|
|
3543
|
+
src.update(startPosition, endPosition, transformedImport), didRewrite = !0;
|
|
3513
3544
|
}
|
|
3514
|
-
})
|
|
3515
|
-
|
|
3545
|
+
});
|
|
3546
|
+
let rewritten = src.toString();
|
|
3547
|
+
return {
|
|
3548
|
+
code: didRewrite ? ensurePreviewRuntimePrecedesGlobals(rewritten, id) : rewritten,
|
|
3516
3549
|
map: null
|
|
3517
3550
|
};
|
|
3518
3551
|
}
|
|
3519
3552
|
}
|
|
3520
3553
|
};
|
|
3521
3554
|
}
|
|
3555
|
+
var bundledPreviewRuntimePattern = /[/\\]dist[/\\]preview[/\\]/;
|
|
3556
|
+
function ensurePreviewRuntimePrecedesGlobals(code, id) {
|
|
3557
|
+
return bundledPreviewRuntimePattern.test(id.split("?")[0]) ? code : `import { setup as __sbInitializePreviewGlobals } from ${JSON.stringify(previewRuntimePath)};
|
|
3558
|
+
__sbInitializePreviewGlobals();
|
|
3559
|
+
${code}`;
|
|
3560
|
+
}
|
|
3522
3561
|
function getDefaultImportReplacement(match) {
|
|
3523
3562
|
let matched = match.match(defaultImportRegExp);
|
|
3524
3563
|
return matched && `const {default: ${matched[1]}} =`;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_w6355p49d7o from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_w6355p49d7o from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_w6355p49d7o from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_w6355p49d7o.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_w6355p49d7o.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_w6355p49d7o.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-2QMODMN7.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_w6355p49d7o from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_w6355p49d7o from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_w6355p49d7o from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_w6355p49d7o.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_w6355p49d7o.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_w6355p49d7o.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-2QMODMN7.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.7",
|
|
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
|
-
"ts-dedent": "^2.
|
|
50
|
+
"ts-dedent": "^2.2.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^22.19.1",
|
|
@@ -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.7",
|
|
65
65
|
"vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|