{"id":21989014,"url":"https://github.com/imweb/fis3-hook-lego","last_synced_at":"2025-08-03T18:36:26.093Z","repository":{"id":57237228,"uuid":"41410677","full_name":"imweb/fis3-hook-lego","owner":"imweb","description":"lego 包管理器 fis3 模块查找。 http://lego.imweb.io/","archived":false,"fork":false,"pushed_at":"2016-12-27T08:30:16.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-22T15:06:05.894Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-26T07:16:53.000Z","updated_at":"2017-06-18T21:44:15.000Z","dependencies_parsed_at":"2022-08-26T15:10:20.360Z","dependency_job_id":null,"html_url":"https://github.com/imweb/fis3-hook-lego","commit_stats":null,"previous_names":["jiangyuan/fis3-hook-lego"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imweb%2Ffis3-hook-lego","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imweb%2Ffis3-hook-lego/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imweb%2Ffis3-hook-lego/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imweb%2Ffis3-hook-lego/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imweb","download_url":"https://codeload.github.com/imweb/fis3-hook-lego/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251690464,"owners_count":21628121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T19:27:23.687Z","updated_at":"2025-04-30T11:28:27.604Z","avatar_url":"https://github.com/imweb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fis3-hook-lego\nfis3 版本的 `lego` 包管理的模块查找，[http://lego.imweb.io/](http://lego.imweb.io/) 。\n\n## 背景\n如下目录结构：\n\n```\n    .\n    ├── index.html\n    ├── lego_modules\n    │   ├── dialog\n    │   │   └── 0.1.0\n    │   │       ├── custom.js\n    │   │       └── package.json\n    │   ├── slider\n    │   │   └── 0.1.0\n    │   │       └── index.js\n    │   ├── tab\n    │   │   └── 0.1.0\n    │   │       └── tab.js\n    │   └── test_module\n    │       └── 0.1.0\n    │           └── index.js\n    ├── map.json\n    ├── modules\n    │   ├── common\n    │   │   ├── common.js\n    │   │   └── header\n    │   │       ├── db.header.js\n    │   │       └── header.js\n    │   ├── common.js\n    │   ├── index\n    │   │   └── header\n    │   │       ├── db.header.js\n    │   │       └── header.js\n    │   └── test_module.js\n    └── pages\n        └── index\n            ├── main.css\n            └── main.js\n```\n现在 `main.js ` 内容：\n\n```js\nvar dialog = require('dialog');\nvar slider = require('slider');\nvar tab = require('tab');   // lego_modules 中的快速引用\nvar version = require('versions@0.1.0'); // 指定版本\nvar common = require('common');\nvar testModule = require('test_module');\nvar header = require('index/header');   // modules 中也可以省去 `modules`\nvar index = require('index'); // 查找modules/index.js ; modules/index/index.js\n```\n\n\n## 使用\n\n### 安装\n```\nnpm i fis3-hook-lego -g\n```\n\n### 配置\n在 `fis-conf.js` 中：\n```js\nfis.hook('lego');\n\nfis.match(/^\\/modules\\/(.+)\\.js$/, {\n        isMod: true,\n        id: '$1'\n    })\n    .match(/^\\/modules\\/((?:[^\\/]+\\/)*)([^\\/]+)\\/\\2\\.(js)$/i, {\n        //isMod: true,\n        id: '$1$2'\n    })\n    .match(/^\\/lego_modules\\/(.+)\\.js$/i, {\n        isMod: true,\n        id: '$1'\n    });\n```\n\n### 注意\n由于有多版本的场景，lego会修改文件id，`比如require('zepto'), 产出后是 require('zepto/1.1.6/zepto')`,\n其他插件的配置中需要zepto时，比如 ignore: ['zepto']，查找会有问题，解决方案：\n\n1. ignore: ['zepto/1.1.6/zepto']，指定具体的版本\n\n2. 在处理逻辑之前，调用 fis.get('idMaps'), 将zepto的id进行转化（ps：idMaps中记录了lego对文件id的修改，key值是修改前的id，value是修改后的id）    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimweb%2Ffis3-hook-lego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimweb%2Ffis3-hook-lego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimweb%2Ffis3-hook-lego/lists"}