Skip to content

Commit

Permalink
fix: #3054 regression in linker behavior in 4.4.2 (#3059)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Nov 4, 2021
1 parent 658b712 commit ccf54bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 5 additions & 3 deletions internal/linker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ function main(args, runfiles) {
else {
yield mkdirp(execrootNodeModules);
}
const packagePathBin = path.posix.join(bin, packagePath);
yield mkdirp(`${packagePathBin}`);
yield symlinkWithUnlink(execrootNodeModules, `${packagePathBin}/node_modules`);
if (packagePath) {
const packagePathBin = path.posix.join(bin, packagePath);
yield mkdirp(`${packagePathBin}`);
yield symlinkWithUnlink(execrootNodeModules, `${packagePathBin}/node_modules`);
}
if (!isExecroot) {
const runfilesPackagePath = path.posix.join(startCwd, packagePath);
yield mkdirp(`${runfilesPackagePath}`);
Expand Down
13 changes: 9 additions & 4 deletions internal/linker/link_node_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,15 @@ export async function main(args: string[], runfiles: Runfiles) {
await mkdirp(execrootNodeModules);
}

// Bin symlink -> execroot node_modules
const packagePathBin = path.posix.join(bin, packagePath);
await mkdirp(`${packagePathBin}`);
await symlinkWithUnlink(execrootNodeModules, `${packagePathBin}/node_modules`);
if (packagePath) {
// Bin symlink -> execroot node_modules
// NB: don't do this for the root of the bin tree since standard node_modules resolution
// will fall back to the execroot node_modules naturally
// See https://github.com/bazelbuild/rules_nodejs/issues/3054
const packagePathBin = path.posix.join(bin, packagePath);
await mkdirp(`${packagePathBin}`);
await symlinkWithUnlink(execrootNodeModules, `${packagePathBin}/node_modules`);
}

// Start CWD symlink -> execroot node_modules
if (!isExecroot) {
Expand Down

0 comments on commit ccf54bc

Please sign in to comment.