일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- 야근은결국승리
- ERR_CERT_AUTHORITY_INVALID
- VSCode
- ReactRouter withRouter
- 리엑트
- 해볼게
- 시플플은영원하구나
- 자바스크립트
- 무과금살아남기
- 코틀린
- 리엑트라우터 구버전 살리기
- checkupdates
- kotlinc
- 날이새도록
- ReactRouter6 다운그레이드
- 공부할시간이
- vscode 수동업데이트
- 편하게쓰자
- 반갑지는않아
- 나의야근
- HTML 자바스크립트 태그제거
- 복붙하기좋은
- 안할수가없네
- react
- ReactRouter 4
- 정규식
- 신기술은
- ubuntu_rg_cpu_100%
- 모던디자인테마
- 선택했을까
- Today
- Total
필사(筆寫)
Node V8 버전 이상 테스트 mjs 본문
Update 13 September 2017
NodeJS 8.5.0 has been released with support for mjs files behind a flag:
node --experimental-modules index.mjs
The plan for this is to remove the flag for the v10.0 LTS release.
Update 8 September 2017
NodeJS master branch has been updated with initial support for ESM modules:
https://github.com/nodejs/node/commit/c8a389e19f172edbada83f59944cad7cc802d9d5
This should be available in the latest nightly (this can be installed via nvm to run alongside your existing install):
https://nodejs.org/download/nightly/
And enabled behind the --experimental-modules
flag:
package.json
{
"name": "testing-mjs",
"version": "1.0.0",
"description": "",
"main": "index.mjs" <-- Set this to be an mjs file
}
Then run:
node --experimental-modules .
--Outdated Information. Kept here for historical purposes--
Update February 2017:
https://medium.com/@jasnell/an-update-on-es6-modules-in-node-js-42c958b890c#.6ye7mtn37
The NodeJS guys have decided that the least bad solution is to use the .mjs
file extension. The takeaway from this is:
In other words, given two files
foo.js
andbar.mjs
, usingimport * from 'foo'
will treatfoo.js
as CommonJS whileimport * from 'bar'
will treatbar.mjs
as an ES6 Module
And as for timelines...
At the current point in time, there are still a number of specification and implementation issues that need to happen on the ES6 and Virtual Machine side of things before Node.js can even begin working up a supportable implementation of ES6 modules. Work is in progress but it is going to take some time — We’re currently looking at around a year at least.
Update October 2016:
One of the developers on Node.JS recently attended a TC-39 meeting and wrote up a superb article on the blockers to implementing for Node.JS:
https://hackernoon.com/node-js-tc-39-and-modules-a1118aecf95e
The basic take-away from that is:
- ES Modules are statically analyzed, CommonJS are evaluated
- CommonJS modules allow for monkey-patching exports, ES Modules currently do not
- It's difficult to detect what is an ES Module and what is CommonJS without some form of user input, but they are trying.
*.mjs
seems the most likely solution, unless they can accurately detect an ES Module without user-input
-- Original Answer --
This has been a hot potato for quite some time. Bottom line is that yes, Node will eventually support the ES2015 syntax for importing/exporting modules - most likely when the spec for loading modulesis finalized and agreed upon.
Here is a good overview of what's holding NodeJS up. Essentially, they need to make sure that the new spec works for Node which is primarily conditional, synchronous loading and also HTML which is primarily asynchronous.
Nobody knows for sure right now, but I imagine Node will support import/export
for static loading, in addition to the new System.import
for dynamic loading - while still keeping require
for legacy code.
Here's a few proposals on how Node might achieve this:
'고민흔적' 카테고리의 다른 글
react-dev-utils/openBrowser (0) | 2017.12.16 |
---|---|
Webpack 3.x 독학 해보기 (0) | 2017.12.15 |
React.js, Angular 두개 모두 단점 (0) | 2017.12.12 |
ES6 2주차 경험담 (0) | 2017.12.10 |
React 와 Angular.js(1.x)의 템플릿을 보고 느낀 느낌 적어놓기 (0) | 2017.12.08 |