1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 10:22:23 +00:00

edit module

This commit is contained in:
ruanyf 2015-12-23 16:47:48 +08:00
parent 61d7165df9
commit 61d2f36c9c
2 changed files with 5 additions and 3 deletions

View File

@ -484,4 +484,4 @@ fs.writeFileSync('out.js.map', result.sourceMap);
ECMAScript当前的所有提案可以在TC39的官方网站[Github.com/tc39/ecma262](https://github.com/tc39/ecma262)查看。
Babel转码器可以通过安装和使用插件来使用各个stage的语
Babel转码器可以通过安装和使用插件来使用各个stage的语

View File

@ -26,7 +26,7 @@ ES6模块不是对象而是通过`export`命令显式指定输出的代码,
import { stat, exists, readFile } from 'fs';
```
上面代码的实质是从`fs`模块加载3个方法其他方法不加载。这种加载称为“编译时加载”即ES6可以在编译时就完成模块编译效率要比CommonJS模块的加载方式高。当然这也导致了没法引用ES6模块本身因为它不是对象。
上面代码的实质是从`fs`模块加载3个方法其他方法不加载。这种加载称为“编译时加载”即ES6可以在编译时就完成模块加载效率要比CommonJS模块的加载方式高。当然这也导致了没法引用ES6模块本身因为它不是对象。
由于ES6模块是编译时加载使得静态分析成为可能。有了它就能进一步拓宽JavaScript的语法比如引入宏macro和类型检验type system这些只能靠静态分析实现的功能。
@ -394,7 +394,9 @@ function incCounter() {
counter++;
}
module.exports = {
counter: counter,
get counter() {
return counter;
},
incCounter: incCounter,
};
```