diff --git a/WORKSPACE b/WORKSPACE index 6de581b6..a9d93458 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -180,4 +180,37 @@ kotlin_repositories() load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") -kt_register_toolchains() \ No newline at end of file +kt_register_toolchains() + +http_archive( + name = "aspect_rules_ts", + sha256 = "1149d4cf7f210de67e0fc5cd3e8f624de3ee976ac05af4f1484e57a74c12f2dc", + strip_prefix = "rules_ts-1.0.0-rc5", + url = "https://github.com/aspect-build/rules_ts/archive/refs/tags/v1.0.0-rc5.tar.gz", +) + +load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies") + +rules_ts_dependencies(ts_version_from = "//typescript:package.json") + +load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") + +nodejs_register_toolchains( + name = "node", + node_version = DEFAULT_NODE_VERSION, +) + +load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + +bazel_skylib_workspace() + +load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") + +npm_translate_lock( + name = "npm", + pnpm_lock = "//typescript:pnpm-lock.yaml", +) + +load("@npm//:repositories.bzl", "npm_repositories") + +npm_repositories() diff --git a/typescript/BUILD b/typescript/BUILD new file mode 100644 index 00000000..a1329565 --- /dev/null +++ b/typescript/BUILD @@ -0,0 +1,22 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") +load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@npm//:defs.bzl", "npm_link_all_packages") + +npm_link_all_packages(name = "node_modules") + +ts_project( + name = "typescript", + srcs = ["main.ts"], + declaration = True, + out_dir = ".", + deps = [ + "//typescript:node_modules/@types/node", + ], +) + +build_test( + name = "typesctript_test", + targets = [ + ":typescript", + ], +) diff --git a/typescript/main.ts b/typescript/main.ts new file mode 100644 index 00000000..15d3f1a0 --- /dev/null +++ b/typescript/main.ts @@ -0,0 +1,4 @@ +export const hello: String = "Hello "; +export const world: String = "World " + +console.log(hello, world) \ No newline at end of file diff --git a/typescript/package.json b/typescript/package.json new file mode 100644 index 00000000..54dc0c3e --- /dev/null +++ b/typescript/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "dependencies": { + "@types/node": "18.6.1", + "typescript": "4.8.2" + } +} \ No newline at end of file diff --git a/typescript/pnpm-lock.yaml b/typescript/pnpm-lock.yaml new file mode 100644 index 00000000..35df6e45 --- /dev/null +++ b/typescript/pnpm-lock.yaml @@ -0,0 +1,21 @@ +lockfileVersion: 5.4 + +specifiers: + '@types/node': 18.6.1 + typescript: 4.8.2 + +dependencies: + '@types/node': 18.6.1 + typescript: 4.8.2 + +packages: + + /@types/node/18.6.1: + resolution: {integrity: sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg==} + dev: false + + /typescript/4.8.2: + resolution: {integrity: sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==} + engines: {node: '>=4.2.0'} + hasBin: true + dev: false diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json new file mode 100644 index 00000000..4518d7d2 --- /dev/null +++ b/typescript/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "declaration": true, + "baseUrl": ".", + "types": ["node"] + } +} \ No newline at end of file