• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

DanWahlin/ES6-Modules-Starter: Simple ES6 Modules starter project that uses Gulp ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

DanWahlin/ES6-Modules-Starter

开源软件地址(OpenSource Url):

https://github.com/DanWahlin/ES6-Modules-Starter

开源编程语言(OpenSource Language):

JavaScript 86.5%

开源软件介绍(OpenSource Introduction):

#ES6/ES2015 Modules Starter Project

Quick Start

  1. Install the global packages.

    npm install gulp -g

  2. Install the local packages for this demo.

    npm install

  3. Run Gulp:

    gulp

  4. Run the server, launch the browser, and transpile the ES6 to ES5 using Babel

    npm start

Details

The source code is located in the js folder and written in ES6/ES2015. We use gulp to transpile to ES5 using Babel. The gulp command runs the default Gulp task which transpiles the code and puts it in the dist folder and then watches for more changes. If you change the source, it will transpile again.

When you launch index.html (via npm start), SystemJS kicks in and looks for config.js for its settings. We tell SystemJS that the base URL for the code is in /dist. This is important so all import statements that were written assuming relative pathing in the src folder will still work. Finally, we tell SystemJS that import statements by default should assume they end with .js. This is accomplished by setting defaultExtension to js. See the code below for an example.

System.config({
    map: {
      main: 'dist' //Map "main" to the "dist" folder
    },
    packages: {
      //Define settings for loading files in "dist"
      dist: {
        main: 'main.js',
        format: 'system',
        defaultExtension: 'js'
      }
    }
});

We can now import the main starting module (main.js) like this:

System.import('main');

Now SystemJS gets /dist/main.js which in turn imports car and truck. Each of those import auto and extend it. SystemJS knows that the base URL is /dist and to assume an extension of .js, so it really gets /dist/car.js and /dist/truck.js which in turn get /dist/auto.js.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
joshuacaron/generator-angular2-gulp-webpack: (DEPRECATED)发布时间:2022-06-21
下一篇:
gberger/gulp-markdox: markdox plugin for gulp发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap