Giter VIP home page Giter VIP logo

js-module-dependencies-to-be-installed's Introduction

jsModuleDependenciesToBeInstalled(specifiers)

JavaScript 模块(esm, cjs, amd, ts, tsx, jsx)说明符过滤器:需要额外安装的的模块。

依赖(说明符)收集器,见 Precinct

使用

  • specifiers {Array} Precinct 收集器收集到的模块说明符集合,默认 []
  • 返回 {Array} 需要额外安装的的模块名称。
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

# 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.