-
支持多版本共存。
-
能够侵入到module-federaion的shared。
-
shareScopes抽象出了shareScope、pkgname、version、requiredVersion、singleton等选项来做到比较精细的控制依赖, 能满足引入一个模块所需的所有条件。
-
演示
一共只有两个API: setShared、getShared, 易于使用
import {setShared, getShared} from "module-shared-pool" setShared({ name: "lodash", version: "1.0.0", async get() { return { v: "lodash 1.0" } } }) setShared({ name: "lodash", version: "1.5.2", async get() { return { v: "lodash 1.5" } } }) setShared({ name: "lodash", version: "2.0.0", async get() { return { v: "lodash 2.0" } } }) setShared({ name: "lodash", version: "latest", async get() { return { v: "lodash latest" } } }) console.log("requiredVersion is default *", await getShared({name: "lodash"})) console.log("requiredVersion is 1", await getShared({name: "lodash", requiredVersion: "1"})) console.log("requiredVersion is ^1.4", await getShared({name: "lodash", requiredVersion: "^1.4"})) console.log("requiredVersion is beta", await getShared({name: "lodash", requiredVersion: "2"})) console.log("requiredVersion is latest", await getShared({name: "lodash", requiredVersion: "latest"})) console.log("requiredVersion is beta", await getShared({name: "lodash", requiredVersion: "beta"}))
module-shared-pool
1.0.4 • Public • PublishedReadme
Keywords
nonePackage Sidebar
Install
npm i module-shared-pool
Weekly Downloads
0
Version
1.0.4
License
ISC
Unpacked Size
5.47 kB
Total Files
5