<commit_before>import path from 'path';
import { getInterpretedFile, serverRequire, Options } from '@storybook/core-common';

export async function getManagerBuilder(configDir: Options['configDir']) {
  const main = path.resolve(configDir, 'main');
  const mainFile = getInterpretedFile(main);
  const { core } = mainFile ? serverRequire(mainFile) : { core: null };

  const builderPackage =
    core?.builder === 'webpack5' ? '@storybook/manager-webpack5' : '@storybook/manager-webpack4';

  const managerBuilder = await import(builderPackage);
  return managerBuilder;
}
<commit_msg>Resolve configured manager builder relative to user's project<commit_after>import path from 'path';
import { getInterpretedFile, serverRequire, Options } from '@storybook/core-common';

export async function getManagerBuilder(configDir: Options['configDir']) {
  const main = path.resolve(configDir, 'main');
  const mainFile = getInterpretedFile(main);
  const { core } = mainFile ? serverRequire(mainFile) : { core: null };

  const builderPackage =
    core?.builder === 'webpack5'
      ? require.resolve('@storybook/manager-webpack5', { paths: [main] })
      : '@storybook/manager-webpack4';

  const managerBuilder = await import(builderPackage);
  return managerBuilder;
}

{'fraction_non_alphanumeric': 0.12480252764612954, 'fraction_numerical': 0.004739336492890996, 'mean_word_length': 5.4974358974358974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3131129', 'n_tokens_mistral': 355, 'n_tokens_neox': 350, 'n_words': 89}