You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add opt-in exports_directories_only mode to yarn_install and npm_install (defaults to False)
When `True`, `yarn_install` and `npm_install` export only top-level package directory artifacts from node_modules.
Turning this on will decrease the time it takes for Bazel to setup runfiles and sandboxing when
there are a large number of npm dependencies as inputs to an action.
This breaks compatabilty for label that reference files within npm packages such as `@npm//:node_modules/prettier/bin-prettier.js`.
To reference files within npm packages, you can use the `directory_file_path` rule and/or `DirectoryFilePathInfo` provider.
Note, some rules still need upgrading to support consuming `DirectoryFilePathInfo` where needed.
NB: This feature requires runfiles be enabled due to an issue in Bazel which we are still investigating.
On Windows runfiles are off by default and must be enabled with the `--enable_runfiles` flag when
using this feature.
NB: `ts_library` does not support directory artifact npm deps due to internal dependency on having all input sources files explicitly specified
NB: `karma_web_test` and `karma_web_test_suite` do not yet support directory artifact npm deps as they require `node_modules/requirejs/require.js` & `node_modules/karma-requirejs/lib/adapter.js` explicit source files in deps
For the `nodejs_binary` & `nodejs_test` `entry_point` attribute (which often needs to reference a file within
an npm package) you can set the entry_point to a dict with a single entry, where the key corresponds to the directory artifact
label and the value corresponds to the path within that directory to the entry point.
For example,
```
nodejs_binary(
name = "prettier",
data = ["@npm//prettier"],
entry_point = "@npm//:node_modules/prettier/bin-prettier.js",
)
```
becomes,
```
nodejs_binary(
name = "prettier",
data = ["@npm//prettier"],
entry_point = { "@npm//:node_modules/prettier": "bin-prettier.js" },
)
```
For other labels that are passed to `$(rootpath)`, `$(execpath)`, or `$(location)` you can simply break these apart into
the directory artifact label that gets passed to the expander & path part to follows it.
For example,
```
$(rootpath @npm//:node_modules/prettier/bin-prettier.js")
```
becomes,
```
$(rootpath @npm//:node_modules/prettier)/bin-prettier.js
```
0 commit comments