Skip to content

Commit

Permalink
fix(npm): invalid export of package/resolved.json (#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jul 22, 2024
1 parent be3098c commit 45c84b1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ BZL_FILES = {
# global
"defs.bzl": "@REPO_NAME//:defs.bzl",

# resolved.json reference
"is-odd_resolved.json": "@REPO_NAME//VERSION:is-odd/resolved.json",

# hasBin, optional deps, deps
"rollup_links_defs.bzl": "@REPO_NAME__rollup__2.14.0__links//:defs.bzl",
"rollup_package_json.bzl": "@REPO_NAME__rollup__2.14.0//VERSION:package_json.bzl",
Expand Down
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/v54/snapshots/is-odd_resolved.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/v60/snapshots/is-odd_resolved.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/v61/snapshots/is-odd_resolved.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/v90/snapshots/is-odd_resolved.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions npm/private/npm_translate_lock_generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,15 @@ def npm_link_all_packages(name = "node_modules", imported_links = []):
build_file = "{}/{}".format(link_package, "BUILD.bazel") if link_package else "BUILD.bazel"
if build_file not in rctx_files:
rctx_files[build_file] = []
resolved_json_file_path = "{}/{}/{}".format(link_package, _import.package, _RESOLVED_JSON_FILENAME).lstrip("/")
resolved_json_rel_path = "{}/{}".format(_import.package, _RESOLVED_JSON_FILENAME) if _import.package else _RESOLVED_JSON_FILENAME
resolved_json_file_path = "{}/{}".format(link_package, resolved_json_rel_path) if link_package else resolved_json_rel_path
rctx.file(resolved_json_file_path, json.encode({
# Allow consumers to auto-detect this filetype
"$schema": "https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock",
"version": _import.version,
"integrity": _import.integrity,
}))
rctx_files[build_file].append("exports_files([\"{}\"])".format(resolved_json_file_path))
rctx_files[build_file].append("exports_files([\"{}\"])".format(resolved_json_rel_path))
if _import.package_info.get("has_bin"):
if rctx.attr.generate_bzl_library_targets:
rctx_files[build_file].append("""load("@bazel_skylib//:bzl_library.bzl", "bzl_library")""")
Expand Down

0 comments on commit 45c84b1

Please sign in to comment.