storybook-builder-rsbuild 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as rsbuildReal from '@rsbuild/core';
2
2
  import { RsbuildConfig } from '@rsbuild/core';
3
3
  import { TypescriptOptions as TypescriptOptions$1, Builder, Options, NormalizedStoriesSpecifier } from '@storybook/types';
4
- import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
4
+ import { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check';
5
5
 
6
6
  type RsbuildStats = {
7
7
  toJson: () => any;
@@ -11,9 +11,9 @@ type RsbuildStats = {
11
11
  */
12
12
  interface TypescriptOptions extends TypescriptOptions$1 {
13
13
  /**
14
- * Configures `fork-ts-checker-webpack-plugin`
14
+ * Configures `@rsbuild/plugin-type-check`, using `fork-ts-checker-webpack-plugin` under the hood.
15
15
  */
16
- checkOptions?: ConstructorParameters<typeof ForkTsCheckerWebpackPlugin>[0];
16
+ checkOptions?: PluginTypeCheckerOptions;
17
17
  }
18
18
  type RsbuildBuilder = Builder<RsbuildConfig, RsbuildStats>;
19
19
  type RsbuildFinal = (config: RsbuildConfig, options: Options) => RsbuildConfig | Promise<RsbuildConfig>;
@@ -27,6 +27,10 @@ type BuilderOptions = {
27
27
  rsbuildConfigPath?: string;
28
28
  };
29
29
 
30
+ type RsbuildBuilderOptions = Options & {
31
+ typescriptOptions: TypescriptOptions;
32
+ };
33
+
30
34
  declare const getVirtualModules: (options: Options) => Promise<{
31
35
  virtualModules: Record<string, string>;
32
36
  entries: string[];
@@ -43,7 +47,7 @@ type BuilderStartOptions = Parameters<RsbuildBuilder['start']>['0'];
43
47
  declare const executor: {
44
48
  get: (options: Options) => Promise<typeof rsbuildReal>;
45
49
  };
46
- declare const rsbuild: (_: unknown, options: Options) => Promise<rsbuildReal.RsbuildConfig>;
50
+ declare const rsbuild: (_: unknown, options: RsbuildBuilderOptions) => Promise<rsbuildReal.RsbuildConfig>;
47
51
  declare const getConfig: RsbuildBuilder['getConfig'];
48
52
  declare function bail(): Promise<void>;
49
53
  declare const start: RsbuildBuilder['start'];
package/dist/index.js CHANGED
@@ -162,7 +162,7 @@ var getVirtualModules = async (options) => {
162
162
  configDir: options.configDir,
163
163
  workingDir
164
164
  });
165
- const realPathRelativeToCwd = import_path.default.relative(workingDir, cwd);
165
+ const realPathRelativeToCwd = import_path.default.relative(workingDir, cwd).split(import_path.default.sep).join(import_path.default.posix.sep);
166
166
  const previewAnnotations = [
167
167
  ...(await options.presets.apply(
168
168
  "previewAnnotations",
@@ -272,7 +272,7 @@ function importPipeline() {
272
272
  // src/preview/iframe-rsbuild.config.ts
273
273
  var import_core = require("@rsbuild/core");
274
274
  var import_preset = require("@storybook/addon-docs/dist/preset");
275
- var import_fork_ts_checker_webpack_plugin = __toESM(require("fork-ts-checker-webpack-plugin"));
275
+ var import_plugin_type_check = require("@rsbuild/plugin-type-check");
276
276
  var getAbsolutePath = (input) => (0, import_path3.dirname)(require.resolve((0, import_path3.join)(input, "package.json")));
277
277
  var maybeGetAbsolutePath = (input) => {
278
278
  try {
@@ -414,6 +414,9 @@ var iframe_rsbuild_config_default = async (options) => {
414
414
  }
415
415
  }
416
416
  },
417
+ plugins: [shouldCheckTs ? (0, import_plugin_type_check.pluginTypeCheck)(tsCheckOptions) : null].filter(
418
+ Boolean
419
+ ),
417
420
  tools: {
418
421
  rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
419
422
  addRules({
@@ -457,8 +460,7 @@ var iframe_rsbuild_config_default = async (options) => {
457
460
  new rspack.ProvidePlugin({
458
461
  process: require.resolve("process/browser.js")
459
462
  }),
460
- new import_case_sensitive_paths_webpack_plugin.default(),
461
- shouldCheckTs ? new import_fork_ts_checker_webpack_plugin.default(tsCheckOptions) : null
463
+ new import_case_sensitive_paths_webpack_plugin.default()
462
464
  ].filter(Boolean)
463
465
  );
464
466
  return mergeConfig(config, appliedDocsWebpack);
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import { dedent } from 'ts-dedent';
12
12
  import fs from 'fs';
13
13
  import { webpackIncludeRegexp } from '@storybook/core-webpack';
14
14
  import { webpack } from '@storybook/addon-docs/dist/preset';
15
- import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
15
+ import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
16
16
 
17
17
  // ../../node_modules/.pnpm/pretty-hrtime@1.0.3/node_modules/pretty-hrtime/index.js
18
18
  var require_pretty_hrtime = __commonJS({
@@ -104,7 +104,7 @@ var getVirtualModules = async (options) => {
104
104
  configDir: options.configDir,
105
105
  workingDir
106
106
  });
107
- const realPathRelativeToCwd = path.relative(workingDir, cwd);
107
+ const realPathRelativeToCwd = path.relative(workingDir, cwd).split(path.sep).join(path.posix.sep);
108
108
  const previewAnnotations = [
109
109
  ...(await options.presets.apply(
110
110
  "previewAnnotations",
@@ -353,6 +353,9 @@ var iframe_rsbuild_config_default = async (options) => {
353
353
  }
354
354
  }
355
355
  },
356
+ plugins: [shouldCheckTs ? pluginTypeCheck(tsCheckOptions) : null].filter(
357
+ Boolean
358
+ ),
356
359
  tools: {
357
360
  rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
358
361
  addRules({
@@ -398,8 +401,7 @@ var iframe_rsbuild_config_default = async (options) => {
398
401
  new rspack.ProvidePlugin({
399
402
  process: __require.resolve("process/browser.js")
400
403
  }),
401
- new CaseSensitivePathsPlugin(),
402
- shouldCheckTs ? new ForkTsCheckerWebpackPlugin(tsCheckOptions) : null
404
+ new CaseSensitivePathsPlugin()
403
405
  ].filter(Boolean)
404
406
  );
405
407
  return mergeConfig(config, appliedDocsWebpack);
@@ -64,8 +64,16 @@ async function loader(source, map, meta) {
64
64
  `;module.exports.__namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
65
65
  );
66
66
  }
67
- const generatedMap = magicString.generateMap({ hires: true });
68
- return callback(null, magicString.toString(), generatedMap, meta);
67
+ return callback(
68
+ null,
69
+ magicString.toString(),
70
+ map ?? magicString.generateMap({
71
+ hires: true,
72
+ includeContent: true,
73
+ source: this.resourcePath
74
+ }),
75
+ meta
76
+ );
69
77
  } catch (err) {
70
78
  return callback(null, source, map, meta);
71
79
  }
@@ -31,8 +31,16 @@ async function loader(source, map, meta) {
31
31
  `;module.exports.__namedExportsOrder = ${JSON.stringify(namedExportsOrder)};`
32
32
  );
33
33
  }
34
- const generatedMap = magicString.generateMap({ hires: true });
35
- return callback(null, magicString.toString(), generatedMap, meta);
34
+ return callback(
35
+ null,
36
+ magicString.toString(),
37
+ map ?? magicString.generateMap({
38
+ hires: true,
39
+ includeContent: true,
40
+ source: this.resourcePath
41
+ }),
42
+ meta
43
+ );
36
44
  } catch (err) {
37
45
  return callback(null, source, map, meta);
38
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-builder-rsbuild",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Rsbuild builder for Storybook",
5
5
  "keywords": [
6
6
  "storybook",
@@ -56,6 +56,7 @@
56
56
  "!src/**/*"
57
57
  ],
58
58
  "dependencies": {
59
+ "@rsbuild/plugin-type-check": "0.6.15",
59
60
  "@storybook/addon-docs": "^8.0.10",
60
61
  "@storybook/channels": "^8.0.10",
61
62
  "@storybook/client-logger": "^8.0.10",
@@ -74,7 +75,6 @@
74
75
  "css-loader": "^6.7.1",
75
76
  "es-module-lexer": "^1.5.0",
76
77
  "express": "^4.17.3",
77
- "fork-ts-checker-webpack-plugin": "^8.0.0",
78
78
  "fs-extra": "^11.1.0",
79
79
  "magic-string": "^0.30.5",
80
80
  "path-browserify": "^1.0.1",