@modern-js/storybook-builder 2.41.0 → 2.42.0

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.
@@ -224,6 +224,12 @@ async function applyMdxLoader(config, options) {
224
224
  var _rules;
225
225
  (_rules = (_config_module = config.module).rules) !== null && _rules !== void 0 ? _rules : _config_module.rules = [];
226
226
  config.module.rules.push({
227
+ resourceQuery: /raw/,
228
+ type: "asset/source"
229
+ }, {
230
+ test: /\.md$/,
231
+ type: "asset/source"
232
+ }, {
227
233
  test: /(stories|story)\.mdx$/,
228
234
  use: [
229
235
  {
@@ -254,7 +260,7 @@ function applyExternals(builderConfig) {
254
260
  }
255
261
  }, {
256
262
  output: {
257
- externals: import_globals.globals
263
+ externals: import_globals.globalsNameReferenceMap
258
264
  }
259
265
  });
260
266
  builderConfig.output = config.output;
@@ -346,18 +352,16 @@ function addonAdapter(api, options) {
346
352
  const getOptions = (plugin) => Array.isArray(plugin) ? plugin[1] : null;
347
353
  const replaceOrInsert = (plugin, plugins) => {
348
354
  const pluginName = getPluginName(plugin);
349
- const append = [];
350
355
  for (let i = 0; i < plugins.length; i++) {
351
356
  if (getPluginName(plugins[i]) === pluginName) {
352
357
  if (getOptions(plugin)) {
353
358
  import_utils.logger.info(`Detected duplicated babel plugin or presets: ${pluginName}, overrides with the new one`);
354
359
  plugins[i] = plugin;
355
360
  }
356
- } else {
357
- append.push(plugin);
361
+ return;
358
362
  }
359
363
  }
360
- plugins.push(...append);
364
+ plugins.push(plugin);
361
365
  };
362
366
  const currentPlugins = config.plugins || [];
363
367
  const currentPresets = config.presets || [];
@@ -368,18 +372,12 @@ function addonAdapter(api, options) {
368
372
  replaceOrInsert(preset, currentPresets);
369
373
  }
370
374
  const finalConfig2 = {
371
- ...config,
372
375
  ...babelOptions,
373
376
  plugins: currentPlugins,
374
377
  presets: currentPresets
375
378
  };
376
- if (typeof userConfig === "function") {
377
- return userConfig(finalConfig2, utils);
378
- } else if (typeof userConfig === "object") {
379
- return {
380
- ...finalConfig2,
381
- ...userConfig
382
- };
379
+ if (userConfig) {
380
+ return (0, import_utils.applyOptionsChain)(finalConfig2, userConfig, utils);
383
381
  } else {
384
382
  return finalConfig2;
385
383
  }
@@ -48,7 +48,7 @@ const entries = async (_, options) => {
48
48
  if (options.configType === "DEVELOPMENT") {
49
49
  result.push(...[
50
50
  `${require.resolve("webpack-hot-middleware/client")}?reload=true&quiet=false&noInfo=${options.quiet}`,
51
- bundler === "rspack" ? require.resolve("@rspack/dev-client/react-refresh-entry") : null
51
+ bundler === "rspack" ? require.resolve("@rspack/plugin-react-refresh/react-refresh-entry") : null
52
52
  ].filter(Boolean));
53
53
  }
54
54
  result.push(getStoriesConfigPath(process.cwd()));
@@ -16,7 +16,7 @@ import {
16
16
  readTemplate,
17
17
  loadPreviewOrConfigFile
18
18
  } from "@storybook/core-common";
19
- import { globals } from "@storybook/preview/globals";
19
+ import { globalsNameReferenceMap } from "@storybook/preview/globals";
20
20
  import { unplugin as csfPlugin } from "@storybook/csf-plugin";
21
21
  import { minimatch } from "minimatch";
22
22
  import {
@@ -225,6 +225,14 @@ async function applyMdxLoader(config, options) {
225
225
  (_d = config.module) != null ? _d : config.module = {};
226
226
  (_f = (_e = config.module).rules) != null ? _f : _e.rules = [];
227
227
  config.module.rules.push(
228
+ {
229
+ resourceQuery: /raw/,
230
+ type: "asset/source"
231
+ },
232
+ {
233
+ test: /\.md$/,
234
+ type: "asset/source"
235
+ },
228
236
  {
229
237
  test: /(stories|story)\.mdx$/,
230
238
  use: [
@@ -260,7 +268,7 @@ function applyExternals(builderConfig) {
260
268
  },
261
269
  {
262
270
  output: {
263
- externals: globals
271
+ externals: globalsNameReferenceMap
264
272
  }
265
273
  }
266
274
  );
@@ -365,7 +373,6 @@ function addonAdapter(api, options) {
365
373
  const getOptions = (plugin) => Array.isArray(plugin) ? plugin[1] : null;
366
374
  const replaceOrInsert = (plugin, plugins) => {
367
375
  const pluginName = getPluginName(plugin);
368
- const append = [];
369
376
  for (let i = 0; i < plugins.length; i++) {
370
377
  if (getPluginName(plugins[i]) === pluginName) {
371
378
  if (getOptions(plugin)) {
@@ -374,11 +381,10 @@ function addonAdapter(api, options) {
374
381
  );
375
382
  plugins[i] = plugin;
376
383
  }
377
- } else {
378
- append.push(plugin);
384
+ return;
379
385
  }
380
386
  }
381
- plugins.push(...append);
387
+ plugins.push(plugin);
382
388
  };
383
389
  const currentPlugins = config.plugins || [];
384
390
  const currentPresets = config.presets || [];
@@ -389,15 +395,12 @@ function addonAdapter(api, options) {
389
395
  replaceOrInsert(preset, currentPresets);
390
396
  }
391
397
  const finalConfig2 = {
392
- ...config,
393
398
  ...babelOptions,
394
399
  plugins: currentPlugins,
395
400
  presets: currentPresets
396
401
  };
397
- if (typeof userConfig === "function") {
398
- return userConfig(finalConfig2, utils);
399
- } else if (typeof userConfig === "object") {
400
- return { ...finalConfig2, ...userConfig };
402
+ if (userConfig) {
403
+ return applyOptionsChain(finalConfig2, userConfig, utils);
401
404
  } else {
402
405
  return finalConfig2;
403
406
  }
@@ -14,7 +14,7 @@ const entries = async (_, options) => {
14
14
  result.push(
15
15
  ...[
16
16
  `${require.resolve("webpack-hot-middleware/client")}?reload=true&quiet=false&noInfo=${options.quiet}`,
17
- bundler === "rspack" ? require.resolve("@rspack/dev-client/react-refresh-entry") : null
17
+ bundler === "rspack" ? require.resolve("@rspack/plugin-react-refresh/react-refresh-entry") : null
18
18
  ].filter(Boolean)
19
19
  );
20
20
  }
@@ -2,4 +2,4 @@
2
2
  import type { Plugin } from '@modern-js/runtime';
3
3
  import type { IConfig } from '../type';
4
4
  export declare const WrapProviders: (storyFn: any, config: IConfig) => JSX.Element;
5
- export declare const resolvePlugins: (runtime: IConfig['modernConfigRuntime']) => Plugin[];
5
+ export declare const resolvePlugins: (runtime: IConfig['modernConfigRuntime']) => Plugin[];
@@ -1 +1 @@
1
- export declare const ADDON_ID = "storybook/modern-runtime";
1
+ export declare const ADDON_ID = "storybook/modern-runtime";
@@ -1,2 +1,2 @@
1
1
  declare const _default: {};
2
- export default _default;
2
+ export default _default;
@@ -1 +1 @@
1
- export declare const decorators: import("@storybook/types").DecoratorFunction[];
1
+ export declare const decorators: import("@storybook/types").DecoratorFunction[];
@@ -1,4 +1,4 @@
1
1
  export interface IConfig {
2
- modernConfigRuntime: any;
3
- modernConfigDesignToken: any;
4
- }
2
+ modernConfigRuntime: any;
3
+ modernConfigDesignToken: any;
4
+ }
@@ -1,2 +1,2 @@
1
1
  import { DecoratorFunction } from '@storybook/types';
2
- export declare const withPluginRuntime: DecoratorFunction;
2
+ export declare const withPluginRuntime: DecoratorFunction;
@@ -4,4 +4,4 @@ export type StorybookBuilder = RawStorybookBuilder<BuilderOptions, Stats>;
4
4
  export declare const getConfig: StorybookBuilder['getConfig'];
5
5
  export declare const build: StorybookBuilder['build'];
6
6
  export declare const start: StorybookBuilder['start'];
7
- export declare const bail: () => Promise<void>;
7
+ export declare const bail: () => Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import type { Options } from '@storybook/types';
2
2
  import type { Compiler } from '@modern-js/builder-shared/webpack-dev-middleware';
3
3
  import type { BuilderOptions } from './types';
4
- export declare function getCompiler(cwd: string, builderOptions: BuilderOptions, options: Options): Promise<Compiler>;
4
+ export declare function getCompiler(cwd: string, builderOptions: BuilderOptions, options: Options): Promise<Compiler>;
@@ -11,4 +11,4 @@
11
11
  import type { NodePath } from 'ast-types/lib/node-path';
12
12
  import type { Importer } from 'react-docgen/dist/parse';
13
13
  import type Documentation from 'react-docgen/dist/Documentation';
14
- export default function actualNameHandler(documentation: Documentation, path: NodePath, importer: Importer): void;
14
+ export default function actualNameHandler(documentation: Documentation, path: NodePath, importer: Importer): void;
@@ -2,8 +2,8 @@ import type { Options } from '@storybook/types';
2
2
  import { RspackConfig } from '@modern-js/builder-rspack-provider';
3
3
  import { WebpackChain } from '@modern-js/builder-webpack-provider';
4
4
  export type DocgenOptions = {
5
- reactDocgen?: 'react-docgen' | 'react-docgen-typescript' | false;
6
- reactDocgenTypescriptOptions?: any;
5
+ reactDocgen?: 'react-docgen' | 'react-docgen-typescript' | false;
6
+ reactDocgenTypescriptOptions?: any;
7
7
  };
8
8
  export declare function applyDocgenWebpack(chain: WebpackChain, options: Options): Promise<void>;
9
- export declare function applyDocgenRspack(config: RspackConfig, options: Options): Promise<void>;
9
+ export declare function applyDocgenRspack(config: RspackConfig, options: Options): Promise<void>;
@@ -1,2 +1,2 @@
1
1
  declare function docLoader(this: any, source: string, map: string, data: any): Promise<void>;
2
- export default docLoader;
2
+ export default docLoader;
@@ -1,10 +1,6 @@
1
- declare const _default: ({
2
- source,
3
- map,
4
- filename
5
- }: {
6
- source: string;
7
- map: string;
8
- filename: string;
1
+ declare const _default: ({ source, map, filename, }: {
2
+ source: string;
3
+ map: string;
4
+ filename: string;
9
5
  }) => string[] | null;
10
- export default _default;
6
+ export default _default;
@@ -1,3 +1,3 @@
1
1
  export { start, build, bail, getConfig } from './build';
2
2
  export * from './types';
3
- export declare const corePresets: string[];
3
+ export declare const corePresets: string[];
@@ -3,4 +3,4 @@ import type { Options } from '@storybook/types';
3
3
  import type { BuilderPluginAPI as WebpackAPI } from '@modern-js/builder-webpack-provider';
4
4
  import type { BuilderPluginAPI as RspackAPI } from '@modern-js/builder-rspack-provider';
5
5
  export declare function finalize(): Promise<void>;
6
- export declare const pluginStorybook: (cwd: string, options: Options) => BuilderPlugin<WebpackAPI | RspackAPI>;
6
+ export declare const pluginStorybook: (cwd: string, options: Options) => BuilderPlugin<WebpackAPI | RspackAPI>;
@@ -2,4 +2,4 @@ import type { Options } from '@storybook/types';
2
2
  import { BuilderConfig } from './types';
3
3
  export declare const previewMainTemplate: () => string;
4
4
  export declare const entries: (_: unknown, options: Options) => Promise<string[]>;
5
- export declare const modern: (builderConfig: BuilderConfig, options: Options) => BuilderConfig;
5
+ export declare const modern: (builderConfig: BuilderConfig, options: Options) => BuilderConfig;
@@ -5,11 +5,11 @@ export type BundlerType = 'webpack' | 'rspack';
5
5
  export type { WebpackBuilderConfig, RspackBuilderConfig };
6
6
  export type AllBuilderConfig = WebpackBuilderConfig | RspackBuilderConfig;
7
7
  export type BuilderOptions = {
8
- bundler?: BundlerType;
9
- builderConfig?: AllBuilderConfig;
10
- configPath?: string;
8
+ bundler?: BundlerType;
9
+ builderConfig?: AllBuilderConfig;
10
+ configPath?: string;
11
11
  };
12
12
  export type BuilderConfig = AllBuilderConfig & {
13
- builderPlugins?: BuilderPlugin[];
13
+ builderPlugins?: BuilderPlugin[];
14
14
  };
15
- export { defineConfig } from '@modern-js/builder/cli';
15
+ export { defineConfig } from '@modern-js/builder/cli';
@@ -12,4 +12,4 @@ export declare function getAbsolutePath<I extends string>(input: I): I;
12
12
  export declare function maybeGetAbsolutePath<I extends string>(input: I): I | false;
13
13
  export declare function runWithErrorMsg<T>(op: () => Promise<T>, msg: string): Promise<T | undefined>;
14
14
  export declare function isDev(): boolean;
15
- export declare function getConfigFileName(): string;
15
+ export declare function getConfigFileName(): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/storybook-builder",
3
- "version": "2.41.0",
3
+ "version": "2.42.0",
4
4
  "description": "modern.js support for storybook",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,18 +51,18 @@
51
51
  },
52
52
  "license": "MIT",
53
53
  "dependencies": {
54
- "@rspack/dev-client": "0.4.0",
55
- "@storybook/components": "^7.5.1",
56
- "@storybook/core-common": "^7.5.1",
57
- "@storybook/csf-plugin": "^7.5.1",
58
- "@storybook/global": "^5.0.0",
59
- "@storybook/mdx1-csf": "^1.0.0",
60
- "@storybook/mdx2-csf": "^1.1.0",
61
- "@storybook/preview": "^7.5.1",
62
- "@storybook/preview-api": "^7.5.1",
54
+ "@rspack/plugin-react-refresh": "0.4.2",
55
+ "@storybook/components": "~7.6.1",
56
+ "@storybook/core-common": "~7.6.1",
57
+ "@storybook/csf-plugin": "~7.6.1",
58
+ "@storybook/global": "~5.0.0",
59
+ "@storybook/mdx1-csf": "~1.0.0",
60
+ "@storybook/mdx2-csf": "~1.1.0",
61
+ "@storybook/preview": "~7.6.1",
62
+ "@storybook/preview-api": "~7.6.1",
63
63
  "@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0",
64
- "@storybook/router": "^7.5.1",
65
- "@storybook/theming": "^7.5.1",
64
+ "@storybook/router": "~7.6.1",
65
+ "@storybook/theming": "~7.6.1",
66
66
  "ast-types": "^0.14.2",
67
67
  "minimatch": "^9.0.3",
68
68
  "react-docgen": "6.0.0-alpha.3",
@@ -71,26 +71,26 @@
71
71
  "serve-static": "^1.14.1",
72
72
  "tinypool": "^0.8.0",
73
73
  "webpack-hot-middleware": "^2.25.4",
74
- "@modern-js/builder": "2.41.0",
75
- "@modern-js/runtime": "2.41.0",
76
- "@modern-js/builder-shared": "2.41.0",
77
- "@modern-js/core": "2.41.0",
78
- "@modern-js/utils": "2.41.0"
74
+ "@modern-js/builder": "2.42.0",
75
+ "@modern-js/builder-shared": "2.42.0",
76
+ "@modern-js/utils": "2.42.0",
77
+ "@modern-js/runtime": "2.42.0",
78
+ "@modern-js/core": "2.42.0"
79
79
  },
80
80
  "devDependencies": {
81
- "@storybook/types": "^7.5.1",
81
+ "@storybook/types": "~7.6.1",
82
82
  "@types/babel__core": "^7.20.1",
83
83
  "@types/serve-static": "^1.13.10",
84
84
  "@types/webpack-hot-middleware": "^2.25.6",
85
85
  "typescript": "^5.2.2",
86
- "@modern-js/builder-rspack-provider": "2.41.0",
87
- "@modern-js/core": "2.41.0",
88
- "@modern-js/builder-webpack-provider": "2.41.0",
89
- "@scripts/build": "2.41.0"
86
+ "@modern-js/builder-webpack-provider": "2.42.0",
87
+ "@modern-js/builder-rspack-provider": "2.42.0",
88
+ "@modern-js/core": "2.42.0",
89
+ "@scripts/build": "2.42.0"
90
90
  },
91
91
  "peerDependencies": {
92
- "@modern-js/builder-webpack-provider": "^2.41.0",
93
- "@modern-js/builder-rspack-provider": "^2.41.0"
92
+ "@modern-js/builder-webpack-provider": "^2.42.0",
93
+ "@modern-js/builder-rspack-provider": "^2.42.0"
94
94
  },
95
95
  "peerDependenciesMeta": {
96
96
  "@modern-js/builder-webpack-provider": {