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

180
Vistas
Webpack bundling behavior for star imports in React.js , webpack 5

lets say I have util.js file in my react project, that has various handy functions I am using across react components.

export const functionOne = () => {
   //does something
  return some_value;
}

export const functionTwo = () => {
   //does something
  return some_value;
}

export const functionThree = () => {
   //does something
  return some_value;
}    

and lets consider these 2 scenarios.

First scenario where we are using * imports in react compoent <ComponentA />

import React, { useState } from react;
import * as util from "./util.js";
const ComponentA = () => {
   return <button onClick={() => util.functionOne()} > Button </button>
}
export default ComponentA;

Second scenario where we are not doing * import and only importing some specific functions that are inside util.js file in <ComponentA />

import React, { useState } from react;
import { functionOne } from "./util.js";
const ComponentA = () => {
   return <button onClick={() => functionOne()} > Button </button>
}
export default ComponentA;

Now when webpack bundles this component <ComponentA /> in first scenario where I am using star import, does it include all the functions inside utils in bundeled file ?

I am not using Create React App.

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