1.0.3 • Published 6 years ago

ys-loader v1.0.3

Weekly downloads
20
License
-
Repository
github
Last release
6 years ago

ys-loader

YS 架构之基础辅助加载模块。

Install

npm i --save ys-loader

Usage

const { FileLoader, ContextLoader, util } = require('ys-loader')

FileLoaderContextLoader都具有如下的属性特征:

属性类型默认值说明
directorystringnull需要解析文件的文件夹
matcharray['**/*.js']匹配规则,规则详见 npm:globby 模块
ignorearray[]过滤某种规则的文件,规则详见 npm:globby 模块
lowercaseFirstbooleantrue解析出来文件变量的首字母是否小写
caseStylestringcamel变量规则模式,支持 lower upper camel 三种
initializerfunctionnull初始化自定义变量以及内容结构的方法
callbooleantrue是否执行注入
injectobjectnull注入对象,需要开启call选项
overridebooleanfalse是否覆盖变量,如果遇到冲突
targetobjectnull结果继承到target对象上
runtimefunctionnull在处理class类型文件模块的时候,我们将该模块编译的方式

FileLoader

文件加载器,不编译,如果需要编译,使用initializer属性。

new FileLoader(options).load();

ContextLoader

对象加载器,会编译class文件模块,如果自定义编译方式,请使用runtime属性

new ContextLoader(options).load();

Utils

const {
  getProperties,
  getExports,
  defaultCamelize,
  getInstance
} = utils;

具体各自用法请看源码。

License

It is MIT licensed.