export-files is a Node.js utility designed to automatically export all JavaScript files within a specified directory as modules. It provides a simple mechanism to aggregate multiple source files into a single object, where each file's export becomes a property. The current stable version is 3.0.2, with previous major breaking changes noted in v3.0.0 and v0.2.0. A key differentiator is its exclusive focus on CommonJS `require` syntax, explicitly stating it does not support ES Module `import` statements. It offers robust features like recursive directory processing, file filtering, and customizable key casing for the exported modules, making it suitable for organizing larger Node.js projects into modular structures without manual `require` statements for every file.
npm install export-filesVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `export-files` to load JavaScript modules from a directory, including nested directories, and access their exports. The example sets up a temporary directory with modules and cleans up afterwards.
Review the official README for v3.0.0 to understand the new `recursive` and `.case` options, and adjust your usage accordingly.
Ensure you are only attempting to export `.js` files. For non-JavaScript files, consider using the `to-exports` package.
Always use `const module = require('export-files');` syntax. If your project uses ES Modules, you may need to wrap `export-files` in a CommonJS module or re-evaluate your module loading strategy.Pass a custom `filter` function to the options, e.g., `{ filter: file => true }` or `{ filter: file => file.name !== 'another-file.js' }`.Replace `import exportFiles from 'export-files';` with `const exportFiles = require('export-files');`Ensure you pass the directory path, typically `__dirname`, as the first argument: `require('export-files')(__dirname);`Ensure that the directory only contains `.js` files you wish to export, or use the `to-exports` package for other file types.
No dependency data recorded yet.