Skip to content

Commit

Permalink
fix: when symlinking node_modules symlinks in js_run_devserer, prefer…
Browse files Browse the repository at this point in the history
… the bazel-out copy instead of the runfiles copy if it exists
  • Loading branch information
gregmagolan committed May 3, 2023
1 parent 6b1cbb8 commit dc197b3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions js/private/js_run_devserver.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,26 @@ async function syncRecursive(src, dst, writePerm) {
const exists = synced.has(src) || fs.existsSync(dst)
synced.set(src, lstat.mtimeMs)
if (lstat.isSymbolicLink()) {
const srcWorkspacePath = src.slice(RUNFILES_ROOT.length + 1)
if (process.env.JS_BINARY__LOG_DEBUG) {
console.error(
`Syncing symlink ${src.slice(RUNFILES_ROOT.length + 1)}`
console.error(`Syncing symlink ${srcWorkspacePath}`)
}
if (path.basename(path.dirname(src)) == 'node_modules') {
// Special case for node_modules symlinks where we should _not_ symlink to the runfiles but rather
// the bin copy of the symlink to avoid finding npm packages in multiple node_modules trees
const maybeBinSrc = path.join(
process.env.JS_BINARY__EXECROOT,
process.env.JS_BINARY__BINDIR,
srcWorkspacePath
)
if (fs.existsSync(maybeBinSrc)) {
if (process.env.JS_BINARY__LOG_DEBUG) {
console.error(
`Syncing to bazel-out copy of symlink ${srcWorkspacePath}`
)
}
src = maybeBinSrc
}
}
if (exists) {
await fs.promises.unlink(dst)
Expand Down

0 comments on commit dc197b3

Please sign in to comment.