Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.48 KB

changing-rules.md

File metadata and controls

53 lines (41 loc) · 1.48 KB
title layout toc
Patching changes to rules_nodejs
default
true

Patching changes

One advantage of open-source software is that you can make your own changes that suit your needs.

The @rules_nodejs module can simply be fetched from sources in place of the published distribution. For example, in place of

http_archive(
    name = "rules_nodejs",
    sha256 = "...",
    urls = ["https://github.com/bazel-contrib/rules_nodejs/releases/download/6.0.0/rules_nodejs-6.0.0.tar.gz"],
)

you can just use a commit from your fork:

http_archive(
    name = "rules_nodejs",
    sha256 = "...",
    strip_prefix = "rules_nodejs-abcd123",
    url = "https://github.com/my-org/rules_nodejs/archive/abcd123.tar.gz",
)

Patching the rules_nodejs release

Bazel has a handy patching mechanism that lets you easily apply a local patch to the release artifact for built-in rules: the patches attribute to http_archive.

First, make your changes in a clone of the rules_nodejs repo. Export a patch file simply using git diff:

git diff > my.patch

Then copy the patch file somewhere in your repo and point to it from your WORKSPACE file:

http_archive(
    name = "rules_nodejs",
    patch_args = ["-p1"],
    patches = ["//path/to/my.patch"],
    sha256 = "...",
    urls = ["https://github.com/bazel-contrib/rules_nodejs/releases/download/6.0.0/rules_nodejs-6.0.0.tar.gz"],
)