Skip to content

Commit

Permalink
chore: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho committed Jan 16, 2023
1 parent 31b2d5d commit cc3a81f
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 39 deletions.
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,19 @@ buildbuddy(name = "buildbuddy_toolchain")
# https://github.com/bazelbuild/rules_rust/releases
http_archive(
name = "rules_rust",
sha256 = "324c2a86a8708d30475f324846b35965c432b63a35567ed2b5051b86791ce345",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.13.0/rules_rust-v0.13.0.tar.gz"],
# Workaround for https://github.com/bazelbuild/rules_rust/issues/1330
patches = ["//tools:rules_rust.patch"],
sha256 = "324c2a86a8708d30475f324846b35965c432b63a35567ed2b5051b86791ce345",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.13.0/rules_rust-v0.13.0.tar.gz"],
)

load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

rules_rust_dependencies()

rust_register_toolchains(
edition="2021",
edition = "2021",
extra_target_triples = [
"wasm32-unknown-unknown",
"wasm32-wasi",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ ruleTester.run('enforce-placeholders', enforcePlaceholders, {
{
message: 'Missing value for placeholder "name"',
},
]
}
],
},
],
})
2 changes: 1 addition & 1 deletion packages/fast-memoize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface CacheCreateFunc<K, V> {

interface DefaultCache<K, V> {
get(key: K): V | undefined
set(key: K, value: V): void
set(key: K, value: V | undefined): void
}

export type Serializer = (args: any[]) => string
Expand Down
2 changes: 1 addition & 1 deletion packages/intl-displaynames/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ ts_script(
"scripts/extract-displaynames.ts",
":node_modules/@formatjs/ecma402-abstract",
"//:node_modules/cldr-core",
"//:node_modules/cldr-dates-full",
"//:node_modules/cldr-localenames-full",
"//:node_modules/cldr-numbers-full",
"//:node_modules/cldr-dates-full",
"//:node_modules/fast-glob",
],
entry_point = "scripts/cldr-raw.ts",
Expand Down
4 changes: 3 additions & 1 deletion packages/intl-messageformat/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export interface Options {
ignoreTag?: boolean
}

function createFastMemoizeCache<V>(store: Record<string, V>): Cache<string, V> {
function createFastMemoizeCache<V>(
store: Record<string, V | undefined>
): Cache<string, V> {
return {
create() {
return {
Expand Down
17 changes: 10 additions & 7 deletions packages/intl/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_js//npm/private:npm_package.bzl", "npm_package")
load("@npm//:tsd/package_json.bzl", tsd_bin = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:tsd/package_json.bzl", tsd_bin = "bin")
load("//tools:index.bzl", "check_format", "package_json_test", "ts_compile")
load("//tools:jest.bzl", "jest_test")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")

npm_link_all_packages(name = "node_modules")

Expand Down Expand Up @@ -85,13 +85,16 @@ copy_to_directory(
name = "global_type_overrides_test_files",
srcs = [
":%s" % PACKAGE_NAME,
"tests/global_type_overrides.test-d.ts"
"tests/global_type_overrides.test-d.ts",
],
out = "global_type_overrides_test_files",
# Remove the prefix so the package directory merges with the test file directory.
replace_prefixes = dict([
("%s" % PACKAGE_NAME, "")
])
(
"%s" % PACKAGE_NAME,
"",
),
]),
)

tsd_bin.tsd_test(
Expand All @@ -103,7 +106,7 @@ tsd_bin.tsd_test(
] + SRC_DEPS,
args = [
"--files",
"tests/global_type_overrides.test-d.ts"
"tests/global_type_overrides.test-d.ts",
],
chdir = "packages/%s/global_type_overrides_test_files" % PACKAGE_NAME
chdir = "packages/%s/global_type_overrides_test_files" % PACKAGE_NAME,
)
4 changes: 3 additions & 1 deletion packages/intl/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export function createIntlCache(): IntlCache {
}
}

function createFastMemoizeCache<V>(store: Record<string, V>): Cache<string, V> {
function createFastMemoizeCache<V>(
store: Record<string, V | undefined>
): Cache<string, V> {
return {
create() {
return {
Expand Down
6 changes: 3 additions & 3 deletions packages/swc-plugin-experimental/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//npm/private:npm_package.bzl", "npm_package")
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@aspect_rules_js//npm/private:npm_package.bzl", "npm_package")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//tools:jest.bzl", "jest_test")

npm_link_all_packages(name = "node_modules")
Expand All @@ -18,8 +18,8 @@ npm_package(
srcs = [
"LICENSE.md",
"README.md",
"package.json",
"index.wasm",
"package.json",
],
package = "@formatjs/%s" % PACKAGE_NAME,
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion rust/icu-messageformat-parser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ rust_library(
name = "icu-messageformat-parser",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(),
crate_features = ["utf16"],
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
deps = all_crate_deps(
normal = True,
),
crate_features = ["utf16"]
)

rust_test(
Expand Down
22 changes: 11 additions & 11 deletions rust/swc-formatjs-visitor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ package(default_visibility = ["//rust:__subpackages__"])

# TODO: support `custom_transform` feature.
rust_library(
name = "swc-formatjs-visitor",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(),
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
deps = ["//rust/icu-messageformat-parser"] + all_crate_deps(
normal = True,
),
crate_features = ["plugin"],
)
name = "swc-formatjs-visitor",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(),
crate_features = ["plugin"],
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
deps = ["//rust/icu-messageformat-parser"] + all_crate_deps(
normal = True,
),
)

rust_test(
name = "unit_test",
Expand Down
6 changes: 3 additions & 3 deletions rust/swc-plugin-formatjs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ rust_wasm_library(
name = "swc_plugin_formatjs.wasm",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(),
wasi = True,
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
tags = ["manual"],
visibility = ["@//packages/swc-plugin-experimental:__pkg__"],
wasi = True,
deps = ["//rust/swc-formatjs-visitor"] + all_crate_deps(
normal = True,
),
visibility = ["@//packages/swc-plugin-experimental:__pkg__"],
tags = ["manual"],
)
2 changes: 0 additions & 2 deletions tools/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazelbuild_buildtools//buildifier:def.bzl", "buildifier_test")
load("@npm//:prettier/package_json.bzl", prettier_bin = "bin")
load("@npm//:ts-node/package_json.bzl", ts_node_bin = "bin")
load("@npm//:@taplo/cli/package_json.bzl", taplo_bin = "bin")
# load("@rules_rust//rust:defs.bzl", "rustfmt_test")

BUILDIFIER_WARNINGS = [
"attr-cfg",
Expand Down
5 changes: 3 additions & 2 deletions tools/rust.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Rust setup utilities"""

load("@rules_rust//rust:defs.bzl", "rust_binary")

def _rust_wasm_transition_impl(_settings, _attr):
Expand Down Expand Up @@ -57,7 +58,7 @@ _rust_wasi_library_rule = rule(

def rust_wasm_library(name, tags = [], wasi = False, **kwargs):
"""Cross compile Rust library to WASM.
Based on https://github.com/envoyproxy/envoy/blob/main/bazel/wasm/wasm.bzl
Args:
Expand Down Expand Up @@ -85,5 +86,5 @@ def rust_wasm_library(name, tags = [], wasi = False, **kwargs):
name = name,
library = ":" + wasm_name,
tags = tags,
visibility = kwargs.get("visibility")
visibility = kwargs.get("visibility"),
)

0 comments on commit cc3a81f

Please sign in to comment.