From 9733afdd47bd30440e5c08cf72be0e654bf5cdc1 Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Sat, 18 Feb 2023 12:54:44 -0800 Subject: [PATCH] Renames `@npm` to `@rules_prerender_npm`. 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. --- BUILD.bazel | 2 +- WORKSPACE.bazel | 6 ++++-- examples/external/BUILD.bazel | 2 +- examples/external/WORKSPACE.bazel | 4 ++-- npm_repositories.bzl | 2 +- packages/rules_prerender/web_resources_devserver.bzl | 2 +- repositories.bzl | 8 ++++---- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 05625481..300dc22e 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 3ceea89a..7a0f16f0 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -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( diff --git a/examples/external/BUILD.bazel b/examples/external/BUILD.bazel index b63bc8a8..4358bbf1 100644 --- a/examples/external/BUILD.bazel +++ b/examples/external/BUILD.bazel @@ -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") diff --git a/examples/external/WORKSPACE.bazel b/examples/external/WORKSPACE.bazel index 1bc021aa..e560df78 100644 --- a/examples/external/WORKSPACE.bazel +++ b/examples/external/WORKSPACE.bazel @@ -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. diff --git a/npm_repositories.bzl b/npm_repositories.bzl index 5b1f9518..efc94a09 100644 --- a/npm_repositories.bzl +++ b/npm_repositories.bzl @@ -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() diff --git a/packages/rules_prerender/web_resources_devserver.bzl b/packages/rules_prerender/web_resources_devserver.bzl index 603acbd0..24be38e3 100644 --- a/packages/rules_prerender/web_resources_devserver.bzl +++ b/packages/rules_prerender/web_resources_devserver.bzl @@ -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( diff --git a/repositories.bzl b/repositories.bzl index a9f95a51..a09a37b1 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -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()