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'