汇总和打字稿包没有编辑器代码完成并跳转到声明

Rollup and typescript bundle is without editor code completion and jump to declaration

对捆绑非常陌生。我的团队习惯于编码完成,并能够在他们的编辑器中使用 command + click 跳转到相应组件的类型声明文件 (VSCode)。

但是生成的包并没有这种行为...我不知道如何从这里开始,或者我缺少什么。这些功能对我的团队非常重要。感谢任何帮助

版本

rollup.config.js

import babel from 'rollup-plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import svgr from '@svgr/rollup';
import url from '@rollup/plugin-url';
import json from '@rollup/plugin-json';
import external from 'rollup-plugin-peer-deps-external';
import includePaths from 'rollup-plugin-includepaths';

const pkg = require('./package.json');

export default {
  cache: false,
  input: 'src/index.ts',
  output: { file: pkg.module, format: 'esm' },
  plugins: [
    external({
      preferBuiltins: false,
    }),
    babel({
      exclude: /node_modules/,
      plugins: ['external-helpers'],
      externalHelpers: true, 
    }),
    json(),
    resolve(),
    svgr({
      ref: true,
      svgo: false,
    }),
    typescript({
      clean: true,
      typescript: require('typescript'),
    }),
    url(),
    includePaths({
      paths: ['src'],
    }),
    commonjs({
      namedExports: {
        'prop-types': [
          'oneOfType',
          'func',
          'shape',
          'any',
          'number',
          'object',
          'bool',
          'string',
        ],
      },
    }),
  ],
};

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": "src",
    "declaration": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "jsx": "react",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "es6",
    "moduleResolution": "node",
    "noEmit": true,
    "noErrorTruncation": true,
    "outDir": "./dist",
    "skipLibCheck": true,
    "strict": true,
    "target": "es5",
    "rootDir": "src"
  },
  "include": ["src"],
  "exclude": ["storybook", "dist"]
}

package.json

仅相关位

{
  "main": "dist/index.js",
  "module": "dist/index.js",
  "typings": "dist/index.d.ts",
}

发现问题 - 这是因为我使用了绝对路径。在构建时将导入路径更改为相对导入或使用插件将绝对导入路径转换为相对导入路径修复了此问题。