Skip to content

Commit 682d9c0

Browse files
authored
chore: upgrade storybook to 10.1.10 (#905)
1 parent e4fd657 commit 682d9c0

File tree

7 files changed

+1985
-2450
lines changed

7 files changed

+1985
-2450
lines changed

.storybook/addons/generateDocs.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as fs from 'fs/promises';
22
import * as path from 'path';
3+
import {fileURLToPath} from 'url';
4+
import {dirname} from 'path';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = dirname(__filename);
38

49
const inputDir = path.join(__dirname, '../../docs');
510
const outputDir = path.join(__dirname, '../../demo/docs');
@@ -19,7 +24,7 @@ const getContent = (title: string, updatedContent: string): string => `
1924
This file is auto-generated. Any changes made to this file will be overwritten
2025
*/}
2126
22-
import { Meta, Markdown } from '@storybook/blocks';
27+
import { Meta, Markdown } from '@storybook/addon-docs/blocks';
2328
2429
<Meta title="Docs / ${title}" />
2530
@@ -95,7 +100,7 @@ const generateDocs = async (): Promise<void> => {
95100
*/
96101
export default {
97102
name: 'generate-docs',
98-
async managerEntries(entries: string[] = []): Promise<string[]> {
103+
async previewAnnotations(entries: string[] = []): Promise<string[]> {
99104
try {
100105
await generateDocs();
101106
} catch (error) {

.storybook/main.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import {resolve} from 'node:path';
1+
import {resolve, dirname} from 'node:path';
2+
import {fileURLToPath} from 'node:url';
3+
import {createRequire} from 'node:module';
24
import webpack from 'webpack';
35
import type {StorybookConfig} from '@storybook/react-webpack5';
4-
import pkg from '../package.json';
5-
import tsConfig from '../tsconfig.json';
6+
7+
const require = createRequire(import.meta.url);
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = dirname(__filename);
10+
11+
const pkg = require('../package.json');
12+
const tsConfig = require('../tsconfig.json');
613

714
const config: StorybookConfig = {
815
framework: {
@@ -11,9 +18,8 @@ const config: StorybookConfig = {
1118
},
1219
stories: ['../demo/**/*.mdx', '../demo/**/*.stories.@(js|jsx|ts|tsx)'],
1320
addons: [
14-
'./addons/generateDocs',
21+
'./addons/generateDocs.ts',
1522
'@storybook/preset-scss',
16-
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
1723
'@storybook/addon-webpack5-compiler-babel',
1824
'@storybook/addon-docs',
1925
],
@@ -26,16 +32,29 @@ const config: StorybookConfig = {
2632
new webpack.DefinePlugin({
2733
__VERSION__: `'${pkg.version}-storybook'`,
2834
}),
35+
new webpack.ProvidePlugin({
36+
process: 'process/browser',
37+
}),
2938
);
3039

3140
config.resolve ||= {};
3241
config.resolve.alias ||= {};
42+
config.resolve.fallback ||= {};
43+
44+
// Node.js polyfills for browser
45+
config.resolve.fallback = {
46+
...config.resolve.fallback,
47+
fs: false,
48+
path: require.resolve('path-browserify'),
49+
url: require.resolve('url/'),
50+
process: require.resolve('process/browser'),
51+
};
3352

3453
const baseUrl = resolve(__dirname, '..', tsConfig.compilerOptions.baseUrl);
3554
const paths = tsConfig.compilerOptions.paths;
3655

3756
for (const alias in paths) {
38-
config.resolve.alias[alias] = resolve(baseUrl, paths[alias][0])
57+
config.resolve.alias[alias] = resolve(baseUrl, paths[alias][0]);
3958
}
4059

4160
config.resolve.alias['demo/*'] = resolve(__dirname, '..', 'demo/*');

.storybook/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {addons} from '@storybook/manager-api';
1+
import {addons} from 'storybook/manager-api';
22
import {themes} from './theme';
33

44
addons.setConfig({

.storybook/preview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type {Preview} from '@storybook/react';
2-
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';
1+
import type {Preview} from '@storybook/react-webpack5';
2+
import {MINIMAL_VIEWPORTS} from 'storybook/viewport';
33
import {withThemeProvider} from '../demo/hocs/withThemeProvider';
44
import {withLang} from '../demo/hocs/withLang';
55
import {withToaster} from '../demo/hocs/withToaster';
@@ -9,7 +9,7 @@ const preview: Preview = {
99
parameters: {
1010
jsx: {showFunctions: true}, // To show functions in sources
1111
viewport: {
12-
viewports: MINIMAL_VIEWPORTS,
12+
options: MINIMAL_VIEWPORTS,
1313
},
1414
options: {
1515
storySort: {

.storybook/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {create} from '@storybook/theming';
1+
import {create} from 'storybook/theming';
22

33
export const ThemeLight = create({
44
base: 'light',

0 commit comments

Comments
 (0)