Skip to content

Commit

Permalink
Renames @npm to @rules_prerender_npm.
Browse files Browse the repository at this point in the history
We can't generally claim the workspace name `@npm` since it is very likely that user code will want to declare that workspace for itself. Instead, we use `@rules_prerender_npm` which installs the `package.json` in the `@rules_prerender` repository. Users can define their own `@npm` which installs their own `package.json`.

Unfortunately this means that local development in this repository is a bit confusing since the `@npm` workspace doesn't exist, though this is a small price to pay.
  • Loading branch information
dgp1130 committed Feb 18, 2023
1 parent d15a7cc commit 9733afd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_prerender_npm//:defs.bzl", "npm_link_all_packages")
load("//tools/publish:npm_publish.bzl", "npm_publish")
load("//tools/stamping:stamp_package.bzl", "stamp_package")
load("//tools:typescript.bzl", "types_only")
Expand Down
6 changes: 4 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ nodejs_register_toolchains(
)

# Install NPM packages from the lockfile.
# NOTE: We can't name this `@npm` because that name is very likely used by the
# user's workspace, and we would conflict with that.
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
npm_translate_lock(
name = "npm",
name = "rules_prerender_npm",
pnpm_lock = "//:pnpm-lock.yaml",
npmrc = "//:.npmrc",
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")
load("@rules_prerender_npm//:repositories.bzl", "npm_repositories")
npm_repositories()

http_archive(
Expand Down
2 changes: 1 addition & 1 deletion examples/external/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm_user//:defs.bzl", "npm_link_all_packages")
load(
"@rules_prerender//:index.bzl",
"link_prerender_component",
"prerender_pages",
"web_resources_devserver",
)
load("@rules_prerender_npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

Expand Down
4 changes: 2 additions & 2 deletions examples/external/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ nodejs_register_toolchains(

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
npm_translate_lock(
name = "npm_user",
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
npmrc = "//:.npmrc",
)
load("@npm_user//:repositories.bzl", "npm_repositories")
load("@npm//:repositories.bzl", "npm_repositories")
npm_repositories()

# Load `@aspect_rules_ts` dependency.
Expand Down
2 changes: 1 addition & 1 deletion npm_repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@jasmine//:npm_repositories.bzl", jasmine_npm_repositories = "npm_repositories")
load("@npm//:repositories.bzl", js_npm_repositories = "npm_repositories")
load("@rollup//:npm_repositories.bzl", rollup_npm_repositories = "npm_repositories")
load("@rules_prerender_npm//:repositories.bzl", js_npm_repositories = "npm_repositories")

def npm_repositories():
js_npm_repositories()
Expand Down
2 changes: 1 addition & 1 deletion packages/rules_prerender/web_resources_devserver.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Defines `web_resources_devserver()` functionality."""

load("@aspect_rules_js//js:defs.bzl", "js_run_devserver")
load("@npm//:http-server/package_json.bzl", http_server_bin = "bin")
load("@rules_prerender_npm//:http-server/package_json.bzl", http_server_bin = "bin")
load("//common:label.bzl", "absolute", "file_path_of")

def web_resources_devserver(
Expand Down
8 changes: 4 additions & 4 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
def rules_prerender_repositories():
rules_js_dependencies()
npm_translate_lock(
name = "npm",
pnpm_lock = "@rules_prerender//:pnpm-lock.yaml",
npmrc = "@rules_prerender//:.npmrc",
name = "rules_prerender_npm",
pnpm_lock = Label("//:pnpm-lock.yaml"),
npmrc = Label("//:.npmrc"),
)

rules_ts_dependencies(ts_version_from = "@rules_prerender//:package.json")
rules_ts_dependencies(ts_version_from = Label("//:package.json"))

if "rollup" not in native.existing_rules():
rules_rollup_dependencies()
Expand Down

0 comments on commit 9733afd

Please sign in to comment.