Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iyowei/js-module-dependencies-to-be-installed
JavaScript 模块(esm, cjs, amd, ts, tsx, jsx)说明符过滤器:需要额外安装的的模块。
https://github.com/iyowei/js-module-dependencies-to-be-installed
denpendenies iyowei nodejs npm npm-package utilities
Last synced: about 7 hours ago
JSON representation
JavaScript 模块(esm, cjs, amd, ts, tsx, jsx)说明符过滤器:需要额外安装的的模块。
- Host: GitHub
- URL: https://github.com/iyowei/js-module-dependencies-to-be-installed
- Owner: iyowei
- License: mit
- Created: 2021-12-14T11:06:03.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-18T07:21:56.000Z (almost 3 years ago)
- Last Synced: 2024-09-26T08:10:41.923Z (about 1 month ago)
- Topics: denpendenies, iyowei, nodejs, npm, npm-package, utilities
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[precinct]: https://github.com/dependents/node-precinct
# jsModuleDependenciesToBeInstalled(specifiers)
> JavaScript 模块(esm, cjs, amd, ts, tsx, jsx)说明符过滤器:需要额外安装的的模块。
依赖(说明符)收集器,见 [Precinct][precinct]。
## 使用
- specifiers {Array} [Precinct][precinct] 收集器收集到的模块说明符集合,默认 **`[]`**;
- 返回 {Array} 需要额外安装的的模块名称。```js
import { readFileSync } from "fs";
import { log } from "console";import precinct from "detective-es6";
import jsModuleDependenciesToBeInstalled from "@iyowei/js-module-dependencies-to-be-installed";/**
* "/Users/iyowei/Development/iyowei/create-esm/cli.js" 片段,
*
* import { existsSync } from "fs";
* import { Listr } from "listr2";
* import shell from "shelljs";
* import meow from "meow";
* import chalk from "chalk";
* import { banner, mainHelp, setupHelp, COMMAND_SET, COMMAND_DEFAULTS, getReport } from "./src/messages.js";
* import pressAnyKeyToContinue from "./src/pressAnyKeyToContinue.js";
* import { updateGlobalConfigurations, getGlobalConfigurations } from "./src/options/global.js";
* import makeOptions from "./src/options/make.js";
* import prerequisites from "./src/prerequisites.js";
*/
const specifiers = precinct(
readFileSync("/Users/iyowei/Development/iyowei/create-esm/cli.js", "utf-8")
);const read = jsModuleDependenciesToBeInstalled(specifiers);
console.log("read", read);
// read: [ 'listr2', 'shelljs', 'meow', 'chalk' ]const given = jsModuleDependenciesToBeInstalled([
"./startup.js",
"../config.mjs","file:///opt/nodejs/config.js",
"/opt/nodejs/config.mjs",
"fs",
"node:fs",
"node:fs/promise","some-package",
"@others/test",
"@npmcli/package-json","@npmcli/package-json/promise",
"some-package/lib/shuffle.mjs",
]);
console.log("given", given);
// given: given [ 'some-package', '@others/test', '@npmcli/package-json' ]
```## 安装
[![Node version](https://img.shields.io/badge/node.js-%3E%3D12.20.0-brightgreen?style=flat&logo=Node.js)](https://nodejs.org/en/download/)
```shell
# Pnpm
pnpm add @iyowei/js-module-dependencies-to-be-installed# yarn
yarn add @iyowei/js-module-dependencies-to-be-installed# npm
npm add @iyowei/js-module-dependencies-to-be-installed
```## 设计
ESM, CJS, AMD, TS, TSX, JSX,等等,模块定义很多,对应了不同依赖(说明符)收集器,但说明符规范是一致的,所以将过滤器部分提取出来,方便复用。
## 参与贡献
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)