Reputation: 5919
I have this sample typescript package with prepare script running tsc
: https://github.com/richard-ejem/tspackage
When I install it with npm using npm add git+https://github.com/richard-ejem/tspackage.git#master
to a project, node_modules/tspackage/dist
contains 4 files as expected:
However, when installed with yarn using yarn add git+https://github.com/richard-ejem/tspackage.git#master
, the dist
folder contains only index.js
.
Am I missing something, or is this a bug in yarn? Is there some possible workaround/other way to build typescript git dependencies on yarn install?
Upvotes: 3
Views: 6042
Reputation: 11
Try add through ssh, yarn add ssh://github.com/richard-ejem/tspackage#master
Don't know why, but it worked for me, yarn -v 1.22.15
Upvotes: 0
Reputation: 5919
Finally found a solution - the trick is to add empty .npmignore
file to the repository.
It is probably related to this problem: https://github.com/yarnpkg/yarn/issues/5235#issuecomment-571206092
if there is no .npmignore
, npm/yarn removes everything matching .gitignore
on install, and in case of yarn, this somehow conflicts with prepare
script. It is still weird that dist/index.js
is not removed since it is ignored by .gitignore
too, however the empty .npmignore
solves the problem.
Upvotes: 3