Почему функция VS Code "Перейти к определению" не работает для этого пользовательского пакета NPM? - PullRequest
0 голосов
/ 01 декабря 2019

Я создал пользовательский пакет 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 + click или right-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"
}

Iсвязав его с помощью Webpack, вы можете проверить мою конфигурацию в репозитории GitHub или попросить меня включить его здесь, если это необходимо.

Сам пакет состоит из одного index.js файла в src/.

Как я могу заставить VS Code переходить к исходному коду cartesian-composition, когда я Cmd + click на нем?

Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...