Skip to content

Commit 208d543

Browse files
committed
fix(builder-rsbuild): make options.cache optional for Nx compatibility
- Remove hard throw when Storybook options.cache is missing - Align cache handling behavior with official builder-webpack5 - Add unit test to verify no-cache scenario works - Fixes issue #33 (Nx executor passes undefined cache)
1 parent 3176758 commit 208d543

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/builder-rsbuild/src/preview/iframe-rsbuild.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ export default async (
179179
const { virtualModules: virtualModuleMapping, entries: dynamicEntries } =
180180
await getVirtualModules(options)
181181

182-
if (!options.cache) {
183-
throw new Error('Cache is required')
184-
}
185-
186182
let contentFromConfig: RsbuildConfig = {}
187183
const { content } = await loadConfig({
188184
cwd: workingDir,

packages/builder-rsbuild/tests/preview/iframe-rsbuild.config.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ const createOptions = (
9898
return { options, apply }
9999
}
100100

101+
const createOptionsWithoutCache = (
102+
lazyCompilation: LazyCompilationOption | 'unset' = false,
103+
) => {
104+
const { options, apply } = createOptions(lazyCompilation)
105+
106+
delete options.cache
107+
108+
return { options, apply }
109+
}
110+
101111
describe('iframe-rsbuild.config', () => {
102112
it('overrides rsbuild source.entry with Storybook entry', async () => {
103113
const { options } = createOptions()
@@ -116,6 +126,16 @@ describe('iframe-rsbuild.config', () => {
116126
})
117127
})
118128

129+
it('does not require cache from storybook options', async () => {
130+
const { options } = createOptionsWithoutCache()
131+
132+
const config = await createIframeRsbuildConfig(
133+
options as RsbuildBuilderOptions,
134+
)
135+
136+
expect(config.source?.entry).toBeDefined()
137+
})
138+
119139
const runRspackTool = async (
120140
lazyCompilation: LazyCompilationOption | 'unset',
121141
) => {

0 commit comments

Comments
 (0)