GithubHelp home page GithubHelp logo

plover-module-resolver's Introduction

plover-module-resolver

NPM version build status Test coverage

【核心模块】 plover模块加载和解析器

Usage

const path = require('path');
const ModuleResolver = require('plover-module-resolver');

const options = {
  development: true,
  applicationRoot: path.resolve('./'),
  libModulesDir: path.resolve('./node_modules'),
  modulesDir: path.resolve('./modules')
};

const moduleResolver = new ModuleResolver(options);

console.log(moduleResolver.list());  // 模块列表

plover-module-resolver先加载libModulesDir目录下的plover库模块,然后再加载modulesDir目录中的plover应用模块。

Note

某些情况下需要对库模块进行自定义,此时在modulesDir中定义同名模块,plover-module-resolver将会覆盖libModulesDir中模块。

Options

development

是否为开发模式,默认为非开发模式。

applicationRoot

应用根目录。

libModulesDir

plover库模块目录,默认为applicationRoot应用根目录下的node_modules目录。

package.json中定义了plover信息的模块为plover库模块。

{
  "name": "plover-xxx",
  "version": "0.1.0",
  "description": "xxx",
  "plover": {
    "plugin": "lib/plugin.js"
  }
}

modulesDir

plover应用模块目录,默认为applicationRoot应用根目录下的modules目录。

Methods

list

返回模块列表。

loadModule

加载模块信息。

moduleResolver.loadModule(path.resolve('./tempModules/test'));
parameters
name description
path 模块根目录
options 配置可选项
  • options配置可选项:
name description
namespace 匿名模块的名字空间
ensure 是否校验模块package.json中必须存在plover配置
silent 当解析模块不存在时,是否忽略,若为false,系统将抛出异常

pushModule

添加模块信息。

moduleResolver.pushModule({
  name: 'test',
  version: '0.0.1',
  path: path.resolve('./tempModules/test'),
  view: {
    template: 'views/view.art',
    js: 'js/view.js',
    css: 'css/view.css'
  },
  // ...
});
parameters
name description
info 模块信息

resolve

返回指定名称的模块信息。在开发模式中每次都重新加载模块信息(隔间时间为3秒), 在生产环境时直接从缓冲中获取。

parameters
name description
name 模块名称

vertify

验证模块依赖是否兼容, 如果有问题则会抛出Error。若在package.jsonplover中定义了dep依赖模块信息,此时将会校验plover模块依赖的版本是否兼容。

plover-module-resolver's People

Contributors

bencode avatar ipluser avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

web17077

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.