Skip to content

Commit

Permalink
chore: normalize "lib" vs "pkg" terminology in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jul 27, 2024
1 parent eb47b67 commit e460067
Show file tree
Hide file tree
Showing 35 changed files with 71 additions and 71 deletions.
24 changes: 12 additions & 12 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

# Building this target results in bazel-bin/examples/node_modules/@myorg/js_lib, so that
# Building this target results in bazel-bin/examples/node_modules/@myorg/js_pkg, so that
# TypeScript and other node programs beneath bazel-bin/examples are able to resolve its location.
npm_link_package(
name = "node_modules/@myorg/js_lib",
src = "//examples/js_lib:pkg",
name = "node_modules/@myorg/js_pkg",
src = "//examples/js_pkg:pkg",
root_package = "examples",
visibility = ["//examples:__subpackages__"],
)

npm_link_package(
name = "node_modules/@myorg/js_lib_pkg",
src = "//examples/js_lib_pkg:pkg",
package = "@myorg/js_lib_pkg",
name = "node_modules/@myorg/js_lib",
src = "//examples/js_lib:pkg",
package = "@myorg/js_lib",
root_package = "examples",
visibility = ["//examples:__subpackages__"],
)

npm_link_package(
name = "node_modules/@myorg/dts_lib",
src = "//examples/dts_lib:pkg",
name = "node_modules/@myorg/dts_pkg",
src = "//examples/dts_pkg:pkg",
root_package = "examples",
visibility = ["//examples:__subpackages__"],
)
Expand All @@ -35,15 +35,15 @@ npm_link_package(
)

npm_link_package(
name = "node_modules/@myorg/deps_lib",
src = "//examples/deps_lib:pkg",
name = "node_modules/@myorg/deps_pkg",
src = "//examples/deps_pkg:pkg",
root_package = "examples",
visibility = ["//examples:__subpackages__"],
)

npm_link_package(
name = "node_modules/@myorg/deps_lib_transpiler",
src = "//examples/deps_lib_transpiler:pkg",
name = "node_modules/@myorg/deps_pkg_transpiler",
src = "//examples/deps_pkg_transpiler:pkg",
root_package = "examples",
visibility = ["//examples:__subpackages__"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ts_project(
declaration = True,
deps = [
"//examples:node_modules/date-fns",
"//examples/deps_lib/b",
"//examples/deps_pkg/b",
],
)

Expand All @@ -27,7 +27,7 @@ npm_package(
srcs = [
":lib",
],
package = "@myorg/deps_lib",
package = "@myorg/deps_pkg",
visibility = ["//examples:__subpackages__"],
)

Expand All @@ -45,6 +45,6 @@ ts_project(
srcs = ["importer_linked.ts"],
declaration = True,
deps = [
"//examples:node_modules/@myorg/deps_lib",
"//examples:node_modules/@myorg/deps_pkg",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ts_project(
name = "b",
srcs = ["index.ts"],
declaration = True,
tsconfig = "//examples/deps_lib:tsconfig",
visibility = ["//examples/deps_lib:__subpackages__"],
tsconfig = "//examples/deps_pkg:tsconfig",
visibility = ["//examples/deps_pkg:__subpackages__"],
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { b, format } from '@myorg/deps_lib'
import { b, format } from '@myorg/deps_pkg'

export const a: string = `number: 1, date: ${format(
new Date(2014, 1, 11),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ts_project(
transpiler = babel,
deps = [
"//examples:node_modules/date-fns",
"//examples/deps_lib_transpiler/b",
"//examples/deps_pkg_transpiler/b",
],
)

Expand All @@ -29,7 +29,7 @@ npm_package(
srcs = [
":lib",
],
package = "@myorg/deps_lib_transpiler",
package = "@myorg/deps_pkg_transpiler",
visibility = ["//examples:__subpackages__"],
)

Expand All @@ -49,6 +49,6 @@ ts_project(
declaration = True,
transpiler = babel,
deps = [
"//examples:node_modules/@myorg/deps_lib_transpiler",
"//examples:node_modules/@myorg/deps_pkg_transpiler",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ ts_project(
srcs = ["index.ts"],
declaration = True,
transpiler = babel,
tsconfig = "//examples/deps_lib_transpiler:tsconfig",
visibility = ["//examples/deps_lib_transpiler:__subpackages__"],
tsconfig = "//examples/deps_pkg_transpiler:tsconfig",
visibility = ["//examples/deps_pkg_transpiler:__subpackages__"],
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { b, format } from '@myorg/deps_lib_transpiler'
import { b, format } from '@myorg/deps_pkg_transpiler'

export const a: string = `number: 1, date: ${format(
new Date(2014, 1, 11),
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions examples/dts_lib/importer_linked.ts

This file was deleted.

2 changes: 0 additions & 2 deletions examples/dts_lib/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion examples/dts_lib/lib_types.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion examples/dts_lib/lib_types_2.d.mts

This file was deleted.

4 changes: 2 additions & 2 deletions examples/dts_lib/BUILD.bazel → examples/dts_pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ts_project(
npm_package(
name = "pkg",
srcs = [":lib"],
package = "@myorg/dts_lib",
package = "@myorg/dts_pkg",
visibility = ["//examples:__subpackages__"],
)

Expand All @@ -34,7 +34,7 @@ ts_project(
srcs = ["importer_linked.ts"],
declaration = True,
deps = [
"//examples:node_modules/@myorg/dts_lib",
"//examples:node_modules/@myorg/dts_pkg",
],
)

Expand Down
4 changes: 4 additions & 0 deletions examples/dts_pkg/importer_linked.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { A, B } from '@myorg/dts_pkg'

export const a: A = 42
export const b: B = 'Forty Two'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { A, B } from './index'

export const a: A = 42
export const b: B = 'Forty Two'
export const b: B = 'Forty Two'
2 changes: 2 additions & 0 deletions examples/dts_pkg/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './lib_types'
export * from './lib_types_2.mjs'
1 change: 1 addition & 0 deletions examples/dts_pkg/lib_types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type A = number
1 change: 1 addition & 0 deletions examples/dts_pkg/lib_types_2.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type B = string
File renamed without changes.
20 changes: 9 additions & 11 deletions examples/js_lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")

npm_package(
name = "pkg",
srcs = ["index.js"],
package = "@myorg/js_lib",
visibility = ["//examples:__subpackages__"],
)
# A package only using js_library() instead of npm_package()

js_library(
name = "lib",
# Provide index.js as types available to downstream type checking rules
# since it has no corresponding .d.ts file.
types = ["index.js"],
name = "pkg",
srcs = [
# A typescript file is required to ensure types will exist within the `JsInfo(types)`
# that can be passed along the package linking chain. Otherwise no files will be copied
# into the sandbox for type-checking (even though tsc would pass if only the .js was there).
"index.d.ts",
"index.js",
],
visibility = ["//examples:__subpackages__"],
)
File renamed without changes.
15 changes: 0 additions & 15 deletions examples/js_lib_pkg/BUILD.bazel

This file was deleted.

17 changes: 17 additions & 0 deletions examples/js_pkg/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")

npm_package(
name = "pkg",
srcs = ["index.js"],
package = "@myorg/js_pkg",
visibility = ["//examples:__subpackages__"],
)

js_library(
name = "lib",
# Provide index.js as types available to downstream type checking rules
# since it has no corresponding .d.ts file.
types = ["index.js"],
visibility = ["//examples:__subpackages__"],
)
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/path_mappings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ts_project(
declaration = True,
validate = False,
deps = [
"//examples/dts_lib:lib",
"//examples/js_lib:lib",
"//examples/dts_pkg:lib",
"//examples/js_pkg:lib",
],
)

Expand Down
4 changes: 2 additions & 2 deletions examples/path_mappings/foo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import num from '@myorg/js_lib'
import { A } from '@myorg/dts_lib'
import num from '@myorg/js_pkg'
import { A } from '@myorg/dts_pkg'

export const a: A = 123
export const b: string = `number: ${num}`
Expand Down
6 changes: 3 additions & 3 deletions examples/simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ ts_project(
deps = [
# Two dependencies are linked from first-party code in this repo
# by the npm_link_package calls in /examples/BUILD.bazel
"//examples:node_modules/@myorg/js_pkg",
"//examples:node_modules/@myorg/js_lib",
"//examples:node_modules/@myorg/js_lib_pkg",
"//examples:node_modules/@myorg/dts_lib",
"//examples:node_modules/@myorg/dts_pkg",
# Two dependencies are linked from third-party npm packages
# by the npm_link_all_packages call in /examples/BUILD.bazel
"//examples:node_modules/@types/node",
Expand All @@ -33,7 +33,7 @@ ts_project(
assert_contains(
name = "test_js",
actual = "foo.js",
expected = """var js_lib_1 = require("@myorg/js_lib")""",
expected = """var js_pkg_1 = require("@myorg/js_pkg")""",
)

assert_contains(
Expand Down
6 changes: 3 additions & 3 deletions examples/simple/foo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import num from '@myorg/js_lib'
import num2 from '@myorg/js_lib_pkg'
import { A } from '@myorg/dts_lib'
import num from '@myorg/js_pkg'
import num2 from '@myorg/js_lib'
import { A } from '@myorg/dts_pkg'
import { format } from 'date-fns'

export const a: A = 123
Expand Down

0 comments on commit e460067

Please sign in to comment.