Skip to content

Commit

Permalink
Revert "Use --stats-json flag for SB 8.0.0+"
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcorbin authored Sep 13, 2024
1 parent 68338db commit ba8c70f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
19 changes: 0 additions & 19 deletions node-src/tasks/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,6 @@ describe('setBuildCommand', () => {
'Storybook version 6.2.0 or later is required to use the --only-changed flag'
);
});

it('uses the correct flag for webpack stats for >= 8.0.0', async () => {
getCliCommand.mockReturnValue(Promise.resolve('npm run build:storybook'));

const ctx = {
sourceDir: './source-dir/',
options: { buildScriptName: 'build:storybook' },
storybook: { version: '8.0.0' },
git: { changedFiles: ['./index.js'] },
} as any;
await setBuildCommand(ctx);

expect(getCliCommand).toHaveBeenCalledWith(
expect.anything(),
['build:storybook', '--output-dir=./source-dir/', '--stats-json=./source-dir/'],
{ programmatic: true }
);
expect(ctx.buildCommand).toEqual('npm run build:storybook');
});
});

describe('buildStorybook', () => {
Expand Down
9 changes: 1 addition & 8 deletions node-src/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ export const setSourceDir = async (ctx: Context) => {
}
};

// Storybook 8.0.0 deprecated --webpack-stats-json in favor of --stats-json.
const webpackStatsFlag = (version: string) => {
return semver.gte(semver.coerce(version), '8.0.0') ? '--stats-json' : '--webpack-stats-json';
};

export const setBuildCommand = async (ctx: Context) => {
const webpackStatsSupported =
ctx.storybook && ctx.storybook.version
Expand All @@ -44,9 +39,7 @@ export const setBuildCommand = async (ctx: Context) => {

const buildCommandOptions = [
`--output-dir=${ctx.sourceDir}`,
ctx.git.changedFiles &&
webpackStatsSupported &&
`${webpackStatsFlag(ctx.storybook.version)}=${ctx.sourceDir}`,
ctx.git.changedFiles && webpackStatsSupported && `--webpack-stats-json=${ctx.sourceDir}`,
].filter(Boolean);

ctx.buildCommand = await (isE2EBuild(ctx.options)
Expand Down

0 comments on commit ba8c70f

Please sign in to comment.