ES Module 에 대하여

ES Module의 Named Export, Default Export, Star Export 방식과 최적화 방법을 자세히 설명합니다.

export const plus = (a, b) => a+b;
export const minus = (a, b) => a-b;
...

import { plus, minus as subtract } from "./math"




const plus = (a, b) => a+b;
const minus = (a, b) => a-b;

export default { plus, minus }
...

import myMath from "./math";
myMath.plus(1, 1);




export const plus = (a, b) => a+b; export const minus = (a, b) => a-b; …

import * as myMath from "./math"; myMath.plus(1, 1);

<br />
***
<br />

* 최적화 
    * Named Export 를 사용하는 것이, 최적화 부분에서는 더 우월하다.
    * Dyanmic Import 를 사용하면, 최적화 할 수 있다. 

javascript function doMath() { const math = await import("./math"); return math.plus(1, 1); } btn.addEventListener("click", doMath); ```


이것도 읽어보세요