Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda