h5bp /
html5-boilerplate
A professional front-end template for building fast, robust, and adaptable web apps or sites.
Loading repository data…
Alamin-Juma / repository
A robust and flexible library for setting up absolute path imports with aliases like `@app/` in JavaScript and TypeScript projects.
A robust and flexible library for setting up absolute path imports with aliases like @app/ in JavaScript and TypeScript projects.
tsconfig.json or jsconfig.jsonnpm install import-aliases
Basic Usage In your entry file (e.g., index.js, app.js, or main.ts):
// Register aliases at the very beginning of your app
const { setupAliases } = require('import-aliases');
setupAliases();
// Now you can use absolute imports:
const myModule = require('@app/modules/myModule');
// Or with ES imports:
// import { myComponent } from '@app/components/myComponent';
Configuration Make sure your project has a tsconfig.json or jsconfig.json with paths configured:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@app/*": ["src/*"],
"@components/*": ["src/components/*"],
"@utils/*": ["src/utils/*"]
}
}
}
Custom Setup Options Customize the alias setup process:
const { setupAliases } = require('auto-import-helper');
// Advanced setup with options
const registeredAliases = setupAliases({
// Use a custom config file path
configPath: './configs/my-tsconfig.json',
// Enable verbose logging
verbose: true,
// Add custom aliases on top of those defined in the config
customAliases: {
'@lib': path.resolve(__dirname, 'lib'),
'@external': path.resolve(__dirname, 'node_modules/some-module')
}
});
console.log('Registered aliases:', registeredAliases);
Type Definitions TypeScript type definitions are included and provide full IntelliSense support:
import { setupAliases, createConfigWithAliases } from 'auto-import-helper';
// Full type support for options
setupAliases({
verbose: true,
customAliases: {
'@models': './src/domain/models'
}
});
Examples Basic Node.js Example
// index.js
const { setupAliases } = require('auto-import-helper');
setupAliases();
// Now use absolute imports
const { User } = require('@app/models/User');
Express.js Example
// app.js
const { setupAliases } = require('auto-import-helper');
setupAliases();
const express = require('express');
const routes = require('@app/routes');
const middlewares = require('@app/middlewares');
const app = express();
// ... app setup
TypeScript Example
// main.ts
import { setupAliases } from 'auto-import-helper';
setupAliases();
import { UserService } from '@app/services/UserService';
import { AppConfig } from '@app/config';
// ... application code
Compatibility Works with Node.js applications
Compatible with TypeScript and JavaScript projects
Works with frameworks like Express, NestJS, etc.
Compatible with testing frameworks like Jest
Contributing Contributions are welcome! Please feel free to submit a Pull Request.
License MIT
Selected from shared topics, language and repository description—not editorial ratings.
h5bp /
A professional front-end template for building fast, robust, and adaptable web apps or sites.
rescript-lang /
ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript.
cydrobolt /
:aerial_tramway: A modern, powerful, and robust URL shortener
OscarGodson /
EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.
mathiasbynens /
A robust base64 encoder/decoder that is fully compatible with `atob()` and btoa()`, written in JavaScript.
Azure-Samples /
A robust enterprise application sample (deployed on ACA) that leverages MCP and multiple AI agents orchestrated by Langchain.js, Llamaindex.TS and Microsoft Agent Framework.