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

refactor: make fstree handle watchers #108

Merged
merged 7 commits into from
Aug 7, 2022
Merged
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
9 changes: 9 additions & 0 deletions e2e/worker/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

ts_project(
name = "ts",
Expand All @@ -12,6 +15,12 @@ ts_project(
],
),
deps = [
":node_modules/@nestjs/common",
":node_modules/@nestjs/core",
":node_modules/@types/debug",
":node_modules/@types/node",
":node_modules/debug",
":node_modules/rxjs",
"//feature",
"//feature1",
"//feature2",
Expand Down
11 changes: 11 additions & 0 deletions e2e/worker/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ nodejs_register_toolchains(
name = "node",
node_version = DEFAULT_NODE_VERSION,
)

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()
5 changes: 5 additions & 0 deletions e2e/worker/feature4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"declaration": true
}
}
9 changes: 8 additions & 1 deletion e2e/worker/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import * as feature2 from "./feature2";
import * as feature3 from "./feature3";
import * as feature4 from "./feature4";
import * as feature from "./feature";
import * as debug from "debug";

import * as common from "@nestjs/common";
import * as core from "@nestjs/core";
import * as rxjs from "rxjs";

console.log(common, core, rxjs);

const features = [
feature.name,
Expand All @@ -14,6 +21,6 @@ const features = [

function sayhello(should_i) {
if (should_i) {
console.log(features)
debug.log(features);
}
}
13 changes: 12 additions & 1 deletion e2e/worker/package.json
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
{"type": "module"}
{
"type": "module",
"dependencies": {
"debug": "^4.3.4",
"@types/debug": "^4.1.7",
"@nestjs/core": "^9.0.8",
"@nestjs/common": "^9.0.8",
"rxjs": "^7.5.6",
"reflect-metadata": "^0.1.13",
"@types/node": "^18.6.3"
}
}
224 changes: 224 additions & 0 deletions e2e/worker/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 29 additions & 4 deletions e2e/worker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ message "# Case 4; assert that tsc does not read a file that's been removed from
for i in $(seq 0 9)
do
echo "const a = $i" > "_addendum_$i.ts"
add_trap "rm _addendum_$i.ts"
add_trap "rm -f _addendum_$i.ts"

bazel build :ts
rm "_addendum_$i.ts"
Expand All @@ -79,7 +79,7 @@ add_trap "git checkout HEAD -- tsconfig.json"
echo '{"compilerOptions": {"module": "ES2015", "moduleResolution": "node"}}' > tsconfig.json
rm "_addendum_$i.ts"

add_trap "rm _addendum_${i}_$i.ts"
add_trap "rm -f _addendum_${i}_$i.ts"
echo "const a = $i" > "_addendum_${i}_$i.ts"

bazel build :ts
Expand All @@ -106,7 +106,7 @@ do
buildozer "remove deps //feature$i" :ts

message="error TS2307: Cannot find module './feature$i' or its corresponding type declarations."
bazel build :ts || echo "failed"
bazel build :ts | grep "$message" && exit_with_message "Case 8: Expected worker to report missing deps"

buildozer "add deps //feature$i" :ts
bazel build :ts
Expand All @@ -132,4 +132,29 @@ bazel build :ts 2>&1 | grep "$message1" || exit_with_message "Case 9: expected w
bazel build :ts 2>&1 | grep "$message2" || exit_with_message "Case 9: expected worker to report \"$message2\""
bazel build :ts 2>&1 | grep "$message3" && exit_with_message "Case 9: expected worker to not report \"$message3\""

message "All tests have passed"

message "# Case 9: Should report when @types/<pkg> and <pkg> is missing from deps."

add_trap "buildozer 'add deps //:node_modules/debug //:node_modules/@types/debug' :ts"
buildozer "remove deps //:node_modules/debug //:node_modules/@types/debug" :ts
message="error TS2307: Cannot find module 'debug' or its corresponding type declarations."
bazel build :ts 2>&1 | grep "$message" || exit_with_message "Case 9: expected worker to report \"$message\""
buildozer "add deps //:node_modules/debug //:node_modules/@types/debug" :ts


message "# Case 10: Should report missing third party deps"

deps=( "@nestjs/core" "@nestjs/common" "rxjs" )

for dep in "${deps[@]}"; do
add_trap "buildozer 'add deps //:node_modules/$dep' :ts"
buildozer "remove deps //:node_modules/$dep" :ts
message="error TS2307: Cannot find module '$dep' or its corresponding type declarations."
bazel build :ts 2>&1 | grep "$message" || exit_with_message "Case 10: expected worker to report \"$message\""
buildozer "add deps //:node_modules/$dep"
done


echo "###########################"
echo "## All tests have passed ##"
echo "###########################"
6 changes: 0 additions & 6 deletions examples/dts_lib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ ts_project(
"lib_types.d.ts",
],
declaration = True,
# TODO: fix worker mode flaky bug when there are multiple ts_project targets in a package
supports_workers = False,
)

js_library(
Expand All @@ -29,8 +27,6 @@ ts_project(
name = "importer_rel_ts",
srcs = ["importer_rel.ts"],
declaration = True,
# TODO: fix worker mode flaky bug when there are multiple ts_project targets in a package
supports_workers = False,
deps = [
":lib",
],
Expand All @@ -40,8 +36,6 @@ ts_project(
name = "importer_linked_ts",
srcs = ["importer_linked.ts"],
declaration = True,
# TODO: fix worker mode flaky bug when there are multiple ts_project targets in a package
supports_workers = False,
deps = [
"//examples:node_modules/@myorg/dts_lib",
],
Expand Down
Loading