{"id":20819,"library":"webpack-requiredir","title":"webpack-requiredir","description":"This library provides a simple function to recursively require all modules from a webpack require.context, returning a hash of modules keyed by their names. Version 0.2.1 is the latest. It supports optional object modification, exclusion of specific modules, and applying a transformation function to each module. It is a minimal utility for use with webpack's require.context, primarily in Node.js or webpack-bundled applications. No active development; last updated in 2016.","status":"deprecated","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/lore/webpack-requiredir","tags":["javascript","webpack","require","dir"],"install":[{"cmd":"npm install webpack-requiredir","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-requiredir","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-requiredir","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not provide ESM exports; CommonJS only.","wrong":"import requireDir from 'webpack-requiredir';","symbol":"default","correct":"const requireDir = require('webpack-requiredir');"},{"note":"The package exports a single function as default.","wrong":"import { requireDir } from 'webpack-requiredir';","symbol":"requireDir","correct":"const requireDir = require('webpack-requiredir');\nrequireDir(require.context('./src', true, /\\.js$/));"},{"note":"Second argument is optional; if provided it must be an options object.","wrong":"const result = requireDir(require.context('./dir', true, /\\.js$/), {});","symbol":"require.context","correct":"const result = requireDir(require.context('./dir', true, /\\.js$/));"}],"quickstart":{"code":"const requireDir = require('webpack-requiredir');\nconst context = require.context('./src/components', true, /\\.js$/);\nconst modules = requireDir(context, {\n  exclude: ['index.js'],\n  functionToApply: (module) => module.default || module\n});\nconsole.log(modules);","lang":"javascript","description":"Shows how to require all .js files from ./src/components recursively, excluding index.js, and extracting default exports."},"warnings":[{"fix":"Replace with manual import() calls or webpack's require.context directly with custom logic.","message":"Package is no longer maintained; last update in 2016. Use dynamic imports or modern webpack context features instead.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure code is bundled with webpack; use only where require.context is available.","message":"require.context is webpack-specific; this library only works in a webpack-bundled environment.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Map keys as needed (e.g., strip extensions and leading './').","message":"The resolved module keys are file paths relative to the context directory; not suitable for dynamic access without normalization.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install webpack-requiredir","cause":"Package may not be installed or the name is misspelled.","error":"Cannot find module 'webpack-requiredir'"},{"fix":"Ensure the code is part of a webpack bundle, or use a polyfill for require.context.","cause":"Code is not running in a webpack-bundled environment (e.g., Node.js outside webpack).","error":"TypeError: require.context is not a function"},{"fix":"Use require() instead of import, or configure your bundler to handle CommonJS.","cause":"The package uses CommonJS, but your bundler expects ESM imports.","error":"Unexpected token export"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}