Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: compatible with Storybook 8.4.0-alpha.5 #140

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/builder-rsbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,25 @@
"cjs-module-lexer": "^1.4.1",
"constants-browserify": "^1.0.0",
"es-module-lexer": "^1.5.4",
"express": "^4.21.0",
"fs-extra": "^11.2.0",
"magic-string": "^0.30.11",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"rsbuild-plugin-html-minifier-terser": "^1.1.1",
"sirv": "^2.0.4",
"ts-dedent": "^2.2.0",
"url": "^0.11.4",
"util": "^0.12.5",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@rsbuild/core": "1.0.8",
"@types/express": "^4.17.21",
"@types/fs-extra": "^11.0.4",
"@types/node": "^18.0.0",
"@types/pretty-hrtime": "^1.0.3",
"pretty-hrtime": "^1.0.3",
"slash": "^5.1.0",
"storybook": "8.4.0-alpha.4",
"storybook": "8.4.0-alpha.5",
"typescript": "^5.6.2"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/builder-rsbuild/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { type AddressInfo, createServer } from 'node:net'
import { join, parse } from 'node:path'
import * as rsbuildReal from '@rsbuild/core'
import { mergeRsbuildConfig } from '@rsbuild/core'
import express from 'express'
import fs from 'fs-extra'
import prettyTime from 'pretty-hrtime'
import sirv from 'sirv'
import { corePath } from 'storybook/core-path'
import { getPresets, resolveAddonName } from 'storybook/internal/common'
import { WebpackInvocationError } from 'storybook/internal/server-errors'
Expand Down Expand Up @@ -178,7 +178,7 @@ export const start: RsbuildBuilder['start'] = async ({

router.use(
'/sb-preview',
express.static(previewDirOrigin, { immutable: true, maxAge: '5m' }),
sirv(previewDirOrigin, { maxAge: 300000, dev: true, immutable: true }),
)

router.use(rsbuildServer.middlewares)
Expand Down
4 changes: 2 additions & 2 deletions packages/builder-rsbuild/src/preview/iframe-rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default async (
docsOptions,
entries,
nonNormalizedStories,
// modulesCount = 1000,
_modulesCount,
build,
tagsOptions,
] = await Promise.all([
Expand All @@ -100,7 +100,7 @@ export default async (
presets.apply('docs'),
presets.apply<string[]>('entries', []),
presets.apply('stories', []),
options.cache?.get('modulesCount').catch(() => {}),
options.cache?.get('modulesCount', 1000),
options.presets.apply('build'),
presets.apply('tags', {}),
])
Expand Down
13 changes: 12 additions & 1 deletion packages/builder-rsbuild/src/preview/virtual-module-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ import type { BuilderOptions } from '../types'
export const getVirtualModules = async (options: Options) => {
const virtualModules: Record<string, string> = {}
const cwd = process.cwd()
const workingDir = options.cache?.basePath || process.cwd()
const workingDir = options.cache
? path.resolve(
process.cwd(),
// TODO: This is a hard code cache dir, as Rspack doesn't support virtual modules now.
// Remove this when Rspack supports virtual modules.
'./node_modules/.cache/storybook/storybook-rsbuild-builder',
)
: process.cwd()

if (!fs.existsSync(workingDir)) {
fs.mkdirSync(workingDir, { recursive: true })
}

const isProd = options.configType === 'PRODUCTION'
const nonNormalizedStories = await options.presets.apply('stories', [])
Expand Down
4 changes: 2 additions & 2 deletions packages/framework-html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
},
"devDependencies": {
"@rsbuild/core": "1.0.8",
"@storybook/types": "8.4.0-alpha.4",
"@storybook/types": "8.4.0-alpha.5",
"@types/resolve": "^1.20.6",
"storybook": "8.4.0-alpha.4",
"storybook": "8.4.0-alpha.5",
"typescript": "^5.6.2"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/framework-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
},
"devDependencies": {
"@rsbuild/core": "1.0.8",
"@storybook/types": "8.4.0-alpha.4",
"@storybook/types": "8.4.0-alpha.5",
"@types/resolve": "^1.20.6",
"react": "18.3.1",
"react-dom": "18.3.1",
"storybook": "8.4.0-alpha.4",
"storybook": "8.4.0-alpha.5",
"typescript": "^5.6.2"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/framework-vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"devDependencies": {
"@rsbuild/core": "1.0.8",
"@types/node": "^18.0.0",
"storybook": "8.4.0-alpha.4",
"storybook": "8.4.0-alpha.5",
"typescript": "^5.6.2"
},
"peerDependencies": {
Expand Down
Loading