Skip to content

Commit

Permalink
Fix CRA
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Nov 28, 2023
1 parent 0adaf29 commit 99dab60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions code/presets/create-react-app/src/helpers/processCraConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const testMatch = (rule: RuleSetRule, string: string): boolean => {
: isRegExp(rule.test) && rule.test.test(string);
};

export const processCraConfig = (
export const processCraConfig = async (
craWebpackConfig: Configuration,
options: PluginOptions
): RuleSetRule[] => {
): Promise<RuleSetRule[]> => {
const configDir = resolve(options.configDir);

/*
Expand All @@ -37,6 +37,7 @@ export const processCraConfig = (
*/
const storybookVersion = semver.coerce(options.packageJson.version) || '';
const isStorybook530 = semver.gte(storybookVersion, '5.3.0');
const babelOptions = await options.presets.apply('babel');

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return craWebpackConfig.module!.rules.reduce((rules, rule): RuleSetRule[] => {
Expand Down Expand Up @@ -108,12 +109,7 @@ export const processCraConfig = (
overrides: TransformOptions[] | null;
};

const {
extends: _extends,
plugins,
presets,
overrides,
} = (options as any).babelOptions;
const { extends: _extends, plugins, presets, overrides } = babelOptions;

return {
...oneOfRule,
Expand Down
2 changes: 1 addition & 1 deletion code/presets/create-react-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const webpack = async (

// Select the relevant CRA rules and add the Storybook config directory.
logger.info(`=> Modifying Create React App rules.`);
const craRules = processCraConfig(craWebpackConfig, options);
const craRules = await processCraConfig(craWebpackConfig, options);

// NOTE: These are set by default in Storybook 6.
const isStorybook6 = semver.gte(options.packageJson.version || '', '6.0.0');
Expand Down

0 comments on commit 99dab60

Please sign in to comment.