Giter Club home page Giter Club logo

babel-plugins's Introduction

babel-plugins

开发指南: ast在线预览 插件开发文档

simple

比较简单的插件

tree shaking

import { Button, Alert } from 'hy-store';
// 转换为
import Button from "hy-store/Button";
import Alert from "hy-store/Alert";

insert method

export default XPage({
    show(){
    },
    hide(){
    },
})

// 插入代码后
export default XPage({
    show(){
    },
    hide(){
    },
    showPop(){
        this.getComponent('pop').show();
    }
})

这个demo在写的过程中发现,实现成本蛮高的,主要是因为showPop方法的ast结构比较复杂。考虑到自己的需求只是动态插入代码,不需要做词法分析,考虑直接使用node的fs来实现。 在采用node写的时候最开始考虑读取一个模板文件,然后解析文件再在里面插入代码,但是不做词法分析还是很难弄。后面换了一个思路,把模板维护在代码里,通过独取配置生成不同的代码。具体代码见src/inertMethod/node.js

babel-plugins's People

Contributors

xszlq avatar

Watchers

 avatar

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.