Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement types-as-a-service and check bundles with generated types #1959

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/npm-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
export DEBIAN_FRONTEND=noninteractive
- name: build types
run: |
bazel build --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev //types:types
bazel build --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev -c opt //types:types
- name: Build package
run: node npm/scripts/build-types-package.mjs
env:
Expand Down
6 changes: 6 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ npm_link_package(
package = "@workerd/jsg",
)

npm_link_package(
name = "node_modules/@workerd/types-internal",
src = "//types:types_internal",
package = "@workerd/types-internal",
)

capnpc_ts_bin.capnpc_ts_binary(
name = "capnpc_ts",
visibility = ["//visibility:public"],
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@ npm_translate_lock(
"capnp-ts@0.7.0": ["//:patches/capnp-ts@0.7.0.patch"],
},
pnpm_lock = "//:pnpm-lock.yaml",
lifecycle_hooks = {
# Skip `esbuild`'s `postinstall` script. Usually, this optimises the dependency by replacing
# the JavaScript bin with a direct symlink to the correct binary. Unfortunately, rules_js
# attempts to import binaries as JavaScript files.
"esbuild": []
}
)

load("@npm//:repositories.bzl", "npm_repositories")
Expand Down
6 changes: 3 additions & 3 deletions build/wd_ts_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def wd_ts_bundle(

srcs = modules + internal_modules
ts_srcs = [src for src in srcs if src.endswith(".ts")]
declarations = [_to_d_ts(src) for src in ts_srcs if not src.endswith(".d.ts")]
declarations = [_to_d_ts(src) for src in ts_srcs if not src.endswith(".d.ts")] + [src for src in ts_srcs if src.endswith(".d.ts")]

ts_project(
name = name + "@tsproject",
Expand All @@ -61,7 +61,7 @@ def wd_ts_bundle(
name = name,
import_name = import_name,
# builtin modules are accessible under "<import_name>:<module_name>" name
builtin_modules = [_to_js(m) for m in modules],
builtin_modules = [_to_js(m) for m in modules if not m.endswith(".d.ts")],
# internal modules are accessible under "<import_name>-internal:<module_name>" name
# without "internal/" folder prefix.
internal_modules = [_to_js(m) for m in internal_modules if not m.endswith(".d.ts")],
Expand All @@ -82,7 +82,7 @@ def wd_ts_bundle(
"-f stylish",
"--report-unused-disable-directives",
] + ["$(location " + src + ")" for src in ts_srcs],
data = srcs + [
data = srcs + deps + [
eslintrc_json,
tsconfig_json,
"//:node_modules/@typescript-eslint/eslint-plugin",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"capnpc-ts": "^0.7.0",
"esbuild": "^0.15.10",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
Loading
Loading