blob: 688e59e3c3f63317cd953e11a8f27566b76124f1 [file]
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("//packages/jasmine:index.bzl", "jasmine_node_test")
load("//packages/rollup:index.bzl", "rollup_bundle")
load("//packages/concatjs:index.bzl", "ts_library")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
name = "produces_files",
out = "a_dep",
content = ["a_dep content"],
)
ts_library(
name = "ts_library",
srcs = ["foo.ts"],
data = ["data.json"],
)
rollup_bundle(
name = "rollup/bundle/subdirectory",
entry_points = {
"foo.ts": "index",
},
output_dir = True,
deps = [":ts_library"],
)
pkg_npm(
name = "dependent_pkg",
srcs = ["dependent_file"],
)
pkg_npm(
name = "test_pkg",
package_name = "test-pkg",
srcs = [
"package.json",
"some_file",
"@internal_npm_package_test_vendored_external//:vendored_external_file",
],
nested_packages = [":dependent_pkg"],
stamp = "@rules_nodejs//nodejs/stamp:always",
substitutions = {
"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
"replace_me": "replaced",
},
vendor_external = [
"internal_npm_package_test_vendored_external",
],
deps = [
":bundle.min.js",
":produces_files",
":rollup/bundle/subdirectory",
":ts_library",
"//internal/pkg_npm/test/transition:test_lib",
"@internal_npm_package_test_vendored_external//:ts_library",
],
)
pkg_npm(
name = "test_noop_pkg",
# Special case where these is a single dep that is a directory artifact
# then we assume the package is contained within that single directory
# and the pkg_npm rules does not need to copy any files
deps = [":rollup/bundle/subdirectory"],
)
pkg_npm(
name = "test_noop2_pkg",
# Special case where these is a single dep that is a directory artifact
# then we assume the package is contained within that single directory
# and the pkg_npm rules does not need to copy any files
srcs = [":rollup/bundle/subdirectory"],
)
sh_test(
name = "test_pkg_pack",
srcs = ["diff_pack_dir.sh"],
args = [
"$(rootpath :test_pkg.pack)",
"$(rootpath :test_pkg)",
],
data = [
":test_pkg",
":test_pkg.pack",
"//third_party/github.com/bazelbuild/bazel/tools/bash/runfiles",
],
tags = ["no-rbe"],
)
jasmine_node_test(
name = "test",
srcs = ["pkg_npm.spec.js"],
data = [
":test_noop2_pkg",
":test_noop_pkg",
":test_pkg",
],
templated_args = [
"$(rootpath :test_pkg)",
"$(rootpath :test_noop_pkg)",
"$(rootpath :test_noop2_pkg)",
],
)
genrule(
name = "bundle",
outs = ["bundle.min.js"],
cmd = "echo -n 'bundle content' > $@",
)