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

172
Visualizações
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 à 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