npm-dts-webpack-plugin:Webpack插件生成单个dts文件以捆绑TypeScript NPM软件包

  • v2_280338
    了解作者
  • 13.8KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-14 02:46
    上传日期
npm-dts-webpack-plugin 该WebPack插件为整个NPM软件包生成单个index.d.ts文件。 它允许创建捆绑的NPM库软件包,而无需使用TypeScript源,并且无论这些库被导入到哪里,都仍然保留代码建议。 TypeScript自动获取index.d.ts 。 安装 首先安装插件: npm install --save-dev npm-dts-webpack-plugin 然后将插件添加到WebPack配置中: const NpmDtsPlugin = require ( 'npm-dts-webpack-plugin' ) module . exports = { ...... plugins : [ new NpmDtsPlugin ( ) ] , ...... } 您还可以通过提供模块支持的选项来选择自定义行为:
npm-dts-webpack-plugin-master.zip
  • npm-dts-webpack-plugin-master
  • .vscode
  • launch.json
    1014B
  • settings.json
    2KB
  • tasks.json
    744B
  • .npmignore
    60B
  • LICENSE
    1.1KB
  • .prettierrc
    90B
  • README.md
    2.4KB
  • .gitignore
    108B
  • index.js
    498B
  • package-lock.json
    24.4KB
  • package.json
    1KB
内容介绍
# npm-dts-webpack-plugin This WebPack plugin generates single _index.d.ts_ file for whole _NPM_ package. It allows creating bundled _NPM_ library packages without _TypeScript_ sources and yet still keeping code suggestions wherever these libraries are imported. _TypeScript_ picks up _index.d.ts_ automatically. --- ## Installation First install the plugin: ``` npm install --save-dev npm-dts-webpack-plugin ``` Then add plugin to _WebPack_ configuration: ```javascript const NpmDtsPlugin = require('npm-dts-webpack-plugin') module.exports = { ...... plugins: [ new NpmDtsPlugin() ], ...... } ``` You can also choose to customize behavior by providing options supported by ["_npm-dts_"](https://www.npmjs.com/package/npm-dts) module: ```javascript const NpmDtsPlugin = require('npm-dts-webpack-plugin') module.exports = { ...... plugins: [ new NpmDtsPlugin({ logLevel: 'debug' }) ], ...... } ``` ### Supported options | Option | Description | | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | entry | Allows changing main _src_ file from _index.ts_ to something else. | | force | Ignores non-critical errors and attempts to at least partially generate typings (disabled by default). | | logLevel | Log level (error, warn, info, verbose, debug) (defaults to "info"). | | output | Overrides recommended output target to a custom one (defaults to "index.d.ts"). | | root | NPM package directory containing package.json (defaults to current working directory). | | tmp | Directory for storing temporary information (defaults to OS-specific temporary directory). Note that tool completely deletes this folder once finished. | | tsc | Passed through additional TSC options (defaults to ""). Note that they are not validated or checked for suitability. |
评论
    相关推荐