Giter Site home page Giter Site logo

edpx-babel's Introduction

edpx-babel

基于babel6的edp插件。

Install

$ npm i edpx-babel babel-preset-browser --save-dev

Usage

Webserver(edp-webserver-config.js)

var babel = require('edpx-babel/lib/babel-handler');

// 注意babel函数的参数是babel6的配置项目,所有参数都可以在babel官网上查到
// http://babeljs.io/docs/usage/options/
exports.getLocations = function () {
    
    return [
        {
            location: /\.js($|\?)/,
            handler: [
                babel({
                    presets: ['babel-preset-browser']
                })
            ]
        }    
    ];
};

Builder(edp-build-config.js)

var BabelProcessor = require('edpx-babel/lib/BabelProcessor');

// 注意babel函数的参数是babel6的配置项目,所有参数都可以在babel官网上查到
// http://babeljs.io/docs/usage/options/
exports.getProcessors = function () {
    
    var babelProcessor = new BabelProcessor({
        files: ['*.es'],
         compileOptions: {
             presets: ['babel-preset-browser']
         }
    });
};

Options

项目使用的配置与babel6完全一致,可以参考babel6配置手册

推荐:

  • 如果需要兼容IE6-8之一:可以使用babel-preset-browser预设
  • 如果只需要兼容IE9+或者移动:可以使用babel-preset-mobile(TODO)

在ES6的特性选择上,babel-preset-browser会剔除所有依赖ES5的Getter/Setter或者getPrototypeOf函数的功能。其它特性是基本一致的。

edpx-babel's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edpx-babel's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.