Skip to main content
Documentation for @rules_nodejs@v6.7.3 View source
This module implements the node toolchain rule.

Function: nodejs_toolchain

Defines a node toolchain for a platform. You can use this to refer to a vendored nodejs binary in your repository, or even to compile nodejs from sources using rules_foreign_cc or other rules. First, in a BUILD.bazel file, create a nodejs_toolchain definition:
Next, declare which execution platforms or target platforms the toolchain should be selected for based on constraints. A separate toolchain type is used for runtime target platform selection.
See https://bazel.build/extending/toolchains#toolchain-resolution for more information on toolchain resolution. Finally in your WORKSPACE, register it with register_toolchains("//:my_nodejs") For usage see https://docs.bazel.build/versions/main/toolchains.html#defining-toolchains. You can use the --toolchain_resolution_debug flag to bazel to help diagnose which toolchain is selected.

Parameters

unknown
required
Unique name for this target
unknown
default:"None"
Node.js executable
unknown
default:"\"\""
Path to Node.js executable fileThis is typically an absolute path to a non-hermetic Node.js executable.Only one of node and node_path may be set.
unknown
default:"None"
Npm JavaScript entry point
unknown
default:"\"\""
Path to npm JavaScript entry point.This is typically an absolute path to a non-hermetic npm installation.Only one of npm and npm_path may be set.
unknown
default:"[]"
Additional source files required to run npm.Not necessary if specifying npm_path to a non-hermetic npm installation.
unknown
default:"None"
cc_library that contains the Node/v8 header files
unknown
Additional parameters

Function: node_toolchain

Deprecated. Use nodejs_toolchain instead.

Parameters

unknown
Parameters to forward to nodejs_toolchain rule.

Provider: NodeInfo

Information about how to invoke Node.js and npm.

Fields

Node.js executableIf set, node_path will not be set.
Path to Node.js executable; typically an absolute path to a non-hermetic Node.js.If set, node will not be set.
Npm JavaScript entry point FileFor backward compability, if set then npm_path will be set to the runfiles path of npm.
Path to npm JavaScript entry point; typically an absolute path to a non-hermetic Node.js.For backward compability, npm_path is set to the runfiles path of npm if npm is set.
Additional source files required to run npm
Optional. (struct) Information about the header files, with fields:
  • providers_map: a dict of string to provider instances. The key should be a fully qualified name (e.g. @rules_foo//bar:baz.bzl#MyInfo) of the provider to uniquely identify its type. The following keys are always present:
    • CcInfo: the CcInfo provider instance for the headers.
    • DefaultInfo: the DefaultInfo provider instance for the headers.
    A map is used to allow additional providers from the originating headers target (typically a cc_library) to be propagated to consumers (directly exposing a Target object can cause memory issues and is an anti-pattern). When consuming this map, it’s suggested to use providers_map.values() to return all providers; or copy the map and filter out or replace keys as appropriate. Note that any keys beginning with _ (underscore) are considered private and should be forward along as-is (this better allows e.g. :current_node_cc_headers to act as the underlying headers target it represents).
(DEPRECATED) Path to Node.js executable for backward compatibility
(DEPRECATED) Alias for [node] for backward compatibility
(DEPRECATED) Alias for npm_sources.to_list()