Skip to content

Commit

Permalink
fix(builtin): linker no longer makes node_modules symlink to the root…
Browse files Browse the repository at this point in the history
… of the workspace output tree

BREAKING CHANGE:

Any nodejs_binary/nodejs_test processes with the linker enabled (--nobazel_patch_module_resolver is set) that were relying on standard node_module resolution to resolve manfest file paths such as `my_workspace/path/to/output/file.js` must now use the runfiles helper such as.

Previously:
```
const absPath = require.resolve('my_workspace/path/to/output/file.js');
```
With runfiles helper:
```
const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']);
const absPath = runfiles.resolve('my_workspace/path/to/output/file.js');
```
  • Loading branch information
gregmagolan authored and alexeagle committed Jun 16, 2020
1 parent a3bd81b commit 044495c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions internal/linker/link_node_modules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ def write_node_modules_manifest(ctx, extra_data = []):
extra_data: labels to search for npm packages that need to be linked (ctx.attr.deps and ctx.attr.data will always be searched)
"""

mappings = {
# We always map the workspace to itself to support absolute require like
# import from 'my_wksp/path/to/file' and it's always links to the bin_dir.
# If source files need to be required then they can be copied to the bin_dir
# with copy_to_bin.
ctx.workspace_name: ["execroot", ctx.bin_dir.path],
}
mappings = {}
node_modules_root = ""

# Look through data/deps attributes to find...
Expand Down

0 comments on commit 044495c

Please sign in to comment.