为什么VS Code“转到定义”功能不适用于此自定义NPM软件包?

时间:2019-12-01 19:04:02

标签: javascript npm visual-studio-code package.json

我创建了一个自定义NPM软件包:

NPM:https://www.npmjs.com/package/cartesian-composition

GitHub:https://github.com/tonix-tuft/cartesian-composition

您可以通过以下NPM命令安装它:

npm install --save js-utl cartesian-composition

并在另一个项目中像这样使用它:

import cartesianComposition from "cartesian-composition";

const a = (...res) => `a(${res.join(", ")})`;
const b = (...res) => `b(${res.join(", ")})`;
const c = (...res) => `c(${res.join(", ")})`;
const d = (...res) => `d(${res.join(", ")})`;
const e = (...res) => `e(${res.join(", ")})`;
const f = (...res) => `f(${res.join(", ")})`;
const g = (...res) => `g(${res.join(", ")})`;
const h = (...res) => `h(${res.join(", ")})`;
const i = (...res) => `i(${res.join(", ")})`;

const res = cartesianComposition(
  [a, b, c],
  [[cartesianComposition.OPTIONAL], d, e, f, g],
  [h, [[cartesianComposition.OPTIONAL], i]]
)(1, 2, 3);

console.log(res);

效果很好,唯一的是,如果我转到import行:

import cartesianComposition from "cartesian-composition";

...

并尝试Cmd + clickright-click并单击“转到定义”,VS Code不会将我发送到程序包的源代码。 但这适用于不是我创建的其他软件包,因此我想我缺少了一些东西。

这是package.json软件包中的cartesian-composition

{
  "name": "cartesian-composition",
  "version": "1.0.0",
  "description": "A higher order function to compose functions through cartesian composition.",
  "keywords": [
    "composition",
    "functional-programming",
    "composite",
    "cartesian-composition"
  ],
  "author": "Anton Bagdatyev (Tonix-Tuft)",
  "license": "MIT",
  "main": "./dist/index.js",
  "module": "./src/index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/tonix-tuft/cartesian-composition.git"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "watch": "WEBPACK_ENV=watch webpack --progress --colors --watch",
    "build": "WEBPACK_ENV=build webpack"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.9.0",
    "@typescript-eslint/parser": "^2.9.0",
    "eslint": "^6.7.2",
    "js-utl": "^1.2.0",
    "terser-webpack-plugin": "^1.4.1",
    "typescript": "^3.7.2",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.10"
  },
  "peerDependencies": {
    "js-utl": "^1.2.0"
  },
  "bugs": {
    "url": "https://github.com/tonix-tuft/cartesian-composition/issues"
  },
  "homepage": "https://github.com/tonix-tuft/cartesian-composition#readme"
}

我使用Webpack捆绑了它,您可以在GitHub存储库上检查我的配置,也可以要求我在此处包含它。

程序包本身由index.js中的一个src/文件组成。

cartesian-composition上如何使VS Code成为Cmd + click的源代码?

谢谢。

0 个答案:

没有答案