Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!