简体   繁体   English

vs 代码智能感知不适用于 webpack 包

[英]vs code IntelliSense not working with webpack bundles

I have a simple webpack config .我有一个简单的 webpack 配置。

const path = require('path');

module.exports = {
  devtool: 'source-map',
  entry: './src/index.js',
  output: {
    libraryTarget: 'commonjs',
    filename: 'index.js',
    path: path.resolve(__dirname, 'dist'),
  },
};

After I build and upload my modules to npm and use them on other projects the vs code IntelliSense is not working for these modules.在我构建并将我的模块上传到 npm 并在其他项目中使用它们后, vs 代码IntelliSense 不适用于这些模块。 The module functions are documented with jsdoc .模块功能记录在jsdoc 中

import { myFunc } from 'myModule';

Or或者

const myModule = require('myModule');

Myfunc and myModule have no IntelliSense auto complate support or any other. Myfunc 和 myModule 没有 IntelliSense 自动编译支持或任何其他支持。

How can I keep the jsdoc working after webpack build?如何在 webpack 构建后保持 jsdoc 工作?

If the package is coming through npm, you need to publish a type definition file ( .d.ts ).如果包是通过 npm 来的,你需要发布一个类型定义文件( .d.ts )。 d.ts files contain type definitions and comments for your API that allow us to efficiently provide rich intellisense for external packages. d.ts文件包含 API 的类型定义和注释,使我们能够有效地为外部包提供丰富的智能感知。 VS Code is limited in how it can parse the actual JS code from node_modules packages. VS Code 在解析node_modules包中的实际 JS 代码方面受到node_modules

Here's some resources on getting started with d.ts files:以下是有关d.ts文件入门的一些资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM