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
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 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