From df7608e7b84282cf12097f4138941bbd8e62fade Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Sun, 7 Apr 2024 15:44:50 -0700 Subject: [PATCH] chore: change all internal virtual store naming to package store (#1616) --- BUILD.bazel | 2 +- MODULE.bazel | 2 +- WORKSPACE | 2 +- docs/README.md | 6 +- docs/js_run_devserver.md | 4 +- docs/npm_import.md | 2 +- docs/npm_link_package.md | 8 +- docs/troubleshooting.md | 2 +- .../bzlmod/segfault-handler_defs.bzl | 2 +- .../snapshots/wksp/segfault-handler_defs.bzl | 2 +- js/private/js_run_devserver.bzl | 8 +- js/private/js_run_devserver.mjs | 8 +- .../js_run_devserver.spec.mjs | 4 +- js/private/test/node-patches/realpath.js | 18 ++-- npm/private/npm_import.bzl | 62 ++++++------- npm/private/npm_link_package.bzl | 14 +-- npm/private/npm_link_package_store.bzl | 18 ++-- npm/private/npm_package_store.bzl | 90 +++++++++---------- npm/private/npm_package_store_info.bzl | 4 +- npm/private/npm_translate_lock_generate.bzl | 24 ++--- npm/private/test/BUILD.bazel | 2 +- .../snapshots/bzlmod/chalk_links_defs.bzl | 2 +- .../snapshots/bzlmod/fsevents_links_defs.bzl | 2 +- .../snapshots/bzlmod/rollup_links_defs.bzl | 2 +- .../snapshots/bzlmod/unused_links_defs.bzl | 2 +- .../test/snapshots/wksp/chalk_links_defs.bzl | 2 +- .../snapshots/wksp/fsevents_links_defs.bzl | 2 +- .../test/snapshots/wksp/rollup_links_defs.bzl | 2 +- .../test/snapshots/wksp/unused_links_defs.bzl | 2 +- npm/private/test/utils_tests.bzl | 6 +- npm/private/utils.bzl | 12 +-- 31 files changed, 159 insertions(+), 159 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 42859daef..7ae96ef28 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -9,7 +9,7 @@ load("//npm:defs.bzl", "npm_link_package") load("//js:defs.bzl", "js_library") # Link all packages from the /WORKSPACE npm_translate_lock(name = "npm") and also packages from -# manual /WORKSPACE npm_import rules to bazel-bin/node_modules as well as the virtual store +# manual /WORKSPACE npm_import rules to bazel-bin/node_modules as well as the package store # bazel-bin/node_modules/.aspect_rules_js since /pnpm-lock.yaml is the root of the pnpm workspace npm_link_all_packages( name = "node_modules", diff --git a/MODULE.bazel b/MODULE.bazel index 45a868696..47a847dae 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -230,7 +230,7 @@ npm.npm_import( bins = {"acorn": "./bin/acorn"}, integrity = "sha512-ULr0LDaEqQrMFGyQ3bhJkLsbtrQ8QibAseGZeaSUiT/6zb9IvIkomWHJIvgvwad+hinRAgsI51JcWk2yvwyL+w==", package = "acorn", - # Root package where to link the virtual store + # Root package where to link the package store root_package = "", version = "8.4.0", ) diff --git a/WORKSPACE b/WORKSPACE index f10b35efc..7324503e7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -184,7 +184,7 @@ npm_import( bins = {"acorn": "./bin/acorn"}, integrity = "sha512-ULr0LDaEqQrMFGyQ3bhJkLsbtrQ8QibAseGZeaSUiT/6zb9IvIkomWHJIvgvwad+hinRAgsI51JcWk2yvwyL+w==", package = "acorn", - # Root package where to link the virtual store + # Root package where to link the package store root_package = "", version = "8.4.0", ) diff --git a/docs/README.md b/docs/README.md index f0cde7af0..96fd12ecc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -52,7 +52,7 @@ Installation is included in the `WORKSPACE` snippet you pasted from the Installa ### Fetch third-party packages from npm rules_js accesses npm packages using [pnpm]. -pnpm's "virtual store" of packages aligns with Bazel's "external repositories", +pnpm's ["symlinked node_modules structure"](https://pnpm.io/symlinked-node-modules-structure) of packages aligns with Bazel's "external repositories", and the pnpm "linker" which creates the `node_modules` tree has semantics we can reproduce with Bazel actions. If your code works with pnpm, then you should expect it works under Bazel as well. @@ -132,9 +132,9 @@ You can see this working by running `bazel build ...`, then look in the `bazel-b You'll see something like this: ```bash -# the virtual store +# the package store bazel-bin/node_modules/.aspect_rules_js -# symlink into the virtual store +# symlink into the package store bazel-bin/node_modules/some_pkg # If you used pnpm workspaces: bazel-bin/packages/some_pkg/node_modules/some_dep diff --git a/docs/js_run_devserver.md b/docs/js_run_devserver.md index 207fb12bd..f95c9a371 100644 --- a/docs/js_run_devserver.md +++ b/docs/js_run_devserver.md @@ -77,8 +77,8 @@ compatible with devserver watch modes in Node.js tools such as Webpack and Next. The custom sandbox is populated with the default outputs of all targets in `data` as well as transitive sources & npm links. -As an optimization, virtual store files are explicitly excluded from the sandbox since the npm -links will point to the virtual store in the execroot and Node.js will follow those links as it +As an optimization, package store files are explicitly excluded from the sandbox since the npm +links will point to the package store in the execroot and Node.js will follow those links as it does within the execroot. As a result, rules_js npm package link targets such as `//:node_modules/next` are handled efficiently. Since these targets are symlinks in the output tree, they are recreated as symlinks in the custom sandbox and do not incur a full copy of the diff --git a/docs/npm_import.md b/docs/npm_import.md index 2c8dca12d..7ee1f88ab 100644 --- a/docs/npm_import.md +++ b/docs/npm_import.md @@ -138,7 +138,7 @@ Read more about the downloader config: deps | A dict other npm packages this one depends on where the key is the package name and value is the version | `{}` | | extra_build_content | Additional content to append on the generated BUILD file at the root of the created repository, either as a string or a list of lines similar to . | `""` | | transitive_closure | A dict all npm packages this one depends on directly or transitively where the key is the package name and value is a list of version(s) depended on in the closure. | `{}` | -| root_package | The root package where the node_modules virtual store is linked to. Typically this is the package that the pnpm-lock.yaml file is located when using `npm_translate_lock`. | `""` | +| root_package | The root package where the node_modules package store is linked to. Typically this is the package that the pnpm-lock.yaml file is located when using `npm_translate_lock`. | `""` | | link_workspace | The workspace name where links will be created for this package.

This is typically set in rule sets and libraries that are to be consumed as external repositories so links are created in the external repository and not the user workspace.

Can be left unspecified if the link workspace is the user workspace. | `""` | | link_packages | Dict of paths where links may be created at for this package to a list of link aliases to link as in each package. If aliases are an empty list this indicates to link as the package name.

Defaults to {} which indicates that links may be created in any package as specified by the `direct` attribute of the generated npm_link_package. | `{}` | | lifecycle_hooks | List of lifecycle hook `package.json` scripts to run for this package if they exist. | `[]` | diff --git a/docs/npm_link_package.md b/docs/npm_link_package.md index b91123d3b..ee63c2c41 100644 --- a/docs/npm_link_package.md +++ b/docs/npm_link_package.md @@ -13,10 +13,10 @@ npm_link_package(name, ` symlink and transitively -its virtual store link and the virtual store links of the transitive closure of deps. +its package store link and the package store links of the transitive closure of deps. When linking, `{name}/dir` filegroup is also generated that refers to a directory artifact can be used to access the package directory for creating entry points or accessing files in the package. @@ -27,8 +27,8 @@ the package directory for creating entry points or accessing files in the packag | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| name | The name of the link target to create if `link` is True. For first-party deps linked across a workspace, the name must match in all packages being linked as it is used to derive the virtual store link target name. | none | -| root_package | the root package where the node_modules virtual store is linked to | `""` | +| name | The name of the link target to create if `link` is True. For first-party deps linked across a workspace, the name must match in all packages being linked as it is used to derive the package store link target name. | none | +| root_package | the root package where the node_modules package store is linked to | `""` | | link | whether or not to link in this package If false, only the npm_package_store target will be created _if_ this is called in the `root_package`. | `True` | | src | the npm_package target to link; may only to be specified when linking in the root package | `None` | | deps | list of npm_package_store; may only to be specified when linking in the root package | `{}` | diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 49955af5b..735efd098 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -103,7 +103,7 @@ The documentation says the value provided to each element in the map is: > a list of Bazel packages in which to hoist the package to the top-level of the node_modules tree To make plugins work, you should have the Bazel package containing the pnpm workspace root (the folder containing `pnpm-lock.yaml`) in this list. -This ensures that the tool in the pnpm virtual store `node_modules/.aspect_rules_js` will be able to locate the plugins. +This ensures that the tool in the package store (`node_modules/.aspect_rules_js`) will be able to locate the plugins. If your lockfile is in the root of the Bazel workspace, this value should be an empty string: `""`. If the lockfile is in `some/subpkg/pnpm-lock.yaml` then `"some/subpkg"` should appear in the list. diff --git a/e2e/gyp_no_install_script/snapshots/bzlmod/segfault-handler_defs.bzl b/e2e/gyp_no_install_script/snapshots/bzlmod/segfault-handler_defs.bzl index 4732364ea..c6594baa3 100644 --- a/e2e/gyp_no_install_script/snapshots/bzlmod/segfault-handler_defs.bzl +++ b/e2e/gyp_no_install_script/snapshots/bzlmod/segfault-handler_defs.bzl @@ -153,7 +153,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@aspect_rules_js~~npm~npm__segfault-handler__1.3.0//:pkg", diff --git a/e2e/gyp_no_install_script/snapshots/wksp/segfault-handler_defs.bzl b/e2e/gyp_no_install_script/snapshots/wksp/segfault-handler_defs.bzl index 05948b8d6..a77dc4eb4 100644 --- a/e2e/gyp_no_install_script/snapshots/wksp/segfault-handler_defs.bzl +++ b/e2e/gyp_no_install_script/snapshots/wksp/segfault-handler_defs.bzl @@ -153,7 +153,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@npm__segfault-handler__1.3.0//:pkg", diff --git a/js/private/js_run_devserver.bzl b/js/private/js_run_devserver.bzl index de2c8dad4..0320ebbca 100644 --- a/js/private/js_run_devserver.bzl +++ b/js/private/js_run_devserver.bzl @@ -50,12 +50,12 @@ def _js_run_devserver_impl(ctx): )] # The .to_list() calls here are intentional and cannot be avoided; they should be small sets of - # files as they only include direct npm links (node_modules/foo) and the virtual store tree + # files as they only include direct npm links (node_modules/foo) and the package store tree # artifacts those symlinks point to (node_modules/.aspect_rules_js/foo@1.2.3/node_modules/foo) data_files = [] for f in depset(transitive = transitive_runfiles + [dep.files for dep in ctx.attr.data]).to_list(): if "/.aspect_rules_js/" in f.path: - # Special handling for virtual store deps; we only include 1st party deps since copying + # Special handling for package store deps; we only include 1st party deps since copying # all 3rd party node_modules over is expensive for typical graphs path_segments = f.path.split("/") package_name_segment = path_segments.index(".aspect_rules_js") + 1 @@ -196,8 +196,8 @@ def js_run_devserver( The custom sandbox is populated with the default outputs of all targets in `data` as well as transitive sources & npm links. - As an optimization, virtual store files are explicitly excluded from the sandbox since the npm - links will point to the virtual store in the execroot and Node.js will follow those links as it + As an optimization, package store files are explicitly excluded from the sandbox since the npm + links will point to the package store in the execroot and Node.js will follow those links as it does within the execroot. As a result, rules_js npm package link targets such as `//:node_modules/next` are handled efficiently. Since these targets are symlinks in the output tree, they are recreated as symlinks in the custom sandbox and do not incur a full copy of the diff --git a/js/private/js_run_devserver.mjs b/js/private/js_run_devserver.mjs index be30c38ef..bd6f26593 100644 --- a/js/private/js_run_devserver.mjs +++ b/js/private/js_run_devserver.mjs @@ -52,7 +52,7 @@ export function isNodeModulePath(p) { return false } -// Determines if a file path is a 1p dep in the virtual store. +// Determines if a file path is a 1p dep in the package store. // See js/private/test/js_run_devserver/js_run_devserver.spec.mjs for examples. export function is1pVirtualStoreDep(p) { // unscoped1p: https://regex101.com/r/hBR08J/1 @@ -258,12 +258,12 @@ async function sync(files, sandbox, writePerm) { if (virtualStore1pFiles.length > 0 && process.env.JS_BINARY__LOG_DEBUG) { console.error( - `Syncing ${virtualStore1pFiles.length} first party virtual store dep(s)` + `Syncing ${virtualStore1pFiles.length} first party package store dep(s)` ) } - // Sync first-party virtual store files first since correctly syncing direct 1p node_modules - // symlinks depends on checking if the virtual store synced files exist. + // Sync first-party package store files first since correctly syncing direct 1p node_modules + // symlinks depends on checking if the package store synced files exist. let totalSynced = ( await Promise.all( virtualStore1pFiles.map(async (file) => { diff --git a/js/private/test/js_run_devserver/js_run_devserver.spec.mjs b/js/private/test/js_run_devserver/js_run_devserver.spec.mjs index 71c103605..5b06a0eb2 100644 --- a/js/private/test/js_run_devserver/js_run_devserver.spec.mjs +++ b/js/private/test/js_run_devserver/js_run_devserver.spec.mjs @@ -30,7 +30,7 @@ const is1pVirtualStoreDep_true = [ ] for (const p of is1pVirtualStoreDep_true) { if (!is1pVirtualStoreDep(p)) { - console.error(`ERROR: expected ${p} to be a 1p virtual store dep`) + console.error(`ERROR: expected ${p} to be a 1p package store dep`) process.exit(1) } } @@ -48,7 +48,7 @@ const is1pVirtualStoreDep_false = [ ] for (const p of is1pVirtualStoreDep_false) { if (is1pVirtualStoreDep(p)) { - console.error(`ERROR: expected ${p} to not be a 1p virtual store dep`) + console.error(`ERROR: expected ${p} to not be a 1p package store dep`) process.exit(1) } } diff --git a/js/private/test/node-patches/realpath.js b/js/private/test/node-patches/realpath.js index c52c620e4..39b8d9a1b 100644 --- a/js/private/test/node-patches/realpath.js +++ b/js/private/test/node-patches/realpath.js @@ -513,11 +513,11 @@ describe('testing realpath', async () => { { sandbox: { node_modules: {}, - virtual_store: { pkg: {} }, + package_store: { pkg: {} }, }, execroot: { node_modules: {}, - virtual_store: { + package_store: { pkg: { file: 'contents', }, @@ -527,9 +527,9 @@ describe('testing realpath', async () => { async (fixturesDir) => { fixturesDir = fs.realpathSync(fixturesDir) - // create symlink from execroot/node_modules/pkg to execroot/virtual_store/pkg + // create symlink from execroot/node_modules/pkg to execroot/package_store/pkg fs.symlinkSync( - path.join(fixturesDir, 'execroot', 'virtual_store', 'pkg'), + path.join(fixturesDir, 'execroot', 'package_store', 'pkg'), path.join(fixturesDir, 'execroot', 'node_modules', 'pkg') ) @@ -538,20 +538,20 @@ describe('testing realpath', async () => { path.join( fixturesDir, 'execroot', - 'virtual_store', + 'package_store', 'pkg', 'file' ), path.join( fixturesDir, 'sandbox', - 'virtual_store', + 'package_store', 'pkg', 'file' ) ) fs.symlinkSync( - path.join(fixturesDir, 'sandbox', 'virtual_store', 'pkg'), + path.join(fixturesDir, 'sandbox', 'package_store', 'pkg'), path.join(fixturesDir, 'sandbox', 'node_modules', 'pkg') ) @@ -569,7 +569,7 @@ describe('testing realpath', async () => { const filePath = path.join( fixturesDir, 'sandbox', - 'virtual_store', + 'package_store', 'pkg', 'file' ) @@ -613,7 +613,7 @@ describe('testing realpath', async () => { const filePath2 = path.join( fixturesDir, 'sandbox', - 'virtual_store', + 'package_store', 'pkg' ) diff --git a/npm/private/npm_import.bzl b/npm/private/npm_import.bzl index bf6c8d5ab..4cfe3817d 100644 --- a/npm/private/npm_import.bzl +++ b/npm/private/npm_import.bzl @@ -64,7 +64,7 @@ def npm_imported_package_store(name): deps = {deps} ref_deps = {ref_deps} - store_target_name = "{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name) + store_target_name = "{package_store_root}/{{}}/{package_store_name}".format(link_root_name) # reference target used to avoid circular deps _npm_package_store( @@ -86,7 +86,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if {transitive_closure_pattern} else "{npm_package_target}", @@ -203,7 +203,7 @@ def npm_link_imported_package_store(name): fail(msg) link_root_name = name[:-len("/{{}}".format(link_alias))] - store_target_name = "{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name) + store_target_name = "{package_store_root}/{{}}/{package_store_name}".format(link_root_name) # terminal package store target to link _npm_link_package_store( @@ -275,7 +275,7 @@ def npm_link_imported_package( _BIN_MACRO_TMPL = """ def _{bin_name}_internal(name, link_root_name, **kwargs): - store_target_name = "{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name) + store_target_name = "{package_store_root}/{{}}/{package_store_name}".format(link_root_name) _directory_path( name = "%s__entry_point" % name, directory = "@{link_workspace}//{root_package}:{{}}/dir".format(store_target_name), @@ -297,7 +297,7 @@ def _{bin_name}_internal(name, link_root_name, **kwargs): ) def _{bin_name}_test_internal(name, link_root_name, **kwargs): - store_target_name = "{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name) + store_target_name = "{package_store_root}/{{}}/{package_store_name}".format(link_root_name) _directory_path( name = "%s__entry_point" % name, directory = "@{link_workspace}//{root_package}:{{}}/dir".format(store_target_name), @@ -312,7 +312,7 @@ def _{bin_name}_test_internal(name, link_root_name, **kwargs): ) def _{bin_name}_binary_internal(name, link_root_name, **kwargs): - store_target_name = "{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name) + store_target_name = "{package_store_root}/{{}}/{package_store_name}".format(link_root_name) _directory_path( name = "%s__entry_point" % name, directory = "@{link_workspace}//{root_package}:{{}}/dir".format(store_target_name), @@ -538,7 +538,7 @@ def _npm_import_rule_impl(rctx): rctx_files["BUILD.bazel"].append("\n" + rctx.attr.extra_build_content) if bins: - virtual_store_name = utils.virtual_store_name(rctx.attr.package, rctx.attr.version) + package_store_name = utils.package_store_name(rctx.attr.package, rctx.attr.version) package_name_no_scope = rctx.attr.package.rsplit("/", 1)[-1] for link_package in rctx.attr.link_packages.keys(): @@ -559,8 +559,8 @@ def _npm_import_rule_impl(rctx): package = rctx.attr.package, root_package = rctx.attr.root_package, version = rctx.attr.version, - virtual_store_name = virtual_store_name, - virtual_store_root = utils.virtual_store_root, + package_store_name = package_store_name, + package_store_root = utils.package_store_root, ), ) @@ -637,13 +637,13 @@ def _npm_import_links_rule_impl(rctx): for (dep_name, dep_version) in rctx.attr.deps.items(): store_package, store_version = utils.parse_pnpm_package_key(dep_name, dep_version) if dep_version.startswith("link:") or dep_version.startswith("file:"): - dep_store_target = """"//{root_package}:{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name)""" + dep_store_target = """"//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(link_root_name)""" else: - dep_store_target = """":{virtual_store_root}/{{}}/{virtual_store_name}/ref".format(link_root_name)""" + dep_store_target = """":{package_store_root}/{{}}/{package_store_name}/ref".format(link_root_name)""" dep_store_target = dep_store_target.format( root_package = rctx.attr.root_package, - virtual_store_name = utils.virtual_store_name(store_package, store_version), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(store_package, store_version), + package_store_root = utils.package_store_root, ) ref_deps[dep_store_target] = ref_deps[dep_store_target] + [dep_name] if dep_store_target in ref_deps else [dep_name] @@ -656,26 +656,26 @@ def _npm_import_links_rule_impl(rctx): for dep_version in dep_versions: store_package, store_version = utils.parse_pnpm_package_key(dep_name, dep_version) if dep_version.startswith("link:") or dep_version.startswith("file:"): - dep_store_target = """"//{root_package}:{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name)""" + dep_store_target = """"//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(link_root_name)""" lc_dep_store_target = dep_store_target else: - dep_store_target = """":{virtual_store_root}/{{}}/{virtual_store_name}/pkg".format(link_root_name)""" + dep_store_target = """":{package_store_root}/{{}}/{package_store_name}/pkg".format(link_root_name)""" lc_dep_store_target = dep_store_target if dep_name == rctx.attr.package and dep_version == rctx.attr.version: # special case for lifecycle transitive closure deps; do not depend on # the __pkg of this package as that will be the output directory # of the lifecycle action - lc_dep_store_target = """":{virtual_store_root}/{{}}/{virtual_store_name}/pkg_pre_lc_lite".format(link_root_name)""" + lc_dep_store_target = """":{package_store_root}/{{}}/{package_store_name}/pkg_pre_lc_lite".format(link_root_name)""" dep_store_target = dep_store_target.format( root_package = rctx.attr.root_package, - virtual_store_name = utils.virtual_store_name(store_package, store_version), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(store_package, store_version), + package_store_root = utils.package_store_root, ) lc_dep_store_target = lc_dep_store_target.format( root_package = rctx.attr.root_package, - virtual_store_name = utils.virtual_store_name(store_package, store_version), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(store_package, store_version), + package_store_root = utils.package_store_root, ) lc_deps[lc_dep_store_target] = lc_deps[lc_dep_store_target] + [dep_name] if lc_dep_store_target in lc_deps else [dep_name] @@ -684,21 +684,21 @@ def _npm_import_links_rule_impl(rctx): for (dep_name, dep_version) in rctx.attr.deps.items(): store_package, store_version = utils.parse_pnpm_package_key(dep_name, dep_version) if dep_version.startswith("link:") or dep_version.startswith("file:"): - dep_store_target = """"//{root_package}:{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name)""" + dep_store_target = """"//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(link_root_name)""" else: - dep_store_target = """":{virtual_store_root}/{{}}/{virtual_store_name}".format(link_root_name)""" + dep_store_target = """":{package_store_root}/{{}}/{package_store_name}".format(link_root_name)""" dep_store_target = dep_store_target.format( root_package = rctx.attr.root_package, - virtual_store_name = utils.virtual_store_name(store_package, store_version), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(store_package, store_version), + package_store_root = utils.package_store_root, ) lc_deps[dep_store_target] = lc_deps[dep_store_target] + [dep_name] if dep_store_target in lc_deps else [dep_name] deps[dep_store_target] = deps[dep_store_target] + [dep_name] if dep_store_target in deps else [dep_name] - virtual_store_name = utils.virtual_store_name(rctx.attr.package, rctx.attr.version) + package_store_name = utils.package_store_name(rctx.attr.package, rctx.attr.version) - # "node_modules/{virtual_store_root}/{virtual_store_name}/node_modules/{package}" - lifecycle_output_dir = paths.join("node_modules", utils.virtual_store_root, virtual_store_name, "node_modules", rctx.attr.package) + # "node_modules/{package_store_root}/{package_store_name}/node_modules/{package}" + lifecycle_output_dir = paths.join("node_modules", utils.package_store_root, package_store_name, "node_modules", rctx.attr.package) # strip _links post-fix to get the repository name of the npm sources npm_import_sources_repo_name = rctx.name[:-len(utils.links_repo_suffix)] @@ -738,7 +738,7 @@ def _npm_import_links_rule_impl(rctx): maybe_bins = (""" bins = %s,""" % starlark_codegen_utils.to_dict_attr(rctx.attr.bins, 3)) if len(rctx.attr.bins) > 0 else "" - virtual_store_name = utils.virtual_store_name(rctx.attr.package, rctx.attr.version) + package_store_name = utils.package_store_name(rctx.attr.package, rctx.attr.version) public_visibility = ("//visibility:public" in rctx.attr.package_visibility) @@ -762,8 +762,8 @@ def _npm_import_links_rule_impl(rctx): root_package = rctx.attr.root_package, transitive_closure_pattern = str(transitive_closure_pattern), version = rctx.attr.version, - virtual_store_name = virtual_store_name, - virtual_store_root = utils.virtual_store_root, + package_store_name = package_store_name, + package_store_root = utils.package_store_root, maybe_bins = maybe_bins, dev = rctx.attr.dev, use_default_shell_env = rctx.attr.lifecycle_hooks_use_default_shell_env, @@ -999,7 +999,7 @@ def npm_import( transitive_closure: A dict all npm packages this one depends on directly or transitively where the key is the package name and value is a list of version(s) depended on in the closure. - root_package: The root package where the node_modules virtual store is linked to. + root_package: The root package where the node_modules package store is linked to. Typically this is the package that the pnpm-lock.yaml file is located when using `npm_translate_lock`. link_workspace: The workspace name where links will be created for this package. diff --git a/npm/private/npm_link_package.bzl b/npm/private/npm_link_package.bzl index dfe4f31b8..94edd4f72 100644 --- a/npm/private/npm_link_package.bzl +++ b/npm/private/npm_link_package.bzl @@ -16,10 +16,10 @@ def npm_link_package( **kwargs): """"Links an npm package to node_modules if link is True. - When called at the root_package, a virtual store target is generated named `link__{bazelified_name}__store`. + When called at the root_package, a package store target is generated named `link__{bazelified_name}__store`. When linking, a `{name}` target is generated which consists of the `node_modules/` symlink and transitively - its virtual store link and the virtual store links of the transitive closure of deps. + its package store link and the package store links of the transitive closure of deps. When linking, `{name}/dir` filegroup is also generated that refers to a directory artifact can be used to access the package directory for creating entry points or accessing files in the package. @@ -27,8 +27,8 @@ def npm_link_package( Args: name: The name of the link target to create if `link` is True. For first-party deps linked across a workspace, the name must match in all packages - being linked as it is used to derive the virtual store link target name. - root_package: the root package where the node_modules virtual store is linked to + being linked as it is used to derive the package store link target name. + root_package: the root package where the node_modules package store is linked to link: whether or not to link in this package If false, only the npm_package_store target will be created _if_ this is called in the `root_package`. src: the npm_package target to link; may only to be specified when linking in the root package @@ -61,9 +61,9 @@ def npm_link_package( msg = "src may only be specified when linking in the root package '{}'".format(root_package) fail(msg) - store_target_name = "{virtual_store_root}/{name}".format( + store_target_name = "{package_store_root}/{name}".format( name = name, - virtual_store_root = utils.virtual_store_root, + package_store_root = utils.package_store_root, ) tags = kwargs.pop("tags", []) @@ -71,7 +71,7 @@ def npm_link_package( tags.append("manual") if is_root: - # link the virtual store when linking at the root + # link the package store when linking at the root npm_package_store( name = store_target_name, src = src, diff --git a/npm/private/npm_link_package_store.bzl b/npm/private/npm_link_package_store.bzl index f4c69bc92..70fa03d84 100644 --- a/npm/private/npm_link_package_store.bzl +++ b/npm/private/npm_link_package_store.bzl @@ -8,7 +8,7 @@ load("//js:providers.bzl", "JsInfo", "js_info") _DOC = """Links an npm package that is backed by an npm_package_store into a node_modules tree as a direct dependency. This is used in conjunction with the npm_package_store rule that outputs an npm package into the -node_modules/.aspect_rules_js virtual store in a pnpm style symlinked node_modules structure. +node_modules/.aspect_rules_js package store in a pnpm style symlinked node_modules structure. The term "package" is defined at @@ -63,24 +63,24 @@ exec node "$basedir/{bin_path}" "$@" def _npm_link_package_store_impl(ctx): store_info = ctx.attr.src[NpmPackageStoreInfo] - virtual_store_directory = store_info.virtual_store_directory - if not virtual_store_directory: - fail("src must be a npm_link_package that provides a virtual_store_directory") + package_store_directory = store_info.package_store_directory + if not package_store_directory: + fail("src must be a npm_link_package that provides a package_store_directory") - if virtual_store_directory.owner.workspace_name != ctx.label.workspace_name: - msg = "expected virtual_store_directory to be in the same workspace as the link target '{}' but found '{}'".format( + if package_store_directory.owner.workspace_name != ctx.label.workspace_name: + msg = "expected package_store_directory to be in the same workspace as the link target '{}' but found '{}'".format( ctx.label.workspace_name, - virtual_store_directory.owner.workspace_name, + package_store_directory.owner.workspace_name, ) fail(msg) package = ctx.attr.package if ctx.attr.package else store_info.package - # symlink the package's path in the virtual store to the root of the node_modules + # symlink the package's path in the package store to the root of the node_modules # "node_modules/{package}" so it is available as a direct dependency root_symlink_path = paths.join("node_modules", package) - files = [utils.make_symlink(ctx, root_symlink_path, virtual_store_directory)] + files = [utils.make_symlink(ctx, root_symlink_path, package_store_directory)] for bin_name, bin_path in ctx.attr.bins.items(): bin_file = ctx.actions.declare_file(paths.join("node_modules", ".bin", bin_name)) diff --git a/npm/private/npm_package_store.bzl b/npm/private/npm_package_store.bzl index e26115446..b64a1c5e4 100644 --- a/npm/private/npm_package_store.bzl +++ b/npm/private/npm_package_store.bzl @@ -158,31 +158,31 @@ def _npm_package_store_impl(ctx): if not version: fail("No package version specified to link to. Package version must either be specified explicitly via 'version' attribute or come from the 'src' 'NpmPackageInfo', typically a 'npm_package' target") - virtual_store_name = utils.virtual_store_name(package, version) + package_store_name = utils.package_store_name(package, version) src = None - virtual_store_directory = None + package_store_directory = None files = [] direct_ref_deps = {} npm_package_store_deps = [] if ctx.attr.src: - # output the package as a TreeArtifact to its virtual store location - # "node_modules/{virtual_store_root}/{virtual_store_name}/node_modules/{package}" - virtual_store_directory_path = paths.join("node_modules", utils.virtual_store_root, virtual_store_name, "node_modules", package) + # output the package as a TreeArtifact to its package store location + # "node_modules/{package_store_root}/{package_store_name}/node_modules/{package}" + package_store_directory_path = paths.join("node_modules", utils.package_store_root, package_store_name, "node_modules", package) if ctx.label.workspace_name: - expected_short_path = paths.join("..", ctx.label.workspace_name, ctx.label.package, virtual_store_directory_path) + expected_short_path = paths.join("..", ctx.label.workspace_name, ctx.label.package, package_store_directory_path) else: - expected_short_path = paths.join(ctx.label.package, virtual_store_directory_path) + expected_short_path = paths.join(ctx.label.package, package_store_directory_path) src = ctx.attr.src[NpmPackageInfo].src if src.short_path == expected_short_path: # the input is already the desired output; this is the pattern for # packages with lifecycle hooks - virtual_store_directory = src + package_store_directory = src else: - virtual_store_directory = ctx.actions.declare_directory(virtual_store_directory_path) + package_store_directory = ctx.actions.declare_directory(package_store_directory_path) if utils.is_tarball_extension(src.extension): # npm packages are always published with one top-level directory inside the tarball, tho the name is not predictable # we can use the --strip-components 1 argument with tar to strip one directory level @@ -195,13 +195,13 @@ def _npm_package_store_impl(ctx): args.add("--file") args.add(src.path) args.add("--directory") - args.add(virtual_store_directory.path) + args.add(package_store_directory.path) bsdtar = ctx.toolchains["@aspect_bazel_lib//lib:tar_toolchain_type"] ctx.actions.run( executable = bsdtar.tarinfo.binary, inputs = depset(direct = [src], transitive = [bsdtar.default.files]), - outputs = [virtual_store_directory], + outputs = [package_store_directory], arguments = [args], mnemonic = "NpmPackageExtract", progress_message = "Extracting npm package {}@{}".format(package, version), @@ -210,7 +210,7 @@ def _npm_package_store_impl(ctx): copy_directory_bin_action( ctx, src = src, - dst = virtual_store_directory, + dst = package_store_directory, copy_directory_bin = ctx.toolchains["@aspect_bazel_lib//lib:copy_directory_toolchain_type"].copy_directory_info.bin, # Hardlinking source files in external repositories as was done under the hood # prior to https://github.com/aspect-build/rules_js/pull/1533 may lead to flaky build @@ -219,22 +219,22 @@ def _npm_package_store_impl(ctx): verbose = ctx.attr.verbose, ) - linked_virtual_store_directories = [] + linked_package_store_directories = [] for dep, _dep_aliases in ctx.attr.deps.items(): - # symlink the package's direct deps to its virtual store location + # symlink the package's direct deps to its package store location if dep[NpmPackageStoreInfo].root_package != ctx.label.package: msg = """npm_package_store in %s package cannot depend on npm_package_store in %s package. deps of npm_package_store must be in the same package.""" % (ctx.label.package, dep[NpmPackageStoreInfo].root_package) fail(msg) dep_package = dep[NpmPackageStoreInfo].package dep_aliases = _dep_aliases.split(",") if _dep_aliases else [dep_package] - dep_virtual_store_directory = dep[NpmPackageStoreInfo].virtual_store_directory - if dep_virtual_store_directory: - linked_virtual_store_directories.append(dep_virtual_store_directory) + dep_package_store_directory = dep[NpmPackageStoreInfo].package_store_directory + if dep_package_store_directory: + linked_package_store_directories.append(dep_package_store_directory) for dep_alias in dep_aliases: - # "node_modules/{virtual_store_root}/{virtual_store_name}/node_modules/{package}" - dep_symlink_path = paths.join("node_modules", utils.virtual_store_root, virtual_store_name, "node_modules", dep_alias) - files.append(utils.make_symlink(ctx, dep_symlink_path, dep_virtual_store_directory)) + # "node_modules/{package_store_root}/{package_store_name}/node_modules/{package}" + dep_symlink_path = paths.join("node_modules", utils.package_store_root, package_store_name, "node_modules", dep_alias) + files.append(utils.make_symlink(ctx, dep_symlink_path, dep_package_store_directory)) else: # this is a ref npm_link_package, a downstream terminal npm_link_package # for this npm dependency will create the dep symlinks for this dep; @@ -244,14 +244,14 @@ deps of npm_package_store must be in the same package.""" % (ctx.label.package, for store in ctx.attr.src[NpmPackageInfo].npm_package_store_deps.to_list(): dep_package = store.package - dep_virtual_store_directory = store.virtual_store_directory + dep_package_store_directory = store.package_store_directory # only link npm package store deps from NpmPackageInfo if they have _not_ already been linked directly # from deps; fixes https://github.com/aspect-build/rules_js/issues/1110. - if dep_virtual_store_directory not in linked_virtual_store_directories: - # "node_modules/{virtual_store_root}/{virtual_store_name}/node_modules/{package}" - dep_symlink_path = paths.join("node_modules", utils.virtual_store_root, virtual_store_name, "node_modules", dep_package) - files.append(utils.make_symlink(ctx, dep_symlink_path, dep_virtual_store_directory)) + if dep_package_store_directory not in linked_package_store_directories: + # "node_modules/{package_store_root}/{package_store_name}/node_modules/{package}" + dep_symlink_path = paths.join("node_modules", utils.package_store_root, package_store_name, "node_modules", dep_package) + files.append(utils.make_symlink(ctx, dep_symlink_path, dep_package_store_directory)) npm_package_store_deps.append(store) else: # if ctx.attr.src is _not_ set then this is a terminal 3p package with ctx.attr.deps is @@ -262,38 +262,38 @@ deps of npm_package_store must be in the same package.""" % (ctx.label.package, dep_package = dep[NpmPackageStoreInfo].package dep_aliases = _dep_aliases.split(",") if _dep_aliases else [dep_package] - # create a map of deps that have virtual store directories - if dep[NpmPackageStoreInfo].virtual_store_directory: - deps_map[utils.virtual_store_name(dep[NpmPackageStoreInfo].package, dep[NpmPackageStoreInfo].version)] = dep + # create a map of deps that have package store directories + if dep[NpmPackageStoreInfo].package_store_directory: + deps_map[utils.package_store_name(dep[NpmPackageStoreInfo].package, dep[NpmPackageStoreInfo].version)] = dep else: # this is a ref npm_link_package, a downstream terminal npm_link_package for this npm # depedency will create the dep symlinks for this dep; this pattern is used to break # for lifecycle hooks on 3rd party deps; it is not recommended for 1st party deps direct_ref_deps[dep] = dep_aliases for dep in ctx.attr.deps: - dep_virtual_store_name = utils.virtual_store_name(dep[NpmPackageStoreInfo].package, dep[NpmPackageStoreInfo].version) + dep_package_store_name = utils.package_store_name(dep[NpmPackageStoreInfo].package, dep[NpmPackageStoreInfo].version) dep_ref_deps = dep[NpmPackageStoreInfo].ref_deps - if virtual_store_name == dep_virtual_store_name: + if package_store_name == dep_package_store_name: # provide the node_modules directory for this package if found in the transitive_closure - virtual_store_directory = dep[NpmPackageStoreInfo].virtual_store_directory + package_store_directory = dep[NpmPackageStoreInfo].package_store_directory for dep_ref_dep, dep_ref_dep_aliases in dep_ref_deps.items(): - dep_ref_dep_virtual_store_name = utils.virtual_store_name(dep_ref_dep[NpmPackageStoreInfo].package, dep_ref_dep[NpmPackageStoreInfo].version) - if not dep_ref_dep_virtual_store_name in deps_map: + dep_ref_dep_package_store_name = utils.package_store_name(dep_ref_dep[NpmPackageStoreInfo].package, dep_ref_dep[NpmPackageStoreInfo].version) + if not dep_ref_dep_package_store_name in deps_map: # This can happen in lifecycle npm package targets. We have no choice but to # ignore reference back to self in dyadic circular deps in this case since a # transitive dep on this npm package is impossible in an action that is - # outputting the virtual store tree artifact that circular dep would point to. + # outputting the package store tree artifact that circular dep would point to. continue - actual_dep = deps_map[dep_ref_dep_virtual_store_name] - dep_ref_def_virtual_store_directory = actual_dep[NpmPackageStoreInfo].virtual_store_directory - if dep_ref_def_virtual_store_directory: + actual_dep = deps_map[dep_ref_dep_package_store_name] + dep_ref_def_package_store_directory = actual_dep[NpmPackageStoreInfo].package_store_directory + if dep_ref_def_package_store_directory: for dep_ref_dep_alias in dep_ref_dep_aliases: - # "node_modules/{virtual_store_root}/{virtual_store_name}/node_modules/{package}" - dep_ref_dep_symlink_path = paths.join("node_modules", utils.virtual_store_root, dep_virtual_store_name, "node_modules", dep_ref_dep_alias) - files.append(utils.make_symlink(ctx, dep_ref_dep_symlink_path, dep_ref_def_virtual_store_directory)) + # "node_modules/{package_store_root}/{package_store_name}/node_modules/{package}" + dep_ref_dep_symlink_path = paths.join("node_modules", utils.package_store_root, dep_package_store_name, "node_modules", dep_ref_dep_alias) + files.append(utils.make_symlink(ctx, dep_ref_dep_symlink_path, dep_ref_def_package_store_directory)) - if virtual_store_directory: - files.append(virtual_store_directory) + if package_store_directory: + files.append(package_store_directory) npm_package_store_deps.extend([ target[NpmPackageStoreInfo] @@ -329,17 +329,17 @@ deps of npm_package_store must be in the same package.""" % (ctx.label.package, package = package, version = version, ref_deps = direct_ref_deps, - virtual_store_directory = virtual_store_directory, + package_store_directory = package_store_directory, files = files_depset, transitive_files = transitive_files_depset, dev = ctx.attr.dev, ), ] - if virtual_store_directory: + if package_store_directory: # Provide an output group that provides a single file which is the # package directory for use in $(execpath) and $(rootpath). # Output group name must match utils.package_directory_output_group - providers.append(OutputGroupInfo(package_directory = depset([virtual_store_directory]))) + providers.append(OutputGroupInfo(package_directory = depset([package_store_directory]))) return providers diff --git a/npm/private/npm_package_store_info.bzl b/npm/private/npm_package_store_info.bzl index 910274810..0e5961105 100644 --- a/npm/private/npm_package_store_info.bzl +++ b/npm/private/npm_package_store_info.bzl @@ -1,7 +1,7 @@ "NpmPackageStoreInfo provider" NpmPackageStoreInfo = provider( - doc = """Provides information about an npm package within the virtual store of a pnpm-style + doc = """Provides information about an npm package within the package store of a pnpm-style symlinked node_modules tree. See https://pnpm.io/symlinked-node-modules-structure for more information about @@ -11,7 +11,7 @@ NpmPackageStoreInfo = provider( "package": "name of this npm package", "version": "version of this npm package", "ref_deps": "dictionary of dependency npm_package_store ref targets", - "virtual_store_directory": "the TreeArtifact of this npm package's virtual store location", + "package_store_directory": "the TreeArtifact of this npm package's package store location", "files": "depset of files that are part of the npm package", "transitive_files": "depset of the files that are part of the npm package and its transitive deps", "dev": "whether or not this npm package is a dev dependency", diff --git a/npm/private/npm_translate_lock_generate.bzl b/npm/private/npm_translate_lock_generate.bzl index c0ed5e8f9..29124cabf 100644 --- a/npm/private/npm_translate_lock_generate.bzl +++ b/npm/private/npm_translate_lock_generate.bzl @@ -30,7 +30,7 @@ _FP_STORE_TMPL = \ """ if is_root: _npm_package_store( - name = "{virtual_store_root}/{{}}/{virtual_store_name}".format(name), + name = "{package_store_root}/{{}}/{package_store_name}".format(name), src = "{npm_package_target}", package = "{package}", version = "0.0.0", @@ -46,7 +46,7 @@ _FP_DIRECT_TMPL = \ # terminal target for direct dependencies _npm_link_package_store( name = "{{}}/{name}".format(name), - src = "//{root_package}:{virtual_store_root}/{{}}/{virtual_store_name}".format(name), + src = "//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(name), visibility = {link_visibility}, tags = ["manual"], ) @@ -126,10 +126,10 @@ sh_binary( transitive_deps = {} for raw_package, raw_version in deps.items(): store_package, store_version = utils.parse_pnpm_package_key(raw_package, raw_version) - dep_store_target = """"//{root_package}:{virtual_store_root}/{{}}/{virtual_store_name}".format(name)""".format( + dep_store_target = """"//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(name)""".format( root_package = root_package, - virtual_store_name = utils.virtual_store_name(store_package, store_version), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(store_package, store_version), + package_store_root = utils.package_store_root, ) if dep_store_target not in transitive_deps: transitive_deps[dep_store_target] = [raw_package] @@ -177,10 +177,10 @@ sh_binary( raw_deps = importers.get(dep_importer).get("deps") for raw_package, raw_version in raw_deps.items(): store_package, store_version = utils.parse_pnpm_package_key(raw_package, raw_version) - dep_store_target = """"//{root_package}:{virtual_store_root}/{{}}/{virtual_store_name}".format(name)""".format( + dep_store_target = """"//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(name)""".format( root_package = root_package, - virtual_store_name = utils.virtual_store_name(store_package, store_version), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(store_package, store_version), + package_store_root = utils.package_store_root, ) if dep_store_target not in transitive_deps: transitive_deps[dep_store_target] = [raw_package] @@ -364,8 +364,8 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): deps = starlark_codegen_utils.to_dict_attr(fp_deps, 3, quote_key = False), npm_package_target = fp_target, package = fp_package, - virtual_store_name = utils.virtual_store_name(fp_package, "0.0.0"), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(fp_package, "0.0.0"), + package_store_root = utils.package_store_root, )) package_visibility, _ = helpers.gather_values_from_matching_names(True, rctx.attr.package_visibility, "*", fp_package) @@ -380,8 +380,8 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): name = fp_package, package_directory_output_group = utils.package_directory_output_group, root_package = root_package, - virtual_store_name = utils.virtual_store_name(fp_package, "0.0.0"), - virtual_store_root = utils.virtual_store_root, + package_store_name = utils.package_store_name(fp_package, "0.0.0"), + package_store_root = utils.package_store_root, )) npm_link_targets_bzl.append(_FP_DIRECT_TARGET_TMPL.format( diff --git a/npm/private/test/BUILD.bazel b/npm/private/test/BUILD.bazel index 2037efc82..73c3ac5d5 100644 --- a/npm/private/test/BUILD.bazel +++ b/npm/private/test/BUILD.bazel @@ -88,7 +88,7 @@ sh_test( data = [ # Test that node_modules/.bin binaries work in both the root package # and in subpackages. The relative paths in the two are different since the - # actual node entry is in the virtual store which is in the root package. + # actual node entry is in the package store which is in the root package. "//:node_modules/typescript", ":node_modules/typescript", # This eager toolchain fetching could be cleaed up in the future diff --git a/npm/private/test/snapshots/bzlmod/chalk_links_defs.bzl b/npm/private/test/snapshots/bzlmod/chalk_links_defs.bzl index 44a70305a..07d922db1 100644 --- a/npm/private/test/snapshots/bzlmod/chalk_links_defs.bzl +++ b/npm/private/test/snapshots/bzlmod/chalk_links_defs.bzl @@ -46,7 +46,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@chalk_501//:pkg", diff --git a/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl b/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl index 98442a000..c396bc0cf 100644 --- a/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl +++ b/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl @@ -50,7 +50,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@_main~npm~npm__fsevents__2.3.2//:pkg", diff --git a/npm/private/test/snapshots/bzlmod/rollup_links_defs.bzl b/npm/private/test/snapshots/bzlmod/rollup_links_defs.bzl index 315e1c3bf..022b5eff7 100644 --- a/npm/private/test/snapshots/bzlmod/rollup_links_defs.bzl +++ b/npm/private/test/snapshots/bzlmod/rollup_links_defs.bzl @@ -49,7 +49,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@_main~npm~npm__rollup__2.70.2//:pkg", diff --git a/npm/private/test/snapshots/bzlmod/unused_links_defs.bzl b/npm/private/test/snapshots/bzlmod/unused_links_defs.bzl index d370c633b..dd8d8b61e 100644 --- a/npm/private/test/snapshots/bzlmod/unused_links_defs.bzl +++ b/npm/private/test/snapshots/bzlmod/unused_links_defs.bzl @@ -53,7 +53,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@_main~npm~npm__unused__0.2.2//:pkg", diff --git a/npm/private/test/snapshots/wksp/chalk_links_defs.bzl b/npm/private/test/snapshots/wksp/chalk_links_defs.bzl index 44a70305a..07d922db1 100644 --- a/npm/private/test/snapshots/wksp/chalk_links_defs.bzl +++ b/npm/private/test/snapshots/wksp/chalk_links_defs.bzl @@ -46,7 +46,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@chalk_501//:pkg", diff --git a/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl b/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl index af9c7f2ea..2e2334788 100644 --- a/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl +++ b/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl @@ -50,7 +50,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@npm__fsevents__2.3.2//:pkg", diff --git a/npm/private/test/snapshots/wksp/rollup_links_defs.bzl b/npm/private/test/snapshots/wksp/rollup_links_defs.bzl index 0cb9cccd0..411ec3d40 100644 --- a/npm/private/test/snapshots/wksp/rollup_links_defs.bzl +++ b/npm/private/test/snapshots/wksp/rollup_links_defs.bzl @@ -49,7 +49,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@npm__rollup__2.70.2//:pkg", diff --git a/npm/private/test/snapshots/wksp/unused_links_defs.bzl b/npm/private/test/snapshots/wksp/unused_links_defs.bzl index 17aa02574..630fb48d1 100644 --- a/npm/private/test/snapshots/wksp/unused_links_defs.bzl +++ b/npm/private/test/snapshots/wksp/unused_links_defs.bzl @@ -53,7 +53,7 @@ def npm_imported_package_store(name): tags = ["manual"], ) - # virtual store target with transitive closure of all npm package dependencies + # package store target with transitive closure of all npm package dependencies _npm_package_store( name = store_target_name, src = None if True else "@@npm__unused__0.2.2//:pkg", diff --git a/npm/private/test/utils_tests.bzl b/npm/private/test/utils_tests.bzl index c6fee5c88..fb9ddc3e8 100644 --- a/npm/private/test/utils_tests.bzl +++ b/npm/private/test/utils_tests.bzl @@ -53,9 +53,9 @@ def test_friendly_name(ctx): asserts.equals(env, "@scope/y@2.1.1", utils.friendly_name("@scope/y", "2.1.1")) return unittest.end(env) -def test_virtual_store_name(ctx): +def test_package_store_name(ctx): env = unittest.begin(ctx) - asserts.equals(env, "@scope+y@2.1.1", utils.virtual_store_name("@scope/y", "2.1.1")) + asserts.equals(env, "@scope+y@2.1.1", utils.package_store_name("@scope/y", "2.1.1")) return unittest.end(env) # buildifier: disable=function-docstring @@ -158,7 +158,7 @@ t0_test = unittest.make(test_strip_peer_dep_or_patched_version) t1_test = unittest.make(test_bazel_name) t2_test = unittest.make(test_pnpm_name) t3_test = unittest.make(test_friendly_name) -t4_test = unittest.make(test_virtual_store_name) +t4_test = unittest.make(test_package_store_name) t5_test = unittest.make(test_version_supported) t6_test = unittest.make(test_parse_package_name) t7_test = unittest.make(test_npm_registry_download_url) diff --git a/npm/private/utils.bzl b/npm/private/utils.bzl index e396c6fe0..06d0cf1b4 100644 --- a/npm/private/utils.bzl +++ b/npm/private/utils.bzl @@ -265,10 +265,10 @@ def _friendly_name(name, version): "Make a name@version developer-friendly name for a package name and version" return "%s@%s" % (name, version) -def _virtual_store_name(name, version): - "Make a virtual store name for a given package and version" +def _package_store_name(name, version): + "Make a package store name for a given package and version" if version.startswith("@"): - # Special case where the package name should _not_ be included in the virtual store name. + # Special case where the package name should _not_ be included in the package store name. # See https://github.com/aspect-build/rules_js/issues/423 for more context. return version.replace("/", "+") else: @@ -464,11 +464,11 @@ utils = struct( parse_pnpm_lock_yaml = _parse_pnpm_lock_yaml, parse_pnpm_lock_json = _parse_pnpm_lock_json, friendly_name = _friendly_name, - virtual_store_name = _virtual_store_name, + package_store_name = _package_store_name, strip_peer_dep_or_patched_version = _strip_peer_dep_or_patched_version, make_symlink = _make_symlink, - # Symlinked node_modules structure virtual store path under node_modules - virtual_store_root = ".aspect_rules_js", + # Symlinked node_modules structure package store path under node_modules + package_store_root = ".aspect_rules_js", # Suffix for npm_import links repository links_repo_suffix = "__links", # Output group name for the package directory of a linked package