Doplax.Dev
  • Inicio
  • Conóceme
  • Blog
  • Experiencia
  • Contacto
  • Inicio
  • Conóceme
  • Blog
  • Experiencia
  • Contacto

¿Tienes un proyecto en mente o quieres saludar?

Contáctame

© 2026 Doplax.Dev — Todos los derechos reservados.

November 30, 2023

Simplify Your Imports in JavaScript with Module Aliases

  • Productivity

If you've ever found yourself typing long relative paths in your JavaScript or TypeScript code, this article will unveil an efficient and elegant way to simplify your imports using module aliases.


How to configure Module Alias:

Module alias configuration is done in the tsconfig.json, tsconfig.app.json, or jsconfig.json file, depending on your project.

you're working with JavaScript, you can use jsconfig.json in the same way:

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@components/*": ["src/components/*"],
      "@services/*": ["src/services/*"],
      "@utils/*": ["src/utils/*"]
    }
  }
}

Once configured, you can import modules like this in your JavaScript code:

import Button from '@components/Button';
import AuthService from '@services/AuthService';
import { formatDate } from '@utils/dateUtils';

Benefits of Using Module Aliases**:**

Module aliases are a powerful tool for simplifying your imports in JavaScript/TypeScript projects. If you're tired of typing long and confusing relative paths, you should definitely consider using this technique. Also, remember that alias configuration is done in tsconfig.json, tsconfig.app.json, or jsconfig.json, depending on your project. Streamline your code and enhance your workflow with this practical technique!

AnteriorCómo Convertir Strings a Números en JavaScriptSiguientePara que sirve HostBinding?

Posts relacionados

  • Core vs Shared: diferencias clave entre estas carpetas en la arquitectura de un proyectoProductivity

Escrito por Pol Valle

Escrito por Pol Valle

Me interesa especialmente desarrollar aplicaciones que no solo sean funcionales, sino también atractivas y fáciles de usar. Lo consigo aplicando principios SOLID, arquitectura limpia y testing para garantizar la calidad.