boseok-note
  • README
  • javascript
    • 함수형 자바스크립트
    • core
      • 이벤트루프 (Event Loop)
      • boxing, unboxing
      • prototype
      • 실행컨텍스트
      • hoisting
      • 클로져(Closure)
      • arguments
      • Scope - 스코프 - 유효범위
    • api
      • Promise
      • Fetch API
      • worker-api
      • Web API
    • lib
      • rxjs
        • rxjs
    • 호스트객체?
    • es6
      • var-let-const
      • template-literals
      • async-await
    • tip
      • array-like
      • Object literal, new Object
    • dom-api
      • HTML Element get Text
      • get-size
      • scrollToBottom
    • for in, for of 차이
    • storage
    • Constructor (생성자)
    • Javascript
    • module
  • front-end
    • vuejs
      • vue-rx
      • README
        • 1-start
        • 2-basic-component
        • 3-add-component
        • 4-advanced-component
        • 5-dynamic-methods-event
        • 6-internal-process
      • next-tick
      • compare-react
      • v-model-with-props
      • v-for
      • vuejs
      • vuex
    • browser
      • dom
      • cssom
      • reflow, repaint
      • 렌더링 트리(Rendering Tree)
      • web-standard
    • css
      • text-ellipse
      • white-space
      • css layout
    • Pre-render
    • react-native
      • react-native
    • 최적화 관련
    • reactjs
      • performance
      • reactjs
    • CSR, SSR
  • server-side
    • letsencrypt
    • auto-deploy
    • nlb
    • Certbot, aws https setting with wildcard
    • mysql
    • node.js
      • npm
        • npm install
      • node-dynamodb
      • node에서 간편하게 letsencrypt를 사용하여 https 구현하는 방법
    • Docker
    • nginx
    • Amazon Web Service
    • nginx https 설정
  • design-pattern
    • observer
    • flux
    • README
  • coop
    • git
      • gitignore
      • remote
      • ssh key 사용하기
      • password
      • credential
      • git
  • cs
    • port
    • data-structure
      • tree
      • binary-tree
    • network
      • home-router
      • tcp-udp
      • http
    • process
  • etc
    • sync-async
    • seo
      • seo
      • SEO Check Point
    • rest
    • unity
      • methods
Powered by GitBook
On this page
  • export, import
  • es6 모듈
  • nodejs 모듈
  • export와 코드의 실행순서
  • import * as {Alias}, import {Alias} 차이
  1. javascript

module

export, import

es6 모듈

export, import

es6모듈의 import 키워드와 webpack, parcel같은 번들러의 dynamic import 메소드를 구분하자.

nodejs 모듈

commonJS와 거의 동일하지만 자체적인 모듈을 사용

module.exports

require()

export와 코드의 실행순서

constants들을 따로따로 구분지어서 작성해놓았을때, 서로 import해야하는 상황이 온다.

그럴때 import를 해도 undefined가 나오는경우가 간혹있는데,

당연히 실행순서에 문제가 있기때문이다.

console.log('1');
export * from './someConstants';
// someConstants.js
console.log('2');

콘솔에는 1 2 가 나올것으로 기대하겠지만, 2 1로 나온다.

export에 우선순위가 있다.

import * as {Alias}, import {Alias} 차이

// a.js
export const a = 1;
export const b = 2;
export default 3;
import A from './a';
import * as B from './a';
console.log(A); //3
console.log(B); //Module {a:1, b:2, default:3, ...}
PreviousJavascriptNextfront-end

Last updated 5 years ago