Skip to content

Commit

Permalink
chore(6.x): fix broken typescript test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Mar 31, 2023
1 parent 5894b09 commit f561c6f
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import %workspace%/common.bazelrc
# This lets us glob() up all the files inside the examples to make them inputs to tests
# To update these lines, just run `yarn bazel:update-deleted-packages`
# (Note, we cannot use common --deleted_packages because the bazel version command doesn't support it)
build --deleted_packages=e2e/bazel_managed_deps,e2e/bazel_run_chdir,e2e/bazel_run_chdir/subfolder,e2e/coverage,e2e/fine_grained_symlinks,e2e/jasmine,e2e/linker_disabled_regression,e2e/linker_disabled_regression/subdir,e2e/node_loader_preserve_symlinks,e2e/nodejs_host,e2e/nodejs_image,e2e/nodejs_image/foolib,e2e/packages,e2e/symlinked_node_modules_npm,e2e/symlinked_node_modules_yarn,e2e/typescript,e2e/webapp,examples/angular,examples/angular/e2e,examples/angular/src,examples/angular/src/app,examples/angular/src/app/hello-world,examples/angular/src/app/home,examples/angular/src/app/todos,examples/angular/src/app/todos/reducers,examples/angular/src/assets,examples/angular/src/lib/shorten,examples/angular/src/shared/material,examples/angular/tools,examples/angular_bazel_architect,examples/angular_bazel_architect/projects/frontend-lib,examples/app,examples/app/styles,examples/app/test,examples/closure,examples/create-react-app,examples/cypress,examples/esbuild,examples/esbuild/src,examples/from_source,examples/jest,examples/jest/ts,examples/jest/ts/src,examples/jest/ts/test,examples/kotlin,examples/nestjs,examples/nestjs/src,examples/parcel,examples/protobufjs,examples/react_webpack,examples/toolchain,examples/vendored_node_and_yarn,examples/vendored_node_and_yarn/toolchains,examples/vue,examples/vue/src,examples/vue/src/components/HelloWorld,examples/web_testing,examples/webapp,examples/worker
query --deleted_packages=e2e/bazel_managed_deps,e2e/bazel_run_chdir,e2e/bazel_run_chdir/subfolder,e2e/coverage,e2e/fine_grained_symlinks,e2e/jasmine,e2e/linker_disabled_regression,e2e/linker_disabled_regression/subdir,e2e/node_loader_preserve_symlinks,e2e/nodejs_host,e2e/nodejs_image,e2e/nodejs_image/foolib,e2e/packages,e2e/symlinked_node_modules_npm,e2e/symlinked_node_modules_yarn,e2e/typescript,e2e/webapp,examples/angular,examples/angular/e2e,examples/angular/src,examples/angular/src/app,examples/angular/src/app/hello-world,examples/angular/src/app/home,examples/angular/src/app/todos,examples/angular/src/app/todos/reducers,examples/angular/src/assets,examples/angular/src/lib/shorten,examples/angular/src/shared/material,examples/angular/tools,examples/angular_bazel_architect,examples/angular_bazel_architect/projects/frontend-lib,examples/app,examples/app/styles,examples/app/test,examples/closure,examples/create-react-app,examples/cypress,examples/esbuild,examples/esbuild/src,examples/from_source,examples/jest,examples/jest/ts,examples/jest/ts/src,examples/jest/ts/test,examples/kotlin,examples/nestjs,examples/nestjs/src,examples/parcel,examples/protobufjs,examples/react_webpack,examples/toolchain,examples/vendored_node_and_yarn,examples/vendored_node_and_yarn/toolchains,examples/vue,examples/vue/src,examples/vue/src/components/HelloWorld,examples/web_testing,examples/webapp,examples/worker
build --deleted_packages=e2e/bazel_managed_deps,e2e/bazel_run_chdir,e2e/bazel_run_chdir/subfolder,e2e/coverage,e2e/fine_grained_symlinks,e2e/jasmine,e2e/linker_disabled_regression,e2e/linker_disabled_regression/subdir,e2e/node_loader_preserve_symlinks,e2e/nodejs_host,e2e/nodejs_image,e2e/nodejs_image/foolib,e2e/packages,e2e/symlinked_node_modules_npm,e2e/symlinked_node_modules_yarn,e2e/webapp,examples/angular,examples/angular/e2e,examples/angular/src,examples/angular/src/app,examples/angular/src/app/hello-world,examples/angular/src/app/home,examples/angular/src/app/todos,examples/angular/src/app/todos/reducers,examples/angular/src/assets,examples/angular/src/lib/shorten,examples/angular/src/shared/material,examples/angular/tools,examples/angular_bazel_architect,examples/angular_bazel_architect/projects/frontend-lib,examples/app,examples/app/styles,examples/app/test,examples/closure,examples/create-react-app,examples/cypress,examples/esbuild,examples/esbuild/src,examples/from_source,examples/jest,examples/jest/ts,examples/jest/ts/src,examples/jest/ts/test,examples/kotlin,examples/nestjs,examples/nestjs/src,examples/parcel,examples/protobufjs,examples/react_webpack,examples/toolchain,examples/vendored_node_and_yarn,examples/vendored_node_and_yarn/toolchains,examples/vue,examples/vue/src,examples/vue/src/components/HelloWorld,examples/web_testing,examples/webapp,examples/worker
query --deleted_packages=e2e/bazel_managed_deps,e2e/bazel_run_chdir,e2e/bazel_run_chdir/subfolder,e2e/coverage,e2e/fine_grained_symlinks,e2e/jasmine,e2e/linker_disabled_regression,e2e/linker_disabled_regression/subdir,e2e/node_loader_preserve_symlinks,e2e/nodejs_host,e2e/nodejs_image,e2e/nodejs_image/foolib,e2e/packages,e2e/symlinked_node_modules_npm,e2e/symlinked_node_modules_yarn,e2e/webapp,examples/angular,examples/angular/e2e,examples/angular/src,examples/angular/src/app,examples/angular/src/app/hello-world,examples/angular/src/app/home,examples/angular/src/app/todos,examples/angular/src/app/todos/reducers,examples/angular/src/assets,examples/angular/src/lib/shorten,examples/angular/src/shared/material,examples/angular/tools,examples/angular_bazel_architect,examples/angular_bazel_architect/projects/frontend-lib,examples/app,examples/app/styles,examples/app/test,examples/closure,examples/create-react-app,examples/cypress,examples/esbuild,examples/esbuild/src,examples/from_source,examples/jest,examples/jest/ts,examples/jest/ts/src,examples/jest/ts/test,examples/kotlin,examples/nestjs,examples/nestjs/src,examples/parcel,examples/protobufjs,examples/react_webpack,examples/toolchain,examples/vendored_node_and_yarn,examples/vendored_node_and_yarn/toolchains,examples/vue,examples/vue/src,examples/vue/src/components/HelloWorld,examples/web_testing,examples/webapp,examples/worker

# Mock versioning command to test the --stamp behavior
build --workspace_status_command="echo BUILD_SCM_VERSION 1.2.3"
Expand Down
4 changes: 2 additions & 2 deletions docs/Rollup.md

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

19 changes: 0 additions & 19 deletions e2e/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,6 @@ e2e_integration_test(
},
)

# tsc_wrapped uses unstable APIs in typescript, so it's wise
# to test it against all the versions we might need to support
[e2e_integration_test(
name = "e2e_typescript_%s" % tsc_version.replace(".", "_"),
npm_packages = {
"//packages/jasmine:npm_package": "@bazel/jasmine",
},
# use these package.json packages instead
package_json_substitutions = {
"typescript": tsc_version,
},
workspace_root = "typescript",
) for tsc_version in [
"4.0.x",
"4.1.x",
"4.2.x",
"4.3.x",
]]

e2e_integration_test(
name = "e2e_bazel_run_chdir",
bazel_commands = [
Expand Down
11 changes: 2 additions & 9 deletions examples/app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
load("@npm//@bazel/concatjs:index.bzl", "concatjs_devserver", "ts_library")
load("@npm//@bazel/protractor:index.bzl", "protractor_web_test_suite")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
load("@npm//@bazel/terser:index.bzl", "terser_minified")
Expand All @@ -9,17 +8,11 @@ load("@npm//http-server:index.bzl", "http_server")

package(default_visibility = ["//visibility:public"])

ts_library(
ts_project(
name = "app",
srcs = ["app.ts"],
)

concatjs_devserver(
name = "devserver",
# We'll collect all the devmode JS sources from these TypeScript libraries
deps = [":app"],
)

rollup_bundle(
name = "bundle",
entry_point = ":app.ts",
Expand Down Expand Up @@ -61,7 +54,7 @@ http_server(
templated_args = ["package"],
)

# This could also be `ts_library` but we mix them here to illustrate
# This could also be `ts_project` but we mix them here to illustrate
ts_project(
name = "tsconfig-test",
testonly = 1,
Expand Down
1 change: 1 addition & 0 deletions internal/linker/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//packages/typescript:index.bzl", "ts_project")
ts_project(
name = "test_lib",
srcs = glob(["*.ts"]),
tsconfig = {},
deps = [
"//internal/linker:linker_lib",
"//packages/runfiles:bazel_runfiles",
Expand Down
2 changes: 2 additions & 0 deletions internal/linker/test/link_node_modules.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck

import * as fs from 'fs';
import * as path from 'path';

Expand Down
6 changes: 3 additions & 3 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ nodejs_binary(
```
You can specify the entry point as a typescript file so long as you also include
the ts_library target in data:
the ts_project target in data:
```python
ts_library(
ts_project(
name = "main",
srcs = ["main.ts"],
)
Expand All @@ -473,7 +473,7 @@ nodejs_binary(
)
```
The rule will use the corresponding `.js` output of the ts_library rule as the entry point.
The rule will use the corresponding `.js` output of the ts_project rule as the entry point.
If the entry point target is a rule, it should produce a single JavaScript entry file that will be passed to the nodejs_binary rule.
For example:
Expand Down
2 changes: 0 additions & 2 deletions internal/npm_install/npm_install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ NB: This feature requires runfiles be enabled due to an issue in Bazel which we
On Windows runfiles are off by default and must be enabled with the `--enable_runfiles` flag when
using this feature.
NB: `ts_library` does not support directory npm deps due to internal dependency on having all input sources files explicitly specified.
NB: `protractor_web_test` and `protractor_web_test_suite` do not support directory npm deps.
For the `nodejs_binary` & `nodejs_test` `entry_point` attribute (which often needs to reference a file within
Expand Down
1 change: 1 addition & 0 deletions internal/pkg_npm/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ts_project(
name = "ts_project",
srcs = ["foo.ts"],
data = ["data.json"],
tsconfig = {},
)

rollup_bundle(
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg_npm/test/linking/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ tsc(
# baz: pkg_npm with js, d.ts srcs & no package.json
"//internal/pkg_npm/test/linking/baz",
"//internal/pkg_npm/test/linking/baz:scoped_baz",
# feb: pkg_npm with ts_library dep & package.json main & typings
# feb: pkg_npm with ts_project dep & package.json main & typings
# "//internal/pkg_npm/test/linking/feb:feb_lib",
"//internal/pkg_npm/test/linking/feb",
"//internal/pkg_npm/test/linking/feb:scoped_feb",
# fez: pkg_npm with ts_library dep & no package.json
# fez: pkg_npm with ts_project dep & no package.json
# "//internal/pkg_npm/test/linking/fez:fez_lib",
"//internal/pkg_npm/test/linking/fez",
"//internal/pkg_npm/test/linking/fez:scoped_fez",
Expand Down Expand Up @@ -60,11 +60,11 @@ nodejs_test(
# baz: pkg_npm with js, d.ts srcs & no package.json
"//internal/pkg_npm/test/linking/baz",
"//internal/pkg_npm/test/linking/baz:scoped_baz",
# feb: pkg_npm with ts_library dep & package.json main & typings
# feb: pkg_npm with ts_project dep & package.json main & typings
# "//internal/pkg_npm/test/linking/feb:feb_lib",
"//internal/pkg_npm/test/linking/feb",
"//internal/pkg_npm/test/linking/feb:scoped_feb",
# fez: pkg_npm with ts_library dep & no package.json
# fez: pkg_npm with ts_project dep & no package.json
"//internal/pkg_npm/test/linking/fez:fez_lib",
"//internal/pkg_npm/test/linking/fez",
"//internal/pkg_npm/test/linking/fez:scoped_fez",
Expand Down
1 change: 1 addition & 0 deletions internal/pkg_npm/test/linking/feb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//packages/typescript:index.bzl", "ts_project")
ts_project(
name = "feb_lib",
srcs = ["main.ts"],
tsconfig = {},
visibility = ["//internal/pkg_npm/test/linking:__pkg__"],
)

Expand Down
1 change: 1 addition & 0 deletions internal/pkg_npm/test/linking/fez/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//packages/typescript:index.bzl", "ts_project")
ts_project(
name = "fez_lib",
srcs = ["index.ts"],
tsconfig = {},
visibility = ["//internal/pkg_npm/test/linking:__pkg__"],
)

Expand Down
10 changes: 5 additions & 5 deletions internal/pkg_npm/test/pkg_npm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ describe('pkg_npm', () => {
it('copies files from other packages', () => {
expect(readFromPkg('dependent_file')).toEqual('dependent_file content');
});
it('copies js files from ts_library', () => {
it('copies js files from ts_project', () => {
expect(readFromPkg('foo.js')).toContain('exports.a = \'\';');
});
it('copies declaration files from ts_library', () => {
it('copies declaration files from ts_project', () => {
expect(readFromPkg('foo.d.ts')).toContain('export declare const a: string;');
});
it('copies ESM files from ts_library', () => {
it('copies ESM files from ts_project', () => {
expect(readFromPkg('foo.mjs')).toContain('export const a = \'\';');
});
it('copies data dependencies', () => {
Expand All @@ -59,10 +59,10 @@ describe('pkg_npm', () => {
it('copies files from external workspace if included in srcs', () => {
expect(readFromPkg('vendored_external_file')).toEqual('vendored_external_file content');
});
it('copies js files from external workspace ts_library if included in vendor_external', () => {
it('copies js files from external workspace ts_project if included in vendor_external', () => {
expect(readFromPkg('external.js')).toContain('exports.b = \'\';');
});
it('copies declaration files from external workspace ts_library if included in vendor_external',
it('copies declaration files from external workspace ts_project if included in vendor_external',
() => {
expect(readFromPkg('external.d.ts')).toContain('export declare const b: string;');
});
Expand Down
13 changes: 13 additions & 0 deletions internal/pkg_npm/test/vendored_external/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@build_bazel_rules_nodejs//packages/typescript:index.bzl", "ts_project")

package(default_visibility = ["//visibility:public"])

# Exported file to be consumed by test
exports_files(["vendored_external_file"])

ts_project(
name = "ts_project",
srcs = [
"external.ts",
],
)
15 changes: 15 additions & 0 deletions internal/pkg_npm/test/vendored_external/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "internal_npm_package_test_vendored_external")
1 change: 1 addition & 0 deletions internal/pkg_npm/test/vendored_external/external.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const b: string = '';
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendored_external_file content
2 changes: 1 addition & 1 deletion nodejs/private/ts_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ts_config = rule(
doc = """Allows a tsconfig.json file to extend another file.
Normally, you just give a single `tsconfig.json` file as the tsconfig attribute
of a `ts_library` or `ts_project` rule. However, if your `tsconfig.json` uses the `extends`
of a `ts_project` rule. However, if your `tsconfig.json` uses the `extends`
feature from TypeScript, then the Bazel implementation needs to know about that
extended configuration file as well, to pass them both to the TypeScript compiler.
""",
Expand Down
2 changes: 2 additions & 0 deletions packages/cypress/test/hello.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck

describe('hello', () => {
it('should find hello', () => {
cy.visit('http://localhost:3000');
Expand Down
1 change: 0 additions & 1 deletion packages/protractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ ts_project(
name = "protractor",
srcs = ["protractor-utils.ts"],
data = ["package.json"],
module_root = "protractor-utils",
deps = ["@npm//@types/node"],
)

Expand Down
1 change: 1 addition & 0 deletions packages/protractor/test/protractor-2/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"lib": ["dom", "es2015"],
"skipLibCheck": true,
"types": []
}
}
1 change: 1 addition & 0 deletions packages/protractor/test/protractor-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ts_project(
name = "protractor_utils_tests_lib",
testonly = True,
srcs = ["index_test.ts"],
tsconfig = {},
deps = [
"//packages/protractor",
"@npm//@types/jasmine",
Expand Down
2 changes: 2 additions & 0 deletions packages/protractor/test/protractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ts_project(
testonly = True,
srcs = ["test.spec.ts"],
tsconfig = ":tsconfig.json",
validate = False,
deps = [
"@npm//@types/jasmine",
"@npm//protractor",
Expand All @@ -17,6 +18,7 @@ ts_project(
testonly = True,
srcs = ["conf.ts"],
tsconfig = ":tsconfig.json",
validate = False,
deps = [
"//packages/protractor",
"@npm//protractor",
Expand Down
1 change: 1 addition & 0 deletions packages/protractor/test/protractor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"lib": ["es2015"],
"skipLibCheck": true,
"types": ["jasmine"]
}
}

0 comments on commit f561c6f

Please sign in to comment.