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
webpack 5 always include re exported module into main.js

I am using the example for multipart lib from the docs: https://github.com/webpack/webpack/tree/master/examples/multi-part-library

I am outputting them with the following config:

//webpack.config.js
var path = require("path");
module.exports = {
  // mode: "development || "production",
  experiments: {
    outputModule: true,
  },
  entry: {
    index: "./src/index",
    alpha: "./src/alpha",
    beta: "./src/beta",
    omega: "./src/omega",
  },

  output: {
    clean: true,
    path: path.join(__dirname, "dist"),
    filename: "MyLibrary.[name].js",
    // library: ["MyLibrary", "[name]"],
    libraryTarget: "module",
    chunkFormat: 'module',
  },
};

What I am not getting is that why the re exported modules are being included in the main. All I want is the main to a single point where I can import any of the modules I don't want to bundle them into it.

Just want to keep it as it is, but packaged with webpack. Similar to what you can do wit esbuild where you have the index.js but the re exported modules are not included in the main/index. ex: fp-ts esm bundle.

//index.js
export { default as alpha } from './alpha'
export { default as beta } from './beta'
export * from './omega'

Any ideas how I can achieve the same with webpack 5?

EDIT: After a lot of checking and testing I came to realize that I think webpack does that because no matter re exporting the modules all of them would be downloaded anyways in the browser. Which is ok. But I would still like to know how to avoid that and make sure that webpack re use the already build modules instead of adding them in the main.js.

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