-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: relative data paths in yarn_install & npm_install when symlink_n…
…ode_modules=False and package.json is not at root This fixes `yarn_install` & `npm_install` to copy `package.json` & lock files into the external repository to a folder that corresponds to the package.json's workspace folder and the package manager is then run out that location so that relative paths to `data` files are preserved (same as they would be outside of bazel) if the `package.json` is _not_ at the root of the WORKSPACE. If you had a nested `package.json` and were using `yarn_install` or `npm_install` with `symlink_node_modules = False,` and passing in `data` that you were referencing during install, then you would have had to use the work-around of absolute workspace paths to the `data` files. This fix will allow you to use the same relative paths that you would use if you were running `yarn` or `npm` outside of bazel in this case. For example, if the package.json file is located at `my/nested/package.json` then it will end up at `_/my/nested/package.json` in the external repository. When `symlink_node_modules` is `False`, `data` files are copied into the same tree, so that relative paths in `package.json` that refer to `data` files are preserved. A `"postinstall": "patch-package --patch-dir patches"` in a nested `package.json` file expects a `patches` directory relative to the `package.json` file will now work with `symlink_node_modules = False`. ``` yarn_install( name = "my_nested_npm_deps", package_json = "//my/nested:package.json", yarn_lock = "//my/nested:yarn.lock", data = ["//my/nested:patches/jest-haste-map+24.9.0.patch"], symlink_node_modules = False, ) ``` Additional fix is that `data` files are now copied to external repository with `mkdir -p && cp -f` instead of `rtcx.template({})` trick. The latter is slower & does not copy over binary files correctly. We must copy `data` files and _not_ symlink them since a `package.json` file with `file:path/to/data` will fail if `path/to/data` is a symlink.
- Loading branch information
Showing
11 changed files
with
101 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"tmp": "0.1.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "node ./postinstall.js" | ||
"postinstall": "node ../postinstall.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"tmp": "0.1.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "node ./postinstall.js" | ||
"postinstall": "node ../postinstall.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"tmp": "0.1.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "node ./postinstall.js" | ||
"postinstall": "node ../postinstall.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"tmp": "0.1.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "node ./postinstall.js" | ||
"postinstall": "node ../postinstall.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -751,7 +751,7 @@ [email protected]: | |
optionalDependencies: | ||
graceful-fs "^4.1.9" | ||
|
||
"local-module@link:tools/npm_packages/local_module/yarn": | ||
"local-module@link:../npm_packages/local_module/yarn": | ||
version "0.0.0" | ||
uid "" | ||
|
||
|