<commit_before>import debounce from 'lodash/debounce'
import chokidar from 'chokidar'
import path from 'path'
import { modulesDirectory, ensureFiles, settings } from 'lib/plugins'

const requirePlugin = (pluginPath) => {
  try {
    return window.require(pluginPath)<commit_msg>Allow to use plugins with `default` key<commit_after>import debounce from 'lodash/debounce'
import chokidar from 'chokidar'
import path from 'path'
import { modulesDirectory, ensureFiles, settings } from 'lib/plugins'

const requirePlugin = (pluginPath) => {
  try {
    let plugin = window.require(pluginPath)
    // Fallback for plugins with structure like `{default: {fn: ...}}`
    const keys = Object.keys(plugin)
    if (keys.length === 1 && keys[0] === 'default') {
      plugin = plugin.default
    }
    return plugin
{'fraction_non_alphanumeric': 0.11567164179104478, 'fraction_numerical': 0.0024875621890547263, 'mean_word_length': 4.366666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2118857', 'n_tokens_mistral': 244, 'n_tokens_neox': 237, 'n_words': 74}