<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Babel-StandaloneBabel 開源類庫

          聯(lián)合創(chuàng)作 · 2023-09-22 04:50

          babel-standalone 的設(shè)計(jì)初衷就是基于非 node.js 環(huán)境下使用 #Babel#。這里是原文介紹:

              babel-standalone is a standalone build of Babel for use in non-Node.js environments, including browsers. It's bundled with all the standard Babel plugins and presets.

          它已經(jīng)包含了Babel所有的插件,雖然本體容量很大(目前版本 6.7.7,未壓縮的js文件1.6MB,壓縮了則為641kb),不過這阻擋不了我們的對(duì)es6的熱愛,使用這個(gè)類庫,可以讓你實(shí)時(shí)在線轉(zhuǎn)換es6為js,而且支持babel提供的各種插件,而且最關(guān)鍵的是全特性支持,包括amd包裹,將import轉(zhuǎn)換為amd的require等等。比如,如下的es6代碼:

          import hello from "any!./hello.coffee";
          
          console.log(hello);
          
          let fun = () => console.log('hello es6')
          
          class Test {
          
          }
          
          module.exports = Test;

          他會(huì)轉(zhuǎn)換出以下的js:

          define(["module", "any!./hello.coffee"], function (module, _hello) {
            "use strict";
          
            var _hello2 = _interopRequireDefault(_hello);
          
            function _interopRequireDefault(obj) {
              return obj && obj.__esModule ? obj : {
                default: obj
              };
            }
          
            function _classCallCheck(instance, Constructor) {
              if (!(instance instanceof Constructor)) {
                throw new TypeError("Cannot call a class as a function");
              }
            }
          
            console.log(_hello2.default);
          
            var fun = function fun() {
              return console.log('hello es6');
            };
          
            var Test = function Test() {
              _classCallCheck(this, Test);
            };
          
            module.exports = Test;
          });

          怎么樣,看著是不是覺得有點(diǎn)小激動(dòng)呢?從此可以徹底擺脫old school的javascript,讓我們更優(yōu)雅的編寫js吧!

          安裝使用:bower install babel-standalone --save

          瀏覽 17
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲国产中文字幕啊啊啊扒开腿 | 国产精品99久久久久久成人 | 国产又粗又长又硬免费视频 | 成人毛片女人免费看 | 99国产精品99久久久久久 |