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

143
Views
Module aggregation in JavaScript evaluates all exports

I have the following JS file structure:

module1.js

console.log('Hello 1')
export const func1 = () => { }

module2.js

console.log('Hello 2')
export const func2 = () => { }

index.js

export * from 'module1'
export * from 'module2'

app.js

import {func1} from 'index'

func1()

In the console I can see both Hello 1 and Hello 2 logged. Is this intended behaviour? Will all modules be evaluated each time I import a single function from an aggregated module? And does it mean that if I want to optimize my code, I will always need to do as below?

import {func1} from 'module1'
import {func2} from 'module2'
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!