JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q23420F
  • License MIT

module provider tools

Package Exports

  • xprovide

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xprovide) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

xprovide

模块提供工具,通过define定义模块,通过require获取模块.类似模块依赖注入工具.

Install

npm install xprovide

Usage

xprovide支持xboot引导方式下,作为项目插件使用.在xboot引导加载xboot.js文件时,能够通过xboot加载使用项目,项目引擎及项目插件下的xprovide.js文件.

// {cwd}/xprovide.js
// {cwd}/node_modules/{xxx engine}/xprovide.js
// {cwd}/node_modules/{xxx plugin}/xprovide.js

module.exports = (provider) =>{
    
    // 定义模块
    provider.define("id",["dep1","opt_dep1?"],(dep1,optDep1)=>{
        // 构建生成模块
        const model = {a:1,b:true,c:dep1,dd:optDep1};
        return model;
    });
    
    // 使用模块
    provide.require(["id"],(model)=>{
        console.log(model);
    });
};

Documentations

使用jsdoc生成注释文档

git clone https://github.com/kiba-zhao/xprovide.git
cd xprovide
npm install
npm run docs
open docs/index.html

n

License

MIT