Skip to content

Commit

Permalink
feat!: compact with storybook 8.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jul 12, 2024
1 parent e476659 commit 38f1eed
Show file tree
Hide file tree
Showing 19 changed files with 510 additions and 1,975 deletions.
17 changes: 5 additions & 12 deletions packages/builder-rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,8 @@
},
"dependencies": {
"@rsbuild/plugin-type-check": "1.0.0-alpha.9",
"@storybook/addon-docs": "^8.0.10",
"@storybook/channels": "^8.0.10",
"@storybook/client-logger": "^8.0.10",
"@storybook/core-common": "^8.0.10",
"@storybook/core-events": "^8.0.10",
"@storybook/core-webpack": "^8.0.10",
"@storybook/node-logger": "^8.0.10",
"@storybook/preview": "^8.0.10",
"@storybook/preview-api": "^8.0.10",
"@storybook/react-dom-shim": "^8.0.10",
"@storybook/types": "^8.0.10",
"@storybook/addon-docs": "^8.2.1",
"@storybook/core-webpack": "^8.2.1",
"browser-assert": "^1.2.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
"cjs-module-lexer": "^1.2.3",
Expand Down Expand Up @@ -99,10 +90,12 @@
"add": "^2.0.6",
"pretty-hrtime": "^1.0.3",
"slash": "^5.0.0",
"storybook": "8.2.1",
"typescript": "^5.3.2"
},
"peerDependencies": {
"@rsbuild/core": ">= 1.0.0-alpha.9"
"@rsbuild/core": ">= 1.0.0-alpha.9",
"storybook": "^8.2.1"
},
"peerDependenciesMeta": {
"typescript": {
Expand Down
18 changes: 8 additions & 10 deletions packages/builder-rsbuild/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as rsbuildReal from '@rsbuild/core'
import type { Options } from '@storybook/types'
import { dirname, join, parse } from 'path'
import type { Options } from 'storybook/internal/types'
import { join, parse } from 'path'
import express from 'express'
import fs from 'fs-extra'
import { WebpackInvocationError } from '@storybook/core-events/server-errors'
import { WebpackInvocationError } from 'storybook/internal/server-errors'
import type { RsbuildBuilder } from './types'
import rsbuildConfig, {
type RsbuildBuilderOptions,
} from './preview/iframe-rsbuild.config'
import { corePath } from 'storybook/core-path'

import prettyTime from 'pretty-hrtime'

Expand All @@ -28,9 +29,6 @@ export const printDuration = (startTime: [number, number]) =>
.replace(' s', ' seconds')
.replace(' m', ' minutes')

const getAbsolutePath = <I extends string>(input: I): I =>
dirname(require.resolve(join(input, 'package.json'))) as any

type BuilderStartOptions = Parameters<RsbuildBuilder['start']>['0']

export const executor = {
Expand Down Expand Up @@ -119,8 +117,8 @@ export const start: RsbuildBuilder['start'] = async ({
})
}

const previewResolvedDir = getAbsolutePath('@storybook/preview')
const previewDirOrigin = join(previewResolvedDir, 'dist')
const previewResolvedDir = join(corePath, 'dist/preview')
const previewDirOrigin = previewResolvedDir

router.use(
`/sb-preview`,
Expand Down Expand Up @@ -150,8 +148,8 @@ export const build: ({
rsbuildConfig: config,
})

const previewResolvedDir = getAbsolutePath('@storybook/preview')
const previewDirOrigin = join(previewResolvedDir, 'dist')
const previewResolvedDir = join(corePath, 'dist/preview')
const previewDirOrigin = previewResolvedDir
const previewDirTarget = join(options.outputDir || '', `sb-preview`)
let stats: Stats

Expand Down
6 changes: 3 additions & 3 deletions packages/builder-rsbuild/src/preview/iframe-rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { dirname, join, resolve } from 'path'
// @ts-expect-error (I removed this on purpose, because it's incorrect)
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'
import type { Options } from '@storybook/types'
import type { Options } from 'storybook/internal/types'
import type { BuilderOptions } from '../types'
import { globalsNameReferenceMap } from '@storybook/preview/globals'
import { globalsNameReferenceMap } from 'storybook/internal/preview/globals'
import {
stringifyProcessEnvs,
normalizeStories,
getBuilderOptions,
isPreservingSymlinks,
} from '@storybook/core-common'
} from 'storybook/internal/common'
import { dedent } from 'ts-dedent'
import { getVirtualModules } from './virtual-module-mapping'
import { loadConfig, mergeRsbuildConfig } from '@rsbuild/core'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import type {
NormalizedStoriesSpecifier,
Options,
PreviewAnnotation,
} from '@storybook/types'
} from 'storybook/internal/types'
import { join, resolve } from 'path'
import {
handlebars,
loadPreviewOrConfigFile,
normalizeStories,
readTemplate,
} from '@storybook/core-common'
} from 'storybook/internal/common'
import slash from 'slash'
import { webpackIncludeRegexp } from '@storybook/core-webpack'
import { dedent } from 'ts-dedent'
Expand Down
2 changes: 1 addition & 1 deletion packages/builder-rsbuild/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
Options,
TypescriptOptions as TypeScriptOptionsBase,
BuilderResult as BuilderResultBase,
} from '@storybook/types'
} from 'storybook/internal/types'
import type { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check'

// Storybook's Stats are optional Webpack related property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { global } from '@storybook/global';

import { ClientApi, PreviewWeb, addons, composeConfigs } from '@storybook/preview-api';
import { createBrowserChannel } from '@storybook/channels';
import { ClientApi, PreviewWeb, addons, composeConfigs } from 'storybook/internal/preview-api';
import { createBrowserChannel } from 'storybook/internal/channels';

import { importFn } from './{{storiesFilename}}';

Expand Down
8 changes: 4 additions & 4 deletions packages/react-rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@
"prep": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/docs-tools": "^8.0.10",
"@storybook/node-logger": "^8.0.10",
"@storybook/react": "^8.0.10",
"@storybook/react": "^8.2.1",
"@storybook/react-docgen-typescript-plugin": "^1.0.1",
"@types/node": "^18.0.0",
"find-up": "^5.0.0",
Expand All @@ -67,15 +65,17 @@
},
"devDependencies": {
"@rsbuild/core": "1.0.0-alpha.9",
"@storybook/types": "^8.0.10",
"@storybook/types": "^8.2.1",
"@types/resolve": "^1.20.6",
"add": "^2.0.6",
"storybook": "^8.2.1",
"typescript": "^5.3.2"
},
"peerDependencies": {
"@rsbuild/core": ">= 1.0.0-alpha.9",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta",
"storybook": "^8.2.1",
"typescript": ">= 4.2.x"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-rsbuild/src/loaders/react-docgen-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
babelTypes as t,
Documentation,
} from 'react-docgen'
import { logger } from '@storybook/node-logger'
import { logger } from 'storybook/internal/node-logger'

import {
RESOLVE_EXTENSIONS,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-rsbuild/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dirname, join } from 'path'
import type { PresetProperty } from '@storybook/types'
import type { PresetProperty } from 'storybook/internal/types'
import { rsbuildFinalDocs } from './react-docs'
import type { StorybookConfig } from './types'

Expand Down
2 changes: 1 addition & 1 deletion packages/react-rsbuild/src/react-docs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hasDocsOrControls } from '@storybook/docs-tools'
import { hasDocsOrControls } from 'storybook/internal/docs-tools'
import { mergeRsbuildConfig } from '@rsbuild/core'

import type { RsbuildConfig } from '@rsbuild/core'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-rsbuild/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
import type {
StorybookConfig as StorybookConfigBase,
TypescriptOptions as TypescriptOptionsBase,
} from '@storybook/types'
} from 'storybook/internal/types'
import type { PluginOptions as ReactDocgenTypescriptOptions } from '@storybook/react-docgen-typescript-plugin'

type FrameworkName = 'storybook-react-rsbuild'
Expand Down
8 changes: 4 additions & 4 deletions packages/vue3-rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@
"prep": "node --loader ../../scripts/node_modules/esbuild-register/loader.js -r ../../scripts/node_modules/esbuild-register/register.js ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/docs-tools": "^8.0.10",
"@storybook/types": "^8.0.10",
"@storybook/vue3": "^8.0.10",
"@storybook/vue3": "^8.2.1",
"storybook-builder-rsbuild": "workspace:*",
"vue-docgen-loader": "^1.5.1"
},
"devDependencies": {
"@rsbuild/core": "1.0.0-alpha.9",
"@types/node": "^18.0.0",
"storybook": "^8.2.1",
"typescript": "^5.3.2"
},
"peerDependencies": {
"@rsbuild/core": ">= 1.0.0-alpha.9"
"@rsbuild/core": ">= 1.0.0-alpha.9",
"storybook": "^8.2.1"
},
"peerDependenciesMeta": {
"typescript": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue3-rsbuild/src/framework-preset-vue3-docs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StorybookConfig } from './types'
import { hasDocsOrControls } from '@storybook/docs-tools'
import { hasDocsOrControls } from 'storybook/internal/docs-tools'
import { mergeRsbuildConfig } from '@rsbuild/core'

export const rsbuildFinal: StorybookConfig['rsbuildFinal'] = (
Expand Down
2 changes: 1 addition & 1 deletion packages/vue3-rsbuild/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PresetProperty } from '@storybook/types'
import type { PresetProperty } from 'storybook/internal/types'
import { dirname, join } from 'path'

export { rsbuildFinal } from './framework-preset-vue3-docs'
Expand Down
2 changes: 1 addition & 1 deletion packages/vue3-rsbuild/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
StorybookConfig as StorybookConfigBase,
TypescriptOptions as TypescriptOptionsBaseAndVue,
} from '@storybook/types'
} from 'storybook/internal/types'
import type {
StorybookConfigRsbuild,
TypescriptOptions as TypescriptOptionsBuilder,
Expand Down
Loading

0 comments on commit 38f1eed

Please sign in to comment.