내가 보려고 정리해두는 자바스크립트 require, import 차이점
const fs = require('fs')
exports.toYou = toYou //여러 개의 객체를 내보낼 경우, exports 변수의 속성으로 할당한다.
module.exports = obj; //딱 하나의 객체를 내보낼 경우, module.exports 변수 자체에 할당한다.
java나 Python처럼 import
키워드를 사용하여 좀 더 명시적으로 모듈을 불러온다.
import는 ES6(ES2015)에서 새롭게 도입된 키워드이다.
import express, { Request, Response } from 'express'
export { fooBar } //복수 객체
export default router //단일 객체
를 export default 키워드를 사용해서 명시적으로 선언해줍니다