Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
ESM modules, package.json exports, and relative imports within a project

I have a module where the package.json contains:

"type": "module",
"exports": {
  ".": "./build/index.js",
  "./*": "./build/*.js",
  "./sub-dir": "./build/sub-dir/index.js",
  "./sub-dir/*": "./build/sub-dir/*.js"
},

From outside of this package, this now resolves just fine:

const { whatever } = import('module/sub-dir/foo');

however, from within the module, this breaks:

const { whatever } = import('./sub-dir/foo');

This is a TS project, so ./src/sub-dir/foo.ts compiles to ./build/sub-dir/foo.js

So if I change my import to './sub-dir/foo.js', then the built project works, but that path isn't valid in src, so TS breaks.

Any idea on a "proper" configuration here? Or the proper way to import this file, or anything else?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda