From eb8ce8fba53d5b318fe6e6b75eebe0c36d523388 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 29 Apr 2017 19:11:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/module-system.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/content/module-system.md b/content/module-system.md index af968b2..b03b0f9 100644 --- a/content/module-system.md +++ b/content/module-system.md @@ -114,7 +114,7 @@ define(function(require, exports, module) { ### ES6 模块 -EcmaScript6 标准增加了 JavaScript 语言层面的模块体系定义。[ES6 模块](http://es6.ruanyifeng.com/#docs/module)的设计思想,是尽量的静态化,使得编译时就能确定模块的依赖关系,以及输入和输出的变量。CommonJS 和 AMD 模块,都只能在运行时确定这些东西。 +ECMAScript6 标准增加了 JavaScript 语言层面的模块体系定义。[ES6 模块](http://es6.ruanyifeng.com/#docs/module)的设计思想,是尽量的静态化,使得编译时就能确定模块的依赖关系,以及输入和输出的变量。CommonJS 和 AMD 模块,都只能在运行时确定这些东西。 ```js import "jquery"; @@ -125,7 +125,7 @@ module "localModule" {} 优点: - 容易进行静态分析 -- 面向未来的 EcmaScript 标准 +- 面向未来的 ECMAScript 标准 缺点: @@ -172,7 +172,3 @@ require("./image.png"); 同时,为了能利用已经存在的各种框架、库和已经写好的文件,我们还需要一个模块加载的兼容策略,来避免重写所有的模块。 那么接下来,让我们开始 Webpack 的神奇之旅吧。 - - - - From 7d76f0849ff5bd48413cdae88fa5badd94b28a91 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 29 Apr 2017 19:12:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87=E5=BA=94=E4=B8=BA=20require?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/amd.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/amd.md b/content/amd.md index 43d4bf6..f8b31aa 100644 --- a/content/amd.md +++ b/content/amd.md @@ -30,7 +30,7 @@ define('myModule', ['jquery'], function($) { $('body').text('hello world'); }); // 使用 -define(['myModule'], function(myModule) {}); +require(['myModule'], function(myModule) {}); ``` 注意:在 webpack 中,模块名只有局部作用域,在 Require.js 中模块名是全局作用域,可以在全局引用。 @@ -73,4 +73,4 @@ define(function(require) { var $ = require('jquery'); $('body').text('hello world'); }); -``` \ No newline at end of file +```