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

153
Vistas
Why are TypeScript + Webpack putting generated declaration file (d.ts) within nested package folders instead of the root

I develop a library of packages with a complex TypeScript + Webpack setup. When I build some packages, they are correctly built into a dist folder. For example this one:

enter image description here

You see index.js alongside index.d.ts as expected.

But for some other packages, despite using the same configuration, I end up with a totally different result. The dist folder is structured into packages, one with the name of a package I depend on (@vulcanjs/graphql), one with the name of the current package (@vulcanjs/mongo)

enter image description here

I don't have a minimal reproduction, but the code is open source: https://github.com/VulcanJS/vulcan-npm.

The issue is that then, when importing from this @vulcanjs/mongo, I can't get the typings because index.d.ts is living in a nested folder while it should be at the root. Also I am not sure the graphql folder should be there either, since those typings are coming from a different package (@vulcanjs/graphql).

Each package configuration is extending the root configurations, both for Webpack and TypeScript.

I suspect my Webpack config to be wrong, I use the externals configuration, but I don't fully master it:

module.exports = {
  devtool: "inline-source-map",
  mode: "production",
  output: {
    libraryTarget: "commonjs2",
    filename: "index.js",
  },
  // This prevent bundling node_modules into the app
  // additionalModuleDirs allow handling root and nested node_modules
  // @see https://stackoverflow.com/questions/46010926/how-to-use-webpack-with-a-monorepo-yarnpkg-workspaces
  externals: [
    nodeExternals({
      additionalModuleDirs: [path.resolve(__dirname, "../node_modules")],
    }),
  ],
// ...rest of the code, that simply configure babel and ts-loader

Where should I start to debug this issue?

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