module-unifier
v1.1.3
Published
Streamline your imports with a single require statement. This package simplifies the process of importing both npm modules and local files, allowing developers to unify all their requires in one clean, efficient declaration. Reduce boilerplate, improve co
Downloads
4
Readme
📦 Install
npm install module-unifier
🪄 Usage
Here are some examples of how to use module-unifier
Basic Usage
const { express, path, fs } = require('module-unifier');
// Now you can use express, path, and fs as if you've required them individually
const app = express();
const filePath = path.join(__dirname, 'example.txt');
const fileContents = fs.readFileSync(filePath, 'utf8');
Requiring Local Files
const { express, "./utils/myUtil.js": myUtil } = require('module-unifier');
// Now you can use express and myUtil
const app = express();
myUtil.doSomething();
Multiple Imports
const {
express, mongoose, path, passport,
"method-override": methodOverride,
"./utils/ExpressError.js": ExpressError,
"./routes/listing.js": listing,
"cookie-parser": cookieParser,
"express-session": session,
} = require("module-unifier");
// Use the imported modules
const app = express();
mongoose.connect(config.dbUri);
🚀 Features
- Unified interface for requiring npm packages and local files
- Reduces boilerplate code
- Improves code readability
- Provides helpful error messages for missing modules
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.