storybook-builder-rsbuild 0.0.5 → 0.0.6
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.
- package/dist/index.d.ts +10 -3
- package/dist/index.js +21 -5
- package/dist/index.mjs +22 -6
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as rsbuildReal from '@rsbuild/core';
|
2
2
|
import { RsbuildConfig } from '@rsbuild/core';
|
3
|
-
import { TypescriptOptions as TypescriptOptions$1, Builder, Options, NormalizedStoriesSpecifier } from '@storybook/types';
|
3
|
+
import { TypescriptOptions as TypescriptOptions$1, Builder, Options, BuilderResult as BuilderResult$1, NormalizedStoriesSpecifier } from '@storybook/types';
|
4
4
|
import { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check';
|
5
5
|
|
6
6
|
type RsbuildStats = {
|
@@ -26,6 +26,9 @@ type BuilderOptions = {
|
|
26
26
|
*/
|
27
27
|
rsbuildConfigPath?: string;
|
28
28
|
};
|
29
|
+
interface BuilderResult extends BuilderResult$1 {
|
30
|
+
stats?: Stats;
|
31
|
+
}
|
29
32
|
|
30
33
|
type RsbuildBuilderOptions = Options & {
|
31
34
|
typescriptOptions: TypescriptOptions;
|
@@ -42,6 +45,10 @@ declare function toImportFn(stories: NormalizedStoriesSpecifier[], relativeOffse
|
|
42
45
|
type ModuleExports = Record<string, any>;
|
43
46
|
declare function importPipeline(): (importFn: () => Promise<ModuleExports>) => Promise<ModuleExports>;
|
44
47
|
|
48
|
+
type StatsOrMultiStats = Parameters<rsbuildReal.OnAfterBuildFn>[0]['stats'];
|
49
|
+
type Stats = NonNullable<Exclude<StatsOrMultiStats, {
|
50
|
+
stats: unknown[];
|
51
|
+
}>>;
|
45
52
|
declare const printDuration: (startTime: [number, number]) => string;
|
46
53
|
type BuilderStartOptions = Parameters<RsbuildBuilder['start']>['0'];
|
47
54
|
declare const executor: {
|
@@ -51,8 +58,8 @@ declare const rsbuild: (_: unknown, options: RsbuildBuilderOptions) => Promise<r
|
|
51
58
|
declare const getConfig: RsbuildBuilder['getConfig'];
|
52
59
|
declare function bail(): Promise<void>;
|
53
60
|
declare const start: RsbuildBuilder['start'];
|
54
|
-
declare const build: ({ options }: BuilderStartOptions) => Promise<
|
61
|
+
declare const build: ({ options, }: BuilderStartOptions) => Promise<Stats>;
|
55
62
|
declare const corePresets: string[];
|
56
63
|
declare const previewMainTemplate: () => string;
|
57
64
|
|
58
|
-
export { BuilderOptions, RsbuildBuilder, RsbuildFinal, StorybookConfigRsbuild, TypescriptOptions, bail, build, corePresets, executor, getConfig, getVirtualModules, importPipeline, previewMainTemplate, printDuration, rsbuild, start, toImportFn, toImportFnPart };
|
65
|
+
export { BuilderOptions, BuilderResult, RsbuildBuilder, RsbuildFinal, Stats, StorybookConfigRsbuild, TypescriptOptions, bail, build, corePresets, executor, getConfig, getVirtualModules, importPipeline, previewMainTemplate, printDuration, rsbuild, start, toImportFn, toImportFnPart };
|
package/dist/index.js
CHANGED
@@ -394,6 +394,9 @@ var iframe_rsbuild_config_default = async (options) => {
|
|
394
394
|
progressBar: !quiet
|
395
395
|
},
|
396
396
|
source: {
|
397
|
+
// TODO: Rspack doesn't support virtual modules yet, use cache dir instead
|
398
|
+
// we needed to explicitly set the module in `node_modules` to be compiled
|
399
|
+
include: [/[\\/]node_modules[\\/].*[\\/]storybook-config-entry\.js/],
|
397
400
|
alias: {
|
398
401
|
...storybookPaths
|
399
402
|
},
|
@@ -567,6 +570,14 @@ var start = async ({
|
|
567
570
|
}
|
568
571
|
});
|
569
572
|
const rsbuildServer = await rsbuildBuild.createDevServer();
|
573
|
+
const waitFirstCompileDone = new Promise((resolve3) => {
|
574
|
+
rsbuildBuild.onDevCompileDone(({ stats: stats2, isFirstCompile }) => {
|
575
|
+
if (!isFirstCompile) {
|
576
|
+
return;
|
577
|
+
}
|
578
|
+
resolve3(stats2);
|
579
|
+
});
|
580
|
+
});
|
570
581
|
server = rsbuildServer;
|
571
582
|
if (!rsbuildBuild) {
|
572
583
|
throw new import_server_errors.WebpackInvocationError({
|
@@ -582,13 +593,10 @@ var start = async ({
|
|
582
593
|
);
|
583
594
|
router.use(rsbuildServer.middlewares);
|
584
595
|
storybookServer.on("upgrade", rsbuildServer.onHTTPUpgrade);
|
596
|
+
const stats = await waitFirstCompileDone;
|
585
597
|
return {
|
586
598
|
bail,
|
587
|
-
stats
|
588
|
-
toJson: () => {
|
589
|
-
throw new import_server_errors.NoStatsForViteDevError();
|
590
|
-
}
|
591
|
-
},
|
599
|
+
stats,
|
592
600
|
totalTime: process.hrtime(startTime)
|
593
601
|
};
|
594
602
|
};
|
@@ -602,6 +610,10 @@ var build = async ({ options }) => {
|
|
602
610
|
const previewResolvedDir = getAbsolutePath2("@storybook/preview");
|
603
611
|
const previewDirOrigin = (0, import_path4.join)(previewResolvedDir, "dist");
|
604
612
|
const previewDirTarget = (0, import_path4.join)(options.outputDir || "", `sb-preview`);
|
613
|
+
let stats;
|
614
|
+
rsbuildBuild.onAfterBuild((params) => {
|
615
|
+
stats = params.stats;
|
616
|
+
});
|
605
617
|
const previewFiles = import_fs_extra.default.copy(previewDirOrigin, previewDirTarget, {
|
606
618
|
filter: (src) => {
|
607
619
|
const { ext } = (0, import_path4.parse)(src);
|
@@ -611,7 +623,11 @@ var build = async ({ options }) => {
|
|
611
623
|
return true;
|
612
624
|
}
|
613
625
|
});
|
626
|
+
rsbuildBuild.onAfterBuild((params) => {
|
627
|
+
stats = params.stats;
|
628
|
+
});
|
614
629
|
await Promise.all([rsbuildBuild.build(), previewFiles]);
|
630
|
+
return stats;
|
615
631
|
};
|
616
632
|
var corePresets = [(0, import_path4.join)(__dirname, "./preview-preset.js")];
|
617
633
|
var previewMainTemplate = () => require.resolve("storybook-builder-rsbuild/templates/preview.ejs");
|
package/dist/index.mjs
CHANGED
@@ -4,7 +4,7 @@ import { loadConfig, mergeRsbuildConfig } from '@rsbuild/core';
|
|
4
4
|
import path, { join, resolve, parse, dirname } from 'path';
|
5
5
|
import express from 'express';
|
6
6
|
import fs2 from 'fs-extra';
|
7
|
-
import { WebpackInvocationError
|
7
|
+
import { WebpackInvocationError } from '@storybook/core-events/server-errors';
|
8
8
|
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
|
9
9
|
import { globalsNameReferenceMap } from '@storybook/preview/globals';
|
10
10
|
import { normalizeStories, loadPreviewOrConfigFile, handlebars, readTemplate, getBuilderOptions, stringifyProcessEnvs, isPreservingSymlinks } from '@storybook/core-common';
|
@@ -333,6 +333,9 @@ var iframe_rsbuild_config_default = async (options) => {
|
|
333
333
|
progressBar: !quiet
|
334
334
|
},
|
335
335
|
source: {
|
336
|
+
// TODO: Rspack doesn't support virtual modules yet, use cache dir instead
|
337
|
+
// we needed to explicitly set the module in `node_modules` to be compiled
|
338
|
+
include: [/[\\/]node_modules[\\/].*[\\/]storybook-config-entry\.js/],
|
336
339
|
alias: {
|
337
340
|
...storybookPaths
|
338
341
|
},
|
@@ -508,6 +511,14 @@ var start = async ({
|
|
508
511
|
}
|
509
512
|
});
|
510
513
|
const rsbuildServer = await rsbuildBuild.createDevServer();
|
514
|
+
const waitFirstCompileDone = new Promise((resolve3) => {
|
515
|
+
rsbuildBuild.onDevCompileDone(({ stats: stats2, isFirstCompile }) => {
|
516
|
+
if (!isFirstCompile) {
|
517
|
+
return;
|
518
|
+
}
|
519
|
+
resolve3(stats2);
|
520
|
+
});
|
521
|
+
});
|
511
522
|
server = rsbuildServer;
|
512
523
|
if (!rsbuildBuild) {
|
513
524
|
throw new WebpackInvocationError({
|
@@ -523,13 +534,10 @@ var start = async ({
|
|
523
534
|
);
|
524
535
|
router.use(rsbuildServer.middlewares);
|
525
536
|
storybookServer.on("upgrade", rsbuildServer.onHTTPUpgrade);
|
537
|
+
const stats = await waitFirstCompileDone;
|
526
538
|
return {
|
527
539
|
bail,
|
528
|
-
stats
|
529
|
-
toJson: () => {
|
530
|
-
throw new NoStatsForViteDevError();
|
531
|
-
}
|
532
|
-
},
|
540
|
+
stats,
|
533
541
|
totalTime: process.hrtime(startTime)
|
534
542
|
};
|
535
543
|
};
|
@@ -543,6 +551,10 @@ var build = async ({ options }) => {
|
|
543
551
|
const previewResolvedDir = getAbsolutePath2("@storybook/preview");
|
544
552
|
const previewDirOrigin = join(previewResolvedDir, "dist");
|
545
553
|
const previewDirTarget = join(options.outputDir || "", `sb-preview`);
|
554
|
+
let stats;
|
555
|
+
rsbuildBuild.onAfterBuild((params) => {
|
556
|
+
stats = params.stats;
|
557
|
+
});
|
546
558
|
const previewFiles = fs2.copy(previewDirOrigin, previewDirTarget, {
|
547
559
|
filter: (src) => {
|
548
560
|
const { ext } = parse(src);
|
@@ -552,7 +564,11 @@ var build = async ({ options }) => {
|
|
552
564
|
return true;
|
553
565
|
}
|
554
566
|
});
|
567
|
+
rsbuildBuild.onAfterBuild((params) => {
|
568
|
+
stats = params.stats;
|
569
|
+
});
|
555
570
|
await Promise.all([rsbuildBuild.build(), previewFiles]);
|
571
|
+
return stats;
|
556
572
|
};
|
557
573
|
var corePresets = [join(__dirname, "./preview-preset.js")];
|
558
574
|
var previewMainTemplate = () => __require.resolve("storybook-builder-rsbuild/templates/preview.ejs");
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "storybook-builder-rsbuild",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
4
4
|
"description": "Rsbuild builder for Storybook",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -56,7 +56,7 @@
|
|
56
56
|
"!src/**/*"
|
57
57
|
],
|
58
58
|
"dependencies": {
|
59
|
-
"@rsbuild/plugin-type-check": "0.
|
59
|
+
"@rsbuild/plugin-type-check": "0.7.9",
|
60
60
|
"@storybook/addon-docs": "^8.0.10",
|
61
61
|
"@storybook/channels": "^8.0.10",
|
62
62
|
"@storybook/client-logger": "^8.0.10",
|
@@ -86,7 +86,7 @@
|
|
86
86
|
"util-deprecate": "^1.0.2"
|
87
87
|
},
|
88
88
|
"devDependencies": {
|
89
|
-
"@rsbuild/core": "0.
|
89
|
+
"@rsbuild/core": "0.7.9",
|
90
90
|
"@types/express": "^4.17.21",
|
91
91
|
"@types/fs-extra": "^11.0.4",
|
92
92
|
"@types/node": "^18.0.0",
|
@@ -97,7 +97,7 @@
|
|
97
97
|
"typescript": "^5.3.2"
|
98
98
|
},
|
99
99
|
"peerDependencies": {
|
100
|
-
"@rsbuild/core": ">= 0.
|
100
|
+
"@rsbuild/core": ">= 0.7.0"
|
101
101
|
},
|
102
102
|
"peerDependenciesMeta": {
|
103
103
|
"typescript": {
|