11 Star 35 Fork 14

溪山科技 / xsloader4j

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

一、项目介绍

让java web项目支持JavaScript ES6+、.scss、.less、.vue、.jsx、*.ts等。

二、版本

当前最新版本为 1.3.5

Version JDK 1.8

Github

码云

三、运行环境

  • JDK 8
  • servlet3
  • Windows,Linux,Mac
  • maven3

推荐IDE

  • idea

已测试环境

  • Jdk8
  • Windows10,windows server 2018
  • CentOS 7.4,7.5,7.8,7.9
  • 注意(WARNING):linux环境可能需要升级libstdc++.so
非root用户可以使用以下方式:
export LD_PRELOAD=/.../libstdc++.so.6.0.28

四、安装

  • spring boot版
<dependency>
    <groupId>com.xishankeji</groupId>
    <artifactId>xsloader4j-spring-boot-embed-starter</artifactId>
    <version>1.3.5</version>
</dependency>
  • 普通servlet版(项目以war包形式运行在tomcat、jetty等容器下)
<dependency>
    <groupId>com.xishankeji</groupId>
    <artifactId>xsloader4j-core</artifactId>
    <version>1.3.5</version>
</dependency>

五、配置

1、启动配置

在资源目录(如src/main/resources)下新建xsloader4j.properties:

  • xsloader.js加载器访问路径为:/contextPath/xsloader.js
xsloader.es6.polyfill=true
xsloader.es6.debug=true
xsloader.es6.name=default
xsloader.sourcemap=true
xsloader.es6.dealt.ignores=
xsloader.es6.dealt.static=
xsloader.es6.extensions=
xsloader.es6.detectBrowser=true
xsloader.es6.v8flags=
xsloader.conf.properties.staticUrlPrefix=https://xxxxx.cn/xxx
xsloader.conf.properties.prop1=xxx
xsloader.htmv.enable=false
xsloader.htmv.paths[0]=* to /WEB-INF/htmv/default.html
xsloader.htmv.paths[1]=/mobile/ to /WEB-INF/htmv/mobile.html
xsloader.react.autojs=true
xsloader.react.product=true
xsloader.htmr.paths[0]=* to /WEB-INF/htmr/default.html
xsloader.htmr.paths[1]=/mobile/ to /WEB-INF/htmr/mobile.html
xsloader.ctrl.enable=false
xsloader.embed.enable=true
  • xsloader.es6.polyfill:是否使用polyfill,为true时、会自动加载polyfill,默认为true。
  • xsloader.es6.debug:是否为debug模式,当为true时,文件修改后会重新进行转换。
  • xsloader.es6.name:目录名,默认default,当多个项目的临时为目录相同时、可避免v8加载失败。
  • xsloader.sourcemap:是否转换source map。
  • xsloader.es6.dealt.ignores:忽略转换的目录,用逗号分隔,如“/static/lib1,/static/lib2”。
  • xsloader.es6.dealt.static:静态资源在资源目录下的路径(在spring boot嵌入式版本中使用),如“/static”,多个用逗号分隔。
  • xsloader.es6.extensions:脚本后缀,可以省略里面指定的后缀名(但路径中必须含有/分隔符),默认为".js,.vue,.jsx,.ts,.jsr,.jtr,/index.js,/index.vue,/index.jsx,/index.ts,/index.jsr,/index.jtr" ,且取值只能是[.js,.vue,.jsx,.ts,.jsr,.jtr,/index.js,/index.vue,/index.jsx,/index.ts,/index.jsr,/index.jtr]中的值
  • xsloader.es6.detectBrowser:是否根据浏览器版本,进行不同级别的js转换。默认true。
  • xsloader.conf.properties.xxx:参数可直接在xsloader配置文件里使用#{propName}进行引用。
  • xsloader.htmv.enable:是否启用htmv,默认为false
  • xsloader.htmv.paths:配置默认的html模板(可选)。classpath:开头表示资源目录,其他表示在web路径下(通过servletContext.getRealPath获取)
  • xsloader.conf.forceCacheSeconds:配置被浏览器强制缓存的时间
  • xsloader.es6.versionAppendTag:如果设置了该标记,当文件变化后,会在该标记后添加文件版本(支持的文件为所有需要转换的文件);该标记右边加,表示需要前置逗号;
  • xsloader.react.autojs:默认为true,是否导入内置的react依赖。
  • xsloader.react.product:默认为true,使用内置react依赖时,是否为产品模式。
  • xsloader.ctrl.enable:默认为true,是否在响应的配置里添加控制参数。
  • xsloader.embed.enable:默认为true,全局的//!embed开关。

2、xsloader配置

在资源目录(如src/main/resources)下新建xsloader-conf.js,参考内容如下:

  • 该配置文件的访问路径为:/contextPath/xsloader.conf
  • 注意此配置文件为JS版的json对象,支持JS脚本。
  • 关于此文件配置的更详细说明见:xsloader模块加载器配置
  • 通过#{propName}引用配置参数,contextPath默认为当前servlet的context path参数。
  • 此配置文件缓存时间为30秒,通过urlArgs可以控制其他资源的版本,从而有效避免缓存问题。
{
	"properties":{
		"contextPath":"#{contextPath}",
		"staticUrlPrefix":"#{staticUrlPrefix}",
		"libReplace":{
               "libxs/":{
                    "replace":"${staticUrlPrefix}/libxs/"
               },
               "lib/":{
                       "replace":"${staticUrlPrefix}/lib/"
              },
               "libui/":{
                     "replace":"${staticUrlPrefix}/libui/"
             }
         }
	},
	"main":{
		getPath:function(dataMain){
    		return dataMain||"./es-main/{name}.js";
    	},
		"before":function(){
			console.log("before:" + name);
		},
		"after":function(){
			console.log("after:" + name);
		}
	},
	"chooseLoader":function(localConfig){
		var path=this.getPagePath();
        if(xsloader.startsWith(path,"/test1/")){
            return "test1";
        }else if(xsloader.startsWith(path,"/test2-no-vue/")){
            return "test2-no-vue";
        }else{
            return "test1";
        }
	},
	"loader":{
		"test1":{
            "baseUrl":"${contextPath}/",
            "modulePrefix":"$[libReplace]",
             "urlArgs":{
                "*[${contextPath}/":"v=20200130-02",
                "*[libxs/":"v=20200129-3",
                "*[lib/":"v=190109-26",
                "*[libui/":"v=190109-26"
            },
            "paths":{
                    "vue":"static/vue/vue.min.js"
            },
            "deps":{
				"*":"vue"//当有vue组件或jsx语法时,一定要先加载vue模块
            }
        },
		"test2-no-vue":{
            "baseUrl":"${contextPath}/",
            "modulePrefix":"$[libReplace]",
             "urlArgs":{
                "*[${contextPath}/":"v=20200130-02",
                "*[libxs/":"v=20200129-3",
                "*[lib/":"v=190109-26",
                "*[libui/":"v=190109-26"
            },
            "paths":{

            },
            "deps":{

            }
        }
	},
	"getPagePath":function(){
		var path=location.pathname.substring(this.properties.contextPath.length);
		return path;
	},
	"sporter":"${contextPath}/",
	"fromPath":function(path){
		return location.protocol+"//"+location.host+this.sporter+path;
	},
     "beforeDealProperties":function(){

     }
}

六、使用与demo运行

  • xsloader脚本引入:

<script src="../xsloader.js" data-conf2="./xsloader.conf" async="async" type="text/javascript" charset="utf-8"></script>
  • 配置文件引入:直接在xsloader.js的script标签上,设置属性data-conf2
data-conf2="./xsloader.conf"
  • 详细例子可以参考demo-servlet项目

  • demo-servlet为普通servlet项目,执行jetty:run或tomcat7:run的maven插件,可运行demo。 访问地址:http://localhost:8070/index.html

  • demo-spring-boot-servlet为spring boot servlet项目

  • demo-spring-boot-main为spring boot main函数项目(普通java项目)

  • test1目录结构:

/test1/
/test1/index.html
/test1/es-main/index.js
/test1/es-main/vue/comp1.vue
/test1/es-main/jsx/comp2.jsx

index.html

<!DOCTYPE html>
<html>

<head>
    <title>测试1</title>
    <meta charset="UTF-8">
    <!--引入xsloader脚本-->
    <script src="../xsloader.js" data-conf2="./xsloader.conf" async="async" type="text/javascript"
            charset="utf-8"></script>
</head>

<body>
<div id="vue-app">

</div>
<script id="app-template" type="text/x-template">
    <div style="text-align:center;">
        <comp1/>
        <comp2/>
        <jsx :x="getVnode" id="123" :name="'name'" @click="onClickVnodex" class="test-class"/>
    </div>
</script>
</body>

</html>

comp1.vue

<template>
    <div>
        <h1 :class="{...classNames}">{{info}}</h1>
        <p>$thiz.getUrl():<span style="color:gray;">{{$thiz.getUrl()}}</span></p>
        <p>$thiz.getUrl("../index.js"):<span style="color:gray;">{{$thiz.getUrl("../index.js")}}</span></p>
    </div>
</template>

<script>
    export default{
        data(){
            return {
                   info:"HelloWorld",
                   classNames:{
                        teatA:true,
                        testB:true,
                   }
            }
        }
    }
</script>

<style lang="scss" scoped="true">
    &{
        margin:2em;
    }
</style>

comp2.jsx


export default {
	render(){
		return (
               <div
               style={{
                   margin:"2em auto"
               }}>
                   <p>这是一个jsx语法的组件</p>
               </div>)
	}
}

index.js

import "css!static/test.scss";//不是以“.”开头的路径相对于baseUrl
import Vue from "vue";
import comp1 from "./vue/comp1.vue";//需要加入文件后缀,当前目录需要用"./"、否则是相对于baseUrl

console.log(thiz.getUrl());//http://localhost:8070/test1/es-main/index.js?v=20200130-02
console.log(thiz.getUrl("./lib/other.js"));//http://localhost:8070/test1/es-main/lib/other.js?v=20200130-02

new Vue({
    el:"#vue-app",
    template:"#app-template",
    methods:{
        getVnode(){
            return (<p on={{click:this.onClickp}}>
                来自函数
            </p>);
        },
        onClickVnodex($event){
            alert("onClickVnodex:"+$event);
        },
        onClickp($event){
            alert("onClickp:"+$event);
        }
    },
    components:{
        comp1,
        comp2:()=>import("./jsx/comp2.jsx")//支持异步加载
    }
});

七、其他说明

1、打包说明

  • 打包成指定系统的war包后会增加20Mb左右,例如打包到linux系统下运行,可在pom.xml的plugins里排除windows与mac的j2v8依赖包:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.2</version>
            <configuration>
                <packagingExcludes>
                    <!--排除j2v8 windows与mac下的依赖包,默认打包后在linux下运行、减小压缩包-->
                    WEB-INF/lib/j2v8_win**.jar,WEB-INF/lib/j2v8_macosx**.jar,
                </packagingExcludes>
            </configuration>
        </plugin>
    </plugins>
</build>
  • 若在mac下运行,需要自行加入依赖:

<dependency>
    <groupId>com.eclipsesource.j2v8</groupId>
    <artifactId>j2v8_macosx_x86_64</artifactId>
    <version>4.6.0</version>
</dependency>

2、引入其他库

  • 引入的第三方库需要遵循AMD规范
  • 一般打包的三方umd模块可以正常工作,可以参考项目demo-servlet
  • 注意:import其他组件或模块,可省略的后缀见xsloader.es6.extensions配置

3、代码转换说明

1.1)*.js

  • 语法支持到es2018
  • 支持jsx语法
  • 某些IDE暂不支持jsx语法,可以用如下方式勉强避免错乱:(编译前,java后台会把Vue文件里的`\jsx与\jsx`删除)
  • 内置<jsx>组件(需要全局配置vue模块),通过x属性(返回jsx对象的函数或jsx对象,支持字符串等内容)可以直接显示编译后的jsx对象
<div>
    <jsx :x="xxx" />
</div>
  • 自动判断js文件语法,当具有以下语句之一时,则会进行转换:
let ...
import ...
export ...
const ...

thiz变量指向当前模块,更多请见xsloader的this

  • 当有vue组件、jsx语法或htmv时,需要在配置文件的loader里设置vue2依赖:
{
  "paths": {
    "vue": "你的vue2的路径/vue.min.js"
  },
  "deps": {
    "*": "vue"
    //当有vue组件、jsx语法或htmv时,一定要先加载vue模块
  }
}

1.2)*.ts

  • typescript脚本;
  • 不支持jsx语法;

2)*.vue


<template>

</template>
<script>

</script>

<style lang="scss" scoped="true">

</style>
  • <script>支持的js语法同*.js
  • 支持jsx语法
  • 某些IDE暂不支持jsx语法,可以用如下方式勉强避免错乱:(编译前,java后台会把Vue文件里的`\jsx与\jsx`删除)
return (`\jsx
    <div>HelloJSX</div>
\jsx`)
  • 在Vue实例上添加$thiz属性(同*.js里的thiz变量),表示当前vue所在的模块对象。
  • 在Vue实例上添加$keepVueStyle属性,默认为false,表示销毁时、对应的style也会被销毁。
  • 在Vue实例上添加$destroyVueStyle()函数,用于销毁style;当使用Vue的<transition>过渡动画时,可设置其包裹的组件的$keepVueStyle=true ,在动画结束后手动调用此函数销毁style。
  • <style>:lang属性支持default(即css)、scss(推荐,也是默认值)、less;可包含多个style标签;scoped:true(scoped),false
1、注意这里scoped为true时,只是在根元素上添加一个随机的class。
2、<style>标签支持多个
  • 当有vue组件、jsx语法或htmv时,需要在配置文件的loader里设置vue2依赖:
{
  "paths": {
    "vue": "你的vue2的路径/vue.min.js"
  },
  "deps": {
    "*": "vue"
    //当有vue组件、jsx语法或htmv时,一定要先加载vue模块
  }
}

3.1)*.htmv

  • 该文件实际是一个vue格式的文件,更多说明见*.vue
<!--settings:
{
    title:"文档标题",
    noLoadingMask:false,
    heads:['<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">']
}
-->
<template>

</template>
<script lang>

</script>

<style lang="scss" scoped="true">

</style>
  • scriptlang支持typescriptts
  • 通过settings注释里的json格式对文档进行设置:
  1. title:设置文档标题
  2. noLoadingMask:当此值设置为true时,将去掉id为loading-mask的加载框。
  3. heads:用于添加到<head>标签中
  • 通过浏览器可以直接访问htmv文件(java端会自动转换),参考demo-servlet的test1/index.htmv。
  • 当有vue组件、jsx语法或htmv时,需要在配置文件的loader里设置vue2依赖:
{
  "paths": {
    "vue": "你的vue2的路径/vue.min.js"
  },
  "deps": {
    "*": "vue"
    //当有vue组件、jsx语法或htmv时,一定要先加载vue模块
  }
}
  • 通过设置xsloader.htmv.enable=true来启用htmv

3.2)*.htmr

  • 该文件实际是一个jsr格式的文件,更多说明见*.jsr
  • htmr文件无<template>,html注释<!---->后面需有换行,<style>标签前面需要有换行。
  • js代码可以省略script标签,style标签必须放在js代码后面,js代码里不能出现<style>标签与html注释<!---->
<!--settings:
{
    title:"文档标题",
    heads:['<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">']
}
-->
export default <h1>Hello, world!</h1>;

<style lang="scss" scoped="true">

</style>
  • scriptlang支持typescript
  • 通过settings注释里的json格式对文档进行设置:
  1. title:设置文档标题
  2. heads:用于添加到<head>标签中
  • 通过浏览器可以直接访问htmr文件(java端会自动转换)。
  • 通过设置xsloader.htmr.enable=true来启用htmr
  • xsloader.react.autojs为false需要配置reactreact-dom依赖

4)*.scss

支持scss语法

5)*.less

支持less语法

6)*.jsx

  • 效果与*.js文件效果是一样的
  • 当有vue组件、jsx语法或htmv时,需要在配置文件的loader里设置vue2依赖:
{
  "paths": {
    "vue": "你的vue2的路径/vue.min.js"
  },
  "deps": {
    "*": "vue"
    //当有vue组件、jsx语法或htmv时,一定要先加载vue模块
  }
}
  • 属性、class、事件等设置见Vue的$createElement
<img attrs={{src:""}} class="test" style="" />

详细属性:
{
  //class:接受一个字符串、对象或字符串和对象组成的数组
  'class': {
    foo: true,
    bar: false
  },
  //style:接受一个字符串、对象,或对象组成的数组
  style: {
    color: 'red',
    fontSize: '14px'
  },
  //普通的HTML特性
  attrs: {
    id: 'foo'
  },
  //组件prop
  props: {
    myProp: 'bar'
  },
  //DOM属性
  domProps: {
    innerHTML: 'baz'
  },
  // 事件监听器在`on`属性内,
  // 但不再支持如`v-on:keyup.enter`这样的修饰器。
  // 需要在处理函数中手动检查keyCode。
  on: {
    click: this.clickHandler
  },
  // 仅用于组件,用于监听原生事件,而不是组件内部使用
  // `vm.$emit` 触发的事件。
  nativeOn: {
    click: this.nativeClickHandler
  },
  // 自定义指令。注意,你无法对 `binding` 中的 `oldValue`
  // 赋值,因为 Vue 已经自动为你进行了同步。
  directives: [
    {
      name: 'my-directive',
      value: '2',
      expression: '1 + 1',
      arg: 'foo',
      modifiers: {
        bar: true
      }
    }
  ],
  //作用域插槽的格式为
  //{ name: props => VNode | Array<VNode> }
  scopedSlots: {
    default: props => createElement('span', props.text)
  },
  //如果组件是其它组件的子组件,需为插槽指定名称
  slot: 'name-of-slot',
  // 其它特殊顶层属性
  key: 'myKey',
  ref: 'myRef',
  //如果在渲染函数中给多个元素都应用了相同的 ref 名,
  //那么`$refs.myRef` 会变成一个数组。
  refInFor: true
}

7).jsr,.jtr

  • *.jtr后缀的语言为typescript 代码为react模式,脚本语法同js,jsx属性见react(不同于vue的)。

8)文件合并说明

可以通过//!embed将脚本(只对需要进行代码转化的有效)直接内嵌到当前文件。

  • 支持递归
  • 注意:后缀名不能省略
//!embed
import "./embed/a.js";
import "./embed/b.js";
//!embed

9)sourcemap源码

转换的源码可在浏览器控制台Sources标签下,对应页面的/$$xs-sources$$/路径下找到,支持脚本断点调试。

4、polyfill

您可能需要使用polyfill来更好的使用es6+代码,如Map、array.includes、string.startsWith、async/await等

cnpm install --save @babel/polyfill
在node_modules/下对应目录下去复制polyfill.js文件

5、xsloader.js说明

该插件是基于AMD协议开发的模块加载器(借鉴了requirejs,但从1.2.x开始进行了重构),支持异步模块加载、插件开发、更灵活的依赖配置、脚本版本配置等。

内置插件包括:css、image、json、text、request、ifmsg等。

xsloader-wiki

6、直接获取源码

在请求地址上加入__source=true则直接返回源码。

八、发布记录

v进行中

1.3.5 2022/01/10

  1. 升级babel版本为7.15.3
  2. 升级vue版本为2.6.14
  3. 使用javetv8引擎;
  4. 完善es6代码的判断;
  5. //!embed嵌入模式的开始标签支持//!embed:all,用于递归嵌入所有相对页面(需含有后缀);
  6. 完善vue模板文件解析;
  7. jsx支持Promise
  8. htmv增加settings.noLoadingMask属性;

1.2.108 2021/08/24

  1. 完善xsloaderifmsg连接流程;
  2. xsloader.appendArgs2Url(url, urlArgs, encoding = false)增加encoding选项;
  3. xshttp增加rhandle属性;
  4. 解决//!embed嵌入模式不支持./xxx!插件的问题;
  5. 完善xsloadercss插件样式加载顺序;
  6. 修复xsloader的插件willCache处理问题;

1.2.97 2021/07/29

  1. ifmsgclient加入request(返回Promise)与onRequest(data,resolve,reject);
  2. 修复.vue<template>里出现<script>报错的问题;
  3. 修复xsloader.clone的bug;
  4. xsloaderifmsg加入超时次数判断;
  5. xsloader增加xsloader.FilesPart;xshttp支持xsloader.FilesPart;
  6. 加入//!embed特性,用于将多个脚本合并到当前文件;使用webpack-sourcessourcemap进行合并;
  7. 修复缓存判断错误的bug;
  8. 修复export xxx from "..."不支持的问题;
  9. 加入xsloader.ctrl.enable属性用于控制xsloader.js脚本的更新缓存问题;
  10. 修复xshttp上传file对象上传两次的问题;
  11. 不转换vue文件内部<style>标签;

v1.2.68 2021/06/22

  1. 完善xsloaderhtmv的支持;
  2. 升级babel7.14.3
  3. 支持typescript,后缀为.ts
  4. 完善xsloader,当导入cssscsssassless后缀名的样式时,自动添加css!前缀
  5. 支持react,后缀为.jsr;支持typescript的react,后缀为.jtr
  6. 支持*.htmr文件,可直接通过浏览器访问;
  7. 修复vue文件解析标签偏移问题;
  8. 增加xsloader4j-maven-plugin插件;
  9. 修复scss编译时@import路径处理bug;

v1.2.49 2021/05/14

  1. 升级babelv7.13.15;
  2. 增加配置xsloader.es6.detectBrowser,默认为true,用于开启浏览器版本判断,对js进行不同级别的转换;
  3. 升级polyfill7.12.1
  4. 加入xsloader.__ignoreCurrentRequireDep属性,配合xsloader,优化处理速度;
  5. xsloader.htmv.paths:配置默认的html模板(可选)。classpath:开头表示资源目录,其他表示在web路径下(通过servletContext.getRealPath获取);
  6. 完善xsloadergetUrl,提供的相对地址上的参数优先级更高;

v1.2.36 2021/03/26

  1. staticInclude支持移除特殊标记;
  2. 增加配置xsloader.conf.forceCacheSeconds,用于设置配置文件被浏览器强制缓存的时间;
  3. 增加配置xsloader.es6.versionAppendTag,用于自动加版本号;
  4. 完善自动版本号,自动后缀名的文件也支持自动版本号;
  5. 完善ScriptEnv
  6. 修复xsloader.queryParam获取参数为空字符串时没有使用默认值的问题;
  7. 完善ifmsg,页面关闭时会主动调用close;
  8. xsloaderservice支持urlArgs参数,用于设置通用的版本参数;

v1.2.19 2021/01/04

  1. 加入IConfigFileCheck
  2. 修复xshttp在multiPart为true下,参数为对象时未能进行转换的bug;
  3. 完善xsloader.es6.extensions配置,默认为.js,.vue,.jsx,/index.js,/index.vue,/index.jsx
  4. 编译js、jsx、vue时,加入xsloader.__currentPath
  5. 加入require().setTag(),便于加载依赖报错时提供tag信息;
  6. 修复xsloader.jstry!插件加载模块失败之无法继续执行的bug;
  7. 修复xsloader.jsdealPathMayAbsolute协议处理bug;
  8. xsloader.js的配置中加入aliasPaths属性,可配置模块别名,别名格式不以"."开头,可出现"/"字符;
  9. xsloader.jsifmsgServer增加单例模式;

v1.2.6 2020/11/06

  1. 完善ScriptEnv
  2. ScriptEnv的java抛出异常给js后,js端也会收到异常;
  3. 对于js文件,某些IDE暂不支持jsx语法,可以用如下方式勉强避免错乱:(编译前,java后台会把Vue文件里的`\jsx与\jsx`删除)
  4. default.html加入<meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/> ,阻止使用兼容模式;

v1.2.1 2020/10/07

  1. 加入spring boot相关demo;
  2. 升级babel与polyfill;
  3. 转换的js支持到es2018;
  4. 增加__source参数,若__source=true则直接返回源码;
  5. 增加语法或特性测试例子(demo-servlet/src/main/webapp/lang/);

v1.1.60 2020/09/14

  1. 解决使用V8时,Map或Collection转换成V8的对象或数组无法释放的问题;
  2. 增加xsloader.es6.name配置;
  3. 增加xsloader.hasDefined(name)判断模块是否已经定义完成(此模块已被执行);

v1.1.55 2020/08/21

  1. 完善ScriptEnv
  2. 编译js与vue的警告日志中打印url;
  3. <jsx>支持字符串等内容;
  4. 修复js代码从es6+变为es5时,仍然被判断为es6的问题;

v1.1.52 2020/07/10

  1. xsloader的invoker增加scriptSrc(),包含地址参数的;
  2. htmv的settings配置中增加heads属性;

v1.1.49 2020/06/24

  1. 解决ifmsg重复onConnect的问题;
  2. 解决ifmsg的client实例作为vue变量时,导致iframe跨域问题的bug;
  3. 完善<jsx>,x属性可以为空;

v1.1.46 2020/05/18

  1. xsloader.js的模块对象增加appendArgs(url,forArgsUrl);
  2. vue模板实例添加$thiz变量,表示当前vue模块;
  3. 支持*.htmv,用于直接显示vue模板;
  4. 修复xsloader.js的xsloader4j-server-bridge依赖vue(但vue还暂未加载),提前注册<jsx>组件导致缺少vue报错的bug;
  5. xsloader.js 支持ifmsg

v1.1.31 2020/5/7

  1. 完善vue模板的编译;

v1.1.29 2020/5/2

  1. 修复loading的bug;

v1.1.27 2020/4/29

  1. 完善demo-servlet,加入vant、mand-mobile测试例子(也支持ant-design-vue);
  2. 默认支持自动后缀:*.vue,*.jsx,*.js
  3. 加入ScriptEnv;
  4. 修复一些bug;

v1.1.19 2020/4/10

  1. 内置<jsx>组件,方便显示jsx;

v1.1.16 2020/3/31

  1. 修复vue模板中无法使用annonymous变量的问题;
  2. 修复后台转换时console.assert判断错误问题;
  3. 修改缓存文件保存目录;
  4. 完善异常处理;
  5. 修复某些js文件在静态导入其他子文件的情况下,导致缓存失效的问题;
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

让java web项目支持JavaScript ES6+(ES2015,ES2016,ES2017,ES2018)、*.scss、*.less、*.vue、*.jsx。 展开 收起
Java 等 3 种语言
Apache-2.0
取消

发行版 (4)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/xishankeji/xsloader4j.git
git@gitee.com:xishankeji/xsloader4j.git
xishankeji
xsloader4j
xsloader4j
master

搜索帮助