本周日【珠海源创会】一起聊聊:PingCAP分布式事务、支付宝移动端实践、GSBN技术框架选型,点此报名占座

china-liji / RexjsJavaScriptMIT

Watch 16 Star 48 Fork 7
加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
Rexjs - 是一款又快、又小、性价比极高的 JavaScript(ES6+) 语法的编译器! 展开 收起

http://www.rexjs.org

Loading...
ReadMe.md

Rexjs is a faster and smaller JavaScript(ES6+) compiler!


中文

Link

Install

  • NPM
npm install rexjs-api
  • Git
git clone https://github.com/china-liji/Rexjs.git
  • Download

Zip

rex.min.js - 234KB

rex-api.min.js - 230KB

rex-browser-helper.min.js - 18KB


Faster and Smaller

./dist/rex.min.js[1.6.48] only 234KB, smaller than others.


Usage

Web

<script src="./dist/rex.min.js"></script>

<!-- set the "type" attribute to define a module -->
<script type="text/rexjs">
	import "./module.js";

	export default class {};
</script>

<!--
	also, set the "src" attribute to reference a module,
	and add the "data-sourcemaps" attribute to enable sourcemaps.
-->
<script src="./module.js" type="text/rexjs" data-sourcemaps></script>

cross browser: ChromeFirefoxSafariIE9+.

Nodejs

  • ./ext.js
import path from "path";

export default function(filename){
	return path.parse(filename).ext;
};
  • ./index.js
import ext from "./ext.js";

// output ".js"
ext(__filename);
  • Command Line
rexjs ./index.js

Rexjs API

  • JavaScript
// import "rexjs-api" module

// Nodejs
let Rexjs = require("rexjs-api");

// Web Worker
importScripts("./dist/rex-api.min.js");
let Rexjs = self.Rexjs;

// Web: <script src="./dist/rex.min.js"></script>
let Rexjs = window.Rexjs;


// initialize parser
let es5Code = "", parser = new Rexjs.ECMAScriptParser();

// parse module from a file
parser.parse(
	// init file
	new Rexjs.File(
		// filename
		"./filename.js",
		// source
		"class Car {}"
	)
);

// returning the generated code
es5Code = parser.build();
  • HTML

This file provides generated code API, so reference it before run generated code in your browser.

<script src="./dist/rex-browser-helper.min.js"></script>

Other Packages


Thanks!

项目点评 ( 0 )

你可以在登录后,发表评论

搜索帮助

12_float_left_people 12_float_left_close