diff --git a/docs/Rollup.md b/docs/Rollup.md
index 0a341f72f6..3cf0df6db1 100755
--- a/docs/Rollup.md
+++ b/docs/Rollup.md
@@ -153,7 +153,7 @@ If not set, a default basic Rollup config is used.
diff --git a/docs/TypeScript.md b/docs/TypeScript.md
index 821d3073fe..fde6651fee 100755
--- a/docs/TypeScript.md
+++ b/docs/TypeScript.md
@@ -174,7 +174,7 @@ Create a BUILD file next to your sources:
{% highlight python %}
package(default_visibility=["//visibility:public"])
-load("//packages/typescript:index.bzl", "ts_library")
+load("@npm//@bazel/typescript:index.bzl", "ts_library")
ts_library(
name = "my_code",
@@ -289,7 +289,7 @@ To use ts_devserver, you simply load the rule, and cal
point to your ts_library target(s):
{% highlight python %}
-load("//packages/typescript:index.bzl", "ts_devserver", "ts_library")
+load("@npm//@bazel/typescript:index.bzl", "ts_devserver", "ts_library")
ts_library(
name = "app",
@@ -521,7 +521,7 @@ ts_devserver(name, Label
diff --git a/tools/stardoc/post-process-docs.js b/tools/stardoc/post-process-docs.js
index a6bcaeebb4..c6433f6a24 100644
--- a/tools/stardoc/post-process-docs.js
+++ b/tools/stardoc/post-process-docs.js
@@ -11,6 +11,14 @@ const out = content
.replace(/```(\w*?)\n((?:(?!```)[\s\S])+)```/g, (str, lang, block) => {
// if no lang is defined, assume Python, it's likely right and the param is required
return `{% highlight ${lang ? lang.trim() : 'python'} %}\n${block}{% endhighlight %}`;
+ })
+ // replace the //packages/foo from the docs with references to @npm//@bazel/foo
+ // @npm is not the required name, but it seems to be the common case
+ // this reflects the similar transformation made when publishing the packages to npm
+ // via pkg_npm defined in //tools:defaults.bzl
+ .replace(/(?:@.*)*?\/\/packages\/([^:"\s]*)/g, (str, pkg) => {
+ const parts = pkg.split('/');
+ return `@npm//@bazel/${parts[parts.length - 1]}`;
});
// stamp the frontmatter into the post processed stardoc HTML