<commit_before>import { NormalModuleReplacementPlugin } from 'webpack';

/** Replaces regular imports of `Flex` with `styled/Flex` */
export default class StyledReflexyWebpackPlugin extends NormalModuleReplacementPlugin {
  constructor() {
    super(/reflexy\/Flex\/Flex\.js/, '../styled/Flex/Flex.js');
  }
}<commit_msg>Fix StyledReflexyWebpackPlugin for webpack v5.49.0+<commit_after>/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import path from 'path';
import { NormalModuleReplacementPlugin } from 'webpack';

/** Replaces regular imports of `Flex` with `styled/Flex` */
export default class StyledReflexyWebpackPlugin extends NormalModuleReplacementPlugin {
  constructor() {
    // Works until webpack v5.49.0
    // super(/reflexy\/Flex\/Flex\.js/, '../styled/Flex/Flex.js');

    // Workaround for webpack v5.49.0+: https://github.com/webpack/webpack/issues/13957
    super(/reflexy\/Flex\/Flex\.js/, (resource) => {
      if (resource.createData) {
        const resolvedRequest = resource.createData.userRequest as string;
        resource.createData.resource = resolvedRequest.replace(
          /reflexy\/Flex\/Flex\.js/,
          'reflexy/styled/Flex/Flex.js'
        );
        resource.createData.context = path.dirname(resource.createData.resource);
      }
    });
  }
}
{'fraction_non_alphanumeric': 0.1411589895988113, 'fraction_numerical': 0.01263001485884101, 'mean_word_length': 3.4455445544554455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 1, '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': '6527684', 'n_tokens_mistral': 440, 'n_tokens_neox': 402, 'n_words': 77}