@storybook/builder-vite 11.0.0-alpha.6 → 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
|
|
@@ -2091,6 +2091,7 @@ async function transformIframeHtml(html, options) {
|
|
|
2091
2091
|
}
|
|
2092
2092
|
|
|
2093
2093
|
// src/utils/vite-features.ts
|
|
2094
|
+
import { basename as basename3 } from "node:path";
|
|
2094
2095
|
import { version } from "vite";
|
|
2095
2096
|
var shouldUseRolldownOptions = () => {
|
|
2096
2097
|
try {
|
|
@@ -2106,6 +2107,35 @@ function ensureRolldownOptions(config) {
|
|
|
2106
2107
|
let rolldown = config.build.rolldownOptions ??= {}, output = rolldown.output ??= {};
|
|
2107
2108
|
output.strictExecutionOrder = !0;
|
|
2108
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
|
+
}
|
|
2109
2139
|
|
|
2110
2140
|
// src/plugins/code-generator-plugin.ts
|
|
2111
2141
|
function codeGeneratorPlugin(options) {
|
|
@@ -2128,7 +2158,7 @@ function codeGeneratorPlugin(options) {
|
|
|
2128
2158
|
build[bundlerOptionsKey] = {
|
|
2129
2159
|
...build[bundlerOptionsKey],
|
|
2130
2160
|
input: iframePath
|
|
2131
|
-
}, ensureRolldownOptions(config);
|
|
2161
|
+
}, ensureRolldownOptions(config), options.features?.experimentalChunkedPreviewRuntime && applyChunkedPreviewRuntime(config);
|
|
2132
2162
|
}
|
|
2133
2163
|
},
|
|
2134
2164
|
configResolved(config) {
|
|
@@ -3505,21 +3535,29 @@ async function storybookExternalGlobalsPlugin(options) {
|
|
|
3505
3535
|
async handler(code, id) {
|
|
3506
3536
|
if (globalsList.every((glob) => !code.includes(glob)))
|
|
3507
3537
|
return;
|
|
3508
|
-
let [imports] = parse3(code), src = new MagicString(code);
|
|
3509
|
-
|
|
3538
|
+
let [imports] = parse3(code), src = new MagicString(code), didRewrite = !1;
|
|
3539
|
+
imports.forEach(({ n: path3, ss: startPosition, se: endPosition }) => {
|
|
3510
3540
|
let packageName = path3;
|
|
3511
3541
|
if (packageName && globalsList.includes(packageName)) {
|
|
3512
3542
|
let importStatement = src.slice(startPosition, endPosition), transformedImport = rewriteImport(importStatement, externals, packageName);
|
|
3513
|
-
src.update(startPosition, endPosition, transformedImport);
|
|
3543
|
+
src.update(startPosition, endPosition, transformedImport), didRewrite = !0;
|
|
3514
3544
|
}
|
|
3515
|
-
})
|
|
3516
|
-
|
|
3545
|
+
});
|
|
3546
|
+
let rewritten = src.toString();
|
|
3547
|
+
return {
|
|
3548
|
+
code: didRewrite ? ensurePreviewRuntimePrecedesGlobals(rewritten, id) : rewritten,
|
|
3517
3549
|
map: null
|
|
3518
3550
|
};
|
|
3519
3551
|
}
|
|
3520
3552
|
}
|
|
3521
3553
|
};
|
|
3522
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
|
+
}
|
|
3523
3561
|
function getDefaultImportReplacement(match) {
|
|
3524
3562
|
let matched = match.match(defaultImportRegExp);
|
|
3525
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": {
|