Skip to content

Commit

Permalink
Moves TypeScript rules into //tools/typescript/....
Browse files Browse the repository at this point in the history
Refs #67.

This is just for better organization and to split the implementation into multiple files.
  • Loading branch information
dgp1130 committed Feb 19, 2023
1 parent eb9af65 commit 8a427ec
Show file tree
Hide file tree
Showing 45 changed files with 75 additions and 51 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
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")
load("//tools/typescript:defs.bzl", "types_only")
load("//:index.bzl", "link_prerender_component", "prerender_component")

exports_files([".npmrc"], visibility = ["//visibility:public"])
Expand Down
2 changes: 1 addition & 1 deletion common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(":label_test.bzl", "label_test_suite")
load(":paths_test.bzl", "paths_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion common/models/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

ts_project(
name = "prerender_annotation",
Expand Down
2 changes: 1 addition & 1 deletion common/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//:index.bzl", "web_resources", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_node_test", "jasmine_web_test_suite")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

ts_project(
name = "binary",
Expand Down
2 changes: 1 addition & 1 deletion examples/components/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"prerender_component",
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_bundling/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_rollup//rollup:defs.bzl", "rollup_bundle")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"extract_single_resource",
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_bundling/component/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_component")

prerender_component(
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_bundling/transitive/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_component")

prerender_component(
Expand Down
2 changes: 1 addition & 1 deletion examples/data/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion examples/declarative_shadow_dom/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"css_library",
Expand Down
2 changes: 1 addition & 1 deletion examples/javascript/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion examples/multi_page/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"css_library",
Expand Down
2 changes: 1 addition & 1 deletion examples/prerender_resources/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_resources")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")

Expand Down
2 changes: 1 addition & 1 deletion examples/resources/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"prerender_pages",
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/component/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_component")

prerender_component(
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/transitive/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_component")

prerender_component(
Expand Down
2 changes: 1 addition & 1 deletion examples/site/blog/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")

Expand Down
2 changes: 1 addition & 1 deletion examples/site/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library")

ts_project(
Expand Down
2 changes: 1 addition & 1 deletion examples/site/components/base/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library", "prerender_component")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")

Expand Down
2 changes: 1 addition & 1 deletion examples/site/components/counter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"prerender_component",
Expand Down
2 changes: 1 addition & 1 deletion examples/site/components/footer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library", "prerender_component")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")

Expand Down
2 changes: 1 addition & 1 deletion examples/site/components/header/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library", "prerender_component")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")

Expand Down
2 changes: 1 addition & 1 deletion examples/site/home/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion examples/styles/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion examples/testonly/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(
"//:index.bzl",
"css_library",
Expand Down
2 changes: 1 addition & 1 deletion examples/testonly/component/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library", "prerender_component", "web_resources")

prerender_component(
Expand Down
2 changes: 1 addition & 1 deletion examples/testonly/transitive/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "css_library", "prerender_component", "web_resources")

prerender_component(
Expand Down
2 changes: 1 addition & 1 deletion examples/tsjs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite")

Expand Down
2 changes: 1 addition & 1 deletion packages/annotation_extractor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

js_binary(
name = "annotation_extractor",
Expand Down
2 changes: 1 addition & 1 deletion packages/css_bundler/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")

bzl_library(
Expand Down
2 changes: 1 addition & 1 deletion packages/declarative_shadow_dom/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load(
"prerender_component_publish_files",
)
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//tools/publish:npm_publish.bzl", "npm_publish")
load("//tools/stamping:stamp_package.bzl", "stamp_package")

Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load(":build_vars.bzl", "RENDERER_RUNTIME_DEPS")

ts_project(
Expand Down
2 changes: 1 addition & 1 deletion packages/resource_injector/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

js_binary(
name = "resource_injector",
Expand Down
2 changes: 1 addition & 1 deletion packages/resource_packager/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

js_binary(
name = "resource_packager",
Expand Down
2 changes: 1 addition & 1 deletion packages/rules_prerender/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//:index.bzl", "prerender_component")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

exports_files(
["rollup-default.config.js"],
Expand Down
2 changes: 1 addition & 1 deletion packages/rules_prerender/link_prerender_component.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@aspect_rules_js//js:providers.bzl", "JsInfo")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")
load("//packages/rules_prerender:web_resources.bzl", "WebResourceInfo")

def link_prerender_component(name, package, visibility = None, testonly = None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ load(
load("//packages/rules_prerender:web_resources.bzl", "web_resources")
load("//packages/rules_prerender/css:css_library.bzl", "css_library")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

prerender_component(
name = "component",
Expand Down
2 changes: 1 addition & 1 deletion packages/script_entry_generator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("//tools/jasmine:defs.bzl", "jasmine_node_test")
load("//tools:typescript.bzl", "ts_project")
load("//tools/typescript:defs.bzl", "ts_project")

js_binary(
name = "script_entry_generator",
Expand Down
1 change: 0 additions & 1 deletion tools/BUILD.bazel

This file was deleted.

20 changes: 20 additions & 0 deletions tools/typescript/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

bzl_library(
name = "defs",
srcs = ["defs.bzl"],
deps = [
":ts_project",
":types_only",
],
)

bzl_library(
name = "ts_project",
srcs = ["ts_project.bzl"],
)

bzl_library(
name = "types_only",
srcs = ["types_only.bzl"],
)
5 changes: 5 additions & 0 deletions tools/typescript/defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load(":ts_project.bzl", _ts_project = "ts_project")
load(":types_only.bzl", _types_only = "types_only")

ts_project = _ts_project
types_only = _types_only
10 changes: 10 additions & 0 deletions tools/typescript/ts_project.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project")

def ts_project(name, tsconfig = None, **kwargs):
_ts_project(
name = name,
tsconfig = tsconfig or "//:tsconfig",
declaration = True,
source_map = True,
**kwargs
)
10 changes: 0 additions & 10 deletions tools/typescript.bzl → tools/typescript/types_only.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info")
load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project")

def ts_project(name, tsconfig = None, **kwargs):
_ts_project(
name = name,
tsconfig = tsconfig or "//:tsconfig",
declaration = True,
source_map = True,
**kwargs
)

def _types_only_impl(ctx):
info = ctx.attr.dep[JsInfo]
Expand Down

0 comments on commit 8a427ec

Please sign in to comment.