lianhanlin-modular weekly downloads statistics
By harry-lien · npm · Webpack plugins
文件路径即依赖网格 (Mesh),零装配、零反射的轻量 TypeScript 全栈 Path-IoC 模块引擎。内置 Vite 与 Webpack 官方插件,支持 DAG 拓扑排序、80% CPU 提速静态图预编译与 100% 类型自动生成。
lianhanlin-modular has 119 recorded weekly downloads on npm, a decrease of 9.8% over the past 30 days, ranking #2585 of 3,247 tracked listings.
About lianhanlin-modular
📦 项目标识与包名对照 (Identity Mapping):
- NPM 安装包名:
lianhanlin-modular(npm i lianhanlin-modular)- 核心架构思想:
Path-IoC(基于物理路径契约的控制反转与依赖查找引擎)- 核心物理单元:
Mesh(对应 Spring 中的 Bean)- 虚拟模块导入:
virtual:modular-container(构建插件在内存中全自动收集导出的 Mesh 注册表)
💡 什么是 Path-IoC (IoC-DL)?:告别原始
import泥潭与 Java 式重型黑盒 DI(如 NestJS)在 JS 异步生态里的死锁/反射包袱。Path-IoC 采用 Dependency Lookup (依赖查找) 范式——路径即契约,静态图预编译,原生async/await支持。零反射、零概念包袱,组件面向container极简解构。
🌟 典范应用模式直达:
⚡ 5 秒上手 (5-Second Quick Start)
1. 插件配置(以 Vite 为例;Webpack / Rspack 配置 👉 点击跳转)
vite.config.ts:
import { defineConfig } from "vite";
import modularType from "lianhanlin-modular/plugin-vite";
export default defineConfig({ plugins: [modularType()] });
2. 目录结构
src/
├── modules/
│ ├── math/add/index.ts # 计算 Mesh
│ ├── math/isEven/index.ts # 校验 Mesh
│ └── app/runner/index.ts # 业务汇聚 Mesh (依赖 add 与 isEven)
└── index.ts # 项目编译构建入口 (仅一行代码)
3. 项目编译构建入口 (src/index.ts)
/// <reference types="lianhanlin-modular/virtual" />
import { createModularContainer } from "virtual:modular-container";
// 🚀 项目编译构建入口:控制权全权交由容器!拓扑引擎自动解析依赖网格并链式唤醒运行
await createModularContainer();
4. 编写 Mesh (src/modules/...)
💡 类型提示:
ModularContainer类型由 Vite / 构建插件全自动根据目录生成并注入,零手动导入。
// src/modules/math/add/index.ts
export const main = () => (a: number, b: number) => a + b;
// src/modules/math/isEven/index.ts
export const main = () => (num: number) => num % 2 === 0;
// src/modules/app/runner/index.ts (业务汇聚 Mesh)
export const main = (container: ModularContainer) => {
const { add, isEven } = container;
const sum = add(3, 5);
const evenText = isEven(sum) ? "Even" : "Odd";
console.log(`🚀 [Quick Start] Sum: ${sum}, IsEven: ${evenText}`);
};
// 💡 顺序控制:声明 order 为无穷大 (Infinity),保证在无显式拓扑约束的模块中最后唤醒
// 亦可替换为显式拓扑依赖:export const dependencies = ["add", "isEven"];
export const order = Number.POSITIVE_INFINITY;
🏛️ 核心设计哲学 (Architecture Philosophy)
Path-IoC 的底层设计建立在 4 大高维架构哲学之上:
1. 💡 约定优于配置 + 闭包工厂 (Convention Over Configuration)
拒绝伪注解与重型 @Injectable() 装饰器,保持模块 100% 纯 TypeScript 函数与闭包纯洁性。依靠构建工具链在编译期进行隐式目录契约挂载,零配置开箱即用。
2. 🏷️ 目录即契约,路径即寻址 (Directory as Contract & Path Address)
- 目录即契约 (Directory as Contract):抛弃显式声明与
@Inject('token')伪元数据,物理目录路径即为全局服务契约 Token。短名称提供极致直觉的无感解构 (const { add } = container),全限定路径提供确定性的歧义消除; - 路径即寻址 (Pattern Discovery):路径不仅是坐标,更是服务发现的天然索引。支持基于路径前缀模式的动态批量收集与副作用扫描(如全动态路由收集
allRoutes、ORM Schema 自动挂载entities)。
3. ⚡ 零运行期反射与静态图编译 (Zero-Reflection & Precompiled Graph)
彻底摆脱 reflect-metadata 重型反射包袱。架构上将静态图编译 (compileModuleGraph) 与 动态容器填充 (instantiateModuleContainer) 彻底分离,服务启动时仅编译一次拓扑图,高并发请求下零重复拓扑计算,提升 80% CPU 性能。
4. 🔒 循环依赖秒级定位 (不内置与不推荐隐式解环)
不内置也不推荐隐式自动解环(主要避免 async 异步初始化死锁风险与切面模块时序紊乱)。一旦误写循环依赖,框架在启动瞬间(Fail-Fast)立刻拦截并精准打印出完整闭环调用链(如 /A -> /B -> /C -> /A),保证 100% 确定性(👉 点击查看 FAQ 深度解析)。
☯️ 架构范式:前端单例 vs 后端多例 (Practices Matrix)
Path-IoC 本身是一个纯粹的拓扑图引擎与容器填充器,天然适配不同端的架构诉求:
模式 A:前端全局单例 (Frontend Singleton)
在前端应用入口初始化全局单例容器,视图组件或应用逻辑直接消费该单例:
// src/index.ts
import { createModularContainer } from "virtual:modular-container";
export const modularContainer = await createModularContainer();
模式 B:后端 Request-Scoped 多例 (Backend Multi-Instance)
在 Node.js / Hono / Express 后端服务中,启动时预编译静态图,HTTP 请求到达时高频实例化独立隔离容器:
import {
compileModuleGraph,
instantiateModuleContainer,
} from "lianhanlin-modular";
import { modules } from "virtual:modular-container";
// 1. 服务启动阶段:纯同步纳秒级预编译静态拓扑图 (全局仅计算一次)
const compiledGraph = compileModuleGraph(modules);
// 2. HTTP 请求到达阶段:高频实例化独立隔离容器 (零重复图计算,CPU 性能提升 80%)
app.use(async (c, next) => {
const reqContainer = {}; // 每次请求独立的新容器对象
await instantiateModuleContainer(compiledGraph, reqContainer);
c.set("container", reqContainer); // 挂载至请求上下文,防止跨请求数据污染
await next();
});
📊 主流 IoC 框架选型对比 (Selection Matrix)…
Description from the npm listing.
- path-ioc
- ioc
- di
- dependency-injection
- mesh
- modular
- typescript
- type-safe
- zero-boilerplate
- dag
- topological-sort
- vite
- vite-plugin
- webpack
- webpack-plugin
- fullstack
- hono
- architecture
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Webpack plugins plugins
All 20 lianhanlin-modular alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/lianhanlin-modular. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.