通过BitBucket使用Angular Library存储库作为依赖关系
我在使用角库存储库时遇到了问题。希望在这里找到一个答案:)
我有一个角度存储库,该存储库容纳一个角库。 该库存储在Bitbucket存储库中 - 包括“ DIST”文件夹中的编译文件。
现在,我想通过一个应用程序消耗此库。
当前,当我将库存储库作为对我的应用程序的依赖性时(通过NPM安装git+ssh:// [email  procearted] /name/my-library.git)整个存储库都添加到了应用程序的node_modules文件夹中。
但是,使用此配置,该库无法通过应用程序找到。由于事实,编译的库文件位于存储库的“ DIST”文件夹中。
现在,如何告诉应用程序在库文件夹的“ DIST”文件夹中查找所需的库文件?
当前的解决方法是将以下内容放置在我的应用程序的tsconfig.json中
"compilerOptions": {
"paths": {
"my-library": [ "node_modules/my-library/dist" ]
}
}
,但我几乎可以肯定,必须有更多的通用。库存储库中必须放置的东西。
先感谢您。
I got a problem regarding the use of an Angular library repository. Hopefully find an answer here :)
I have an Angular repository which holds one single Angular library.
This library is stored in a bitbucket repository - including the compiled files in the "dist" folder.
Now I want to consume this library by an application.
Currently, when I install the library repository as an dependency to my application (via npm install git+ssh://[email protected]/NAME/my-library.git) the whole repository is added to the node_modules folder of the application.
But with this configuration the library can not be found by the application. Because of the fact, that the compiled library files are located in the "dist" folder of the repository.
Now how can I tell the application to look in the "dist" folder of the library folder, to find the needed library files?
A current workaround is to place the following in the tsconfig.json of my application
"compilerOptions": {
"paths": {
"my-library": [ "node_modules/my-library/dist" ]
}
}
But I'm almost sure, that there must be somethign more generic. Something which must be placed in the package.json/angular.json of the library repository to point consuming applications to the dist-folder?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很遗憾地告诉您,与在配置文件中添加一行相比,要做的小要做的要多。
除了您的存储库
my-library
外,您需要仅保存转码的DIST文件的Bitbucket中的第二个存储库。让我们命名my-library-Dist
。 注意:如果您在my-library
存储库中有多个项目,则每个项目都需要一个Dist存储库。要将DIST文件推在DIST存储库中,您可以在本地构建它们并将其推入之后,或者一种更自动化的方法是使用
bitbucket-pipeline.yml
file。但这也是最困难的方法。为了节省很多跟踪和错误,我将在此处复制自己的文件。将此文件放在您的
my-library
存储库的根文件夹中。注意:
bitbucket-pipeline.yml
文件中调整一些项目名称的路径。my-library/projects/my-projection-my-library/package.json
文件中拥有一个版本号。 (在任何管道运行中进行更新)main
分支(第7行)构建完成后,您可以在
my-library-Dist
存储库中找到一个新的次要版本标签。使用以下NPM命令安装/更新:npm i bitbucket:my-Company/my-library-Dist#xyz
这是截至2022年6月的Bitbucket支持的方式,并用Angular V14进行了测试
I am pretty sorry to tell you that there is a little more to do than adding a line to a configuration file.
Aside your repository
my-library
you need a second repository in bitbucket holding only the transcoded dist files. Lets name itmy-library-dist
. Note: If you have multipe projects in yourmy-library
repository you like to distribute, you need one dist repository for each project.To push the dist files in your dist repo, you can build them locally and push them afterwards, or a more automated way is to use a
bitbucket-pipeline.yml
file. But this is also the hardest way.To save you a lot of trail and error, I will copy my own file here. Place this file in root folder of your
my-library
repository.Note:
bitbucket-pipeline.yml
file.my-library/projects/my-project-within-my-library/package.json
file. (gets updated for any pipeline run)main
branch (line 7)my-library
repository ( -> repository settings -> ssh key) to his own SSH keys ( -> avatar -> personal settings -> ssh keys -> add key ). now the repository has the same access rights as the user holing the public key.Once the build is done, you can find a new minor version tag in your
my-library-dist
repository. Use the following NPM command to install/update:npm i bitbucket:my-company/my-library-dist#X.Y.Z
This is the suggested way by the bitbucket support by june 2022, tested with angular v14