简体   繁体   English

如何修改使用TypeScript构建的npm软件包

[英]How to modify an npm package built with TypeScript

I want to try and make some changes to a package published in npm? 我想尝试对npm中发布的软件包进行一些更改吗? (I've suggest some changes as an issue but I think they are simple enough for me to attempt them). (我建议将一些更改作为问题,但我认为这些更改很简单,我可以尝试一下)。

https://www.npmjs.com/package/bt-presence#contributing--modifying https://www.npmjs.com/package/bt-presence#contributing--modifying

The author supplies some information on how to modify the package, but not really enough for someone doing it for the first time. 作者提供了有关如何修改程序包的一些信息,但对于初次使用该程序包的人来说确实不够。

  • Where should I clone the GitHub repo to? 我应该将GitHub存储库克隆到哪里? The folder where the package is installed? 安装软件包的文件夹? I tried it in my home folder and that would not build (unmodified). 我在我的主文件夹中尝试过它,但是它不会生成(未修改)。
  • The command npm run build - where is this run from? 命令npm run build从哪里运行? The root folder of the package where the package.json is? package.json所在的package.json的根文件夹?
  • Will I need to modify the package.json ? 我需要修改package.json吗?

In general what is the best way to develop something like this for npm? 通常,为npm开发类似内容的最佳方法是什么? I've worked on packages before but they were simply Javascript. 我之前曾研究过软件包,但它们只是Javascript。

  • If you want to work on the bt-presence package in isolation, you can put the cloned repository anywhere. 如果要bt-presence包,则可以将克隆的存储库放在任何地方。 If you want to use your modified version of bt-presence in combination with an application, my recommended approach is to register bt-presence as a dependency in the application's package.json file with the version set to a relative path to your bt-presence repository; 如果要与应用程序结合使用修改后的bt-presence版本,我建议的方法是在应用程序的package.json文件中将bt-presence注册为依赖项,并将版本设置为bt-presence的相对路径。库; then running npm install in the application will make a symlink from node_modules/bt-presence in the application to your bt-presence repository. 然后在应用程序中运行npm install将建立从应用程序中的node_modules/bt-presence到您的bt-presence存储库的符号链接。
  • npm run build should indeed be run from the root folder that contains the package.json of bt-presence . 实际上, npm run build应该从包含bt-presencepackage.json的根文件夹中运行。
  • If you just want to change the code of bt-presence , you won't need to modify its package.json . 如果您只想更改bt-presence的代码,则无需修改其package.json You would only modify the package.json if you need to change any of the settings in there, eg, if you need to add additional dependencies to your version of bt-presence . 仅在需要更改其中的任何设置(例如,需要向bt-presence版本添加其他依赖项)时,才修改package.json

None of the above is really specific to TypeScript. 以上内容都不是真正针对TypeScript的。 (Some JavaScript packages have build processes too if they need to transform or package the JavaScript files in some way.) (如果某些JavaScript程序包需要以某种方式转换或打包JavaScript文件,它们也具有构建过程。)

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

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