yarnpkg/yarn

Build artifacts caching support for non-relocatable binaries

Open

#480 创建于 2016年9月29日

在 GitHub 查看
 (16 评论) (0 反应) (0 负责人)JavaScript (41,514 star) (2,731 fork)batch import
cat-featurehelp wantedneeds-discussiontriaged

描述

The current caching mechanism assumes all binaries are relocatable. However that's not always the case. As an example, the ocaml compiler itself has hardcoded paths inside the binary.

The current problem today is that if we build ocaml in project A and use the cache in building project B, artifacts in project B will be pointing to project A, where it was originally build. This means if we remove projectA, B will stop working.

One possible solution to this problem is to always run build in a configurable directory, instead of node_modules in the current project. After build we can then copy the build artifacts back to the destination (either project A or B). This way, the non-relocatable artifacts will only depend on a directory where users are aware of.

To repro:

mkdir A; cd A
yarn add @opam-alpha/ocaml
mkdir B; cd B
yarn add @opam-alpha/ocaml # This should be built instantly from cache
rm -rf ../A
node_modules/ocaml/bin/ocaml # ocaml in project B won't work anymore

@bestander @jordwalke @dxu

贡献者指南