Skip to content

Commit

Permalink
chore: revert files that can be cleanup after flag flip
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eagle committed Dec 11, 2020
1 parent 8b33a07 commit d0b08d5
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 37 deletions.
2 changes: 2 additions & 0 deletions e2e/nodejs_image/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ nodejs_binary(
"@npm//date-fns",
],
entry_point = "main.js",
# Turn off require() monkey patches so linker is required to run inside docker container
templated_args = ["--nobazel_patch_module_resolver"],
)

# bazel run --platforms=@build_bazel_rules_nodejs//toolchains/node:linux_amd64 //:nodejs_image
Expand Down
10 changes: 0 additions & 10 deletions e2e/typescript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("@npm//@bazel/typescript:index.bzl", "ts_library")

Expand Down Expand Up @@ -46,24 +45,15 @@ ts_library(
],
)

# Run the test with cwd in the output folder
write_file(
name = "write_chdir_script",
out = "chdir.js",
content = ["process.chdir(__dirname)"],
)

jasmine_node_test(
name = "test",
data = [
"chdir.js",
# Verify that worker_protocol.proto can be referenced as a target in the generated npm bazel workspace
"@npm//@bazel/typescript/third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto",
],
templated_args = [
# ts_library produces named AMD output with repo name in the require statement
"--bazel_patch_module_resolver",
"--node_options=--require=$$(rlocation $(rootpath chdir.js))",
],
deps = [
":test_lib",
Expand Down
9 changes: 0 additions & 9 deletions e2e/typescript/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ http_archive(
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.2.2/rules_nodejs-2.2.2.tar.gz"],
)

http_archive(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
)

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

yarn_install(
Expand Down
1 change: 1 addition & 0 deletions examples/nestjs/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ nodejs_binary(
"@npm//minimist",
],
entry_point = ":main.ts",
templated_args = ["--nobazel_patch_module_resolver"],
)

jasmine_node_test(
Expand Down
5 changes: 1 addition & 4 deletions internal/bazel_integration_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ nodejs_binary(
configuration_env_vars = ["BAZEL_INTEGRATION_TEST_DEBUG"],
data = ["@npm//tmp"],
entry_point = ":test_runner.js",
templated_args = [
#"--bazel_patch_module_resolver",
"--node_options=--max-old-space-size=1024",
],
templated_args = ["--node_options=--max-old-space-size=1024"],
)

filegroup(
Expand Down
1 change: 1 addition & 0 deletions internal/linker/test/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ jasmine_node_test(
name = "test",
srcs = ["test.js"],
tags = ["local"],
templated_args = ["--nobazel_patch_module_resolver"],
deps = ["//internal/linker/test/local/fit"],
)
1 change: 1 addition & 0 deletions internal/linker/test/workspace_link/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jasmine_node_test(
name = "test",
srcs = ["test.js"],
link_workspace_root = True,
templated_args = ["--nobazel_patch_module_resolver"],
deps = [
"//internal/linker/test/workspace_link/bar",
"//internal/linker/test/workspace_link/foo",
Expand Down
9 changes: 9 additions & 0 deletions internal/node/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ jasmine_node_test(
"dir_output",
"minified.js",
],
# Turn on the linker & turn off require patches so that the external workspace jasmine_node_test
# entry point npm/@bazel/jasmine/jasmine_runner.js's require('@bazel/jasmine') is exercised without
# require patches.
templated_args = select({
# TODO: fix this linker assertion on Windows
"@bazel_tools//src/conditions:host_windows": [],
"//conditions:default": ["--nobazel_patch_module_resolver"],
}),
)

[nodejs_toolchain_test(
Expand Down Expand Up @@ -490,4 +498,5 @@ nodejs_test(
name = "main_test",
data = [":main_lib"],
entry_point = ":main.js",
templated_args = ["--nobazel_patch_module_resolver"],
)
9 changes: 6 additions & 3 deletions internal/npm_install/generate_build_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,8 @@ export function printPackageBin(pkg: Dep) {
nodejs_binary(
name = "${name}",
entry_point = "//:node_modules/${pkg._dir}/${path}",
data = [${data.map(p => `"${p}"`).join(', ')}],${additionalAttributes(pkg, name)}
data = [${data.map(p => `"${p}"`).join(', ')}],
templated_args = ["--nobazel_patch_module_resolver"],${additionalAttributes(pkg, name)}
)
`;
}
Expand Down Expand Up @@ -1104,7 +1105,8 @@ def ${name.replace(/-/g, '_')}(**kwargs):
nodejs_binary(
entry_point = "@${WORKSPACE}//:node_modules/${pkg._dir}/${path}",
data = [${data.map(p => `"${p}"`).join(', ')}] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),${additionalAttributes(pkg, name)}
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),${
additionalAttributes(pkg, name)}
**kwargs
)
Expand All @@ -1113,7 +1115,8 @@ def ${name.replace(/-/g, '_')}_test(**kwargs):
nodejs_test(
entry_point = "@${WORKSPACE}//:node_modules/${pkg._dir}/${path}",
data = [${data.map(p => `"${p}"`).join(', ')}] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),${additionalAttributes(pkg, name)}
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),${
additionalAttributes(pkg, name)}
**kwargs
)
`;
Expand Down
7 changes: 4 additions & 3 deletions internal/npm_install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ function printPackageBin(pkg) {
nodejs_binary(
name = "${name}",
entry_point = "//:node_modules/${pkg._dir}/${path}",
data = [${data.map(p => `"${p}"`).join(', ')}],${additionalAttributes(pkg, name)}
data = [${data.map(p => `"${p}"`).join(', ')}],
templated_args = ["--nobazel_patch_module_resolver"],${additionalAttributes(pkg, name)}
)
`;
}
Expand Down Expand Up @@ -673,7 +674,7 @@ def ${name.replace(/-/g, '_')}(**kwargs):
nodejs_binary(
entry_point = "@${WORKSPACE}//:node_modules/${pkg._dir}/${path}",
data = [${data.map(p => `"${p}"`).join(', ')}] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),${additionalAttributes(pkg, name)}
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),${additionalAttributes(pkg, name)}
**kwargs
)
Expand All @@ -682,7 +683,7 @@ def ${name.replace(/-/g, '_')}_test(**kwargs):
nodejs_test(
entry_point = "@${WORKSPACE}//:node_modules/${pkg._dir}/${path}",
data = [${data.map(p => `"${p}"`).join(', ')}] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),${additionalAttributes(pkg, name)}
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),${additionalAttributes(pkg, name)}
**kwargs
)
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ nodejs_binary(
name = "test",
entry_point = "//:node_modules/@gregmagolan/test-a/@bin/test.js",
data = ["//@gregmagolan/test-a:test-a"],
templated_args = ["--nobazel_patch_module_resolver"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def test(**kwargs):
nodejs_binary(
entry_point = "@fine_grained_goldens//:node_modules/@gregmagolan/test-a/@bin/test.js",
data = ["@fine_grained_goldens//@gregmagolan/test-a:test-a"] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),
**kwargs
)
def test_test(**kwargs):
nodejs_test(
entry_point = "@fine_grained_goldens//:node_modules/@gregmagolan/test-a/@bin/test.js",
data = ["@fine_grained_goldens//@gregmagolan/test-a:test-a"] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),
**kwargs
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ nodejs_binary(
name = "jasmine",
entry_point = "//:node_modules/jasmine/bin/jasmine.js",
data = ["//jasmine:jasmine"],
templated_args = ["--nobazel_patch_module_resolver"],
)
4 changes: 2 additions & 2 deletions internal/npm_install/test/golden/jasmine/index.bzl.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def jasmine(**kwargs):
nodejs_binary(
entry_point = "@fine_grained_goldens//:node_modules/jasmine/bin/jasmine.js",
data = ["@fine_grained_goldens//jasmine:jasmine"] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),
**kwargs
)
def jasmine_test(**kwargs):
nodejs_test(
entry_point = "@fine_grained_goldens//:node_modules/jasmine/bin/jasmine.js",
data = ["@fine_grained_goldens//jasmine:jasmine"] + kwargs.pop("data", []),
templated_args = kwargs.pop("templated_args", []),
templated_args = ["--nobazel_patch_module_resolver"] + kwargs.pop("templated_args", []),
**kwargs
)
1 change: 1 addition & 0 deletions internal/pkg_npm/test/directory/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ nodejs_test(
":folder_pkg",
],
entry_point = "main.js",
templated_args = ["--nobazel_patch_module_resolver"],
)
1 change: 1 addition & 0 deletions internal/pkg_npm/test/linking/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ nodejs_test(
"//internal/pkg_npm/test/linking/fuz:scoped_fuz",
],
entry_point = ":main.js",
templated_args = ["--nobazel_patch_module_resolver"],
)
5 changes: 5 additions & 0 deletions internal/providers/node_runtime_deps_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ def run_node(ctx, inputs, arguments, executable, **kwargs):
add_arg(arguments, "--bazel_capture_exit_code=%s" % exit_code_file.path)
outputs = outputs + [exit_code_file]

# By using the run_node helper, you suggest that your program
# doesn't implicitly use runfiles to require() things
# To access runfiles, you must use a runfiles helper in the program instead
add_arg(arguments, "--nobazel_patch_module_resolver")

env = kwargs.pop("env", {})

# Always forward the COMPILATION_MODE to node process as an environment variable
Expand Down
2 changes: 2 additions & 0 deletions packages/cypress/internal/template.cypress_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def cypress_web_test(
] + srcs,
entry_point = "@build_bazel_rules_nodejs//packages/cypress:internal/run-cypress.js",
templated_args = [
"--nobazel_patch_module_resolver",
"$(rootpath {config_file})".format(config_file = config_file),
"$(rootpath {cypress_plugin})".format(cypress_plugin = cypress_plugin),
"$(rootpath {cypress_archive})".format(cypress_archive = cypress_archive),
Expand Down Expand Up @@ -153,6 +154,7 @@ def cypress_web_test_global_cache(
] + srcs,
entry_point = "@build_bazel_rules_nodejs//packages/cypress:internal/run-cypress.js",
templated_args = [
"--nobazel_patch_module_resolver",
"$(rootpath {config_file})".format(config_file = config_file),
"$(rootpath {cypress_plugin})".format(cypress_plugin = cypress_plugin),
] + templated_args,
Expand Down
1 change: 0 additions & 1 deletion packages/labs/test/protobufjs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ protobufjs_ts_library(
jasmine_node_test(
name = "protobuf_test",
srcs = [":test"],
#templated_args = ["--bazel_patch_module_resolver"],
deps = [
"@npm//protobufjs",
],
Expand Down
1 change: 1 addition & 0 deletions packages/rollup/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ nodejs_binary(
data = ["@npm//rollup:rollup"],
entry_point = "@npm//:node_modules/rollup/dist/bin/rollup",
templated_args = [
"--nobazel_patch_module_resolver",
"--node_options=--max-old-space-size=<SOME_SIZE>",
],
)
Expand Down
1 change: 1 addition & 0 deletions packages/typescript/internal/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def ts_project_macro(
],
entry_point = Label("//packages/typescript/internal/worker:worker_adapter"),
templated_args = [
"--nobazel_patch_module_resolver",
"$(execpath {})".format(Label(worker_tsc_bin)),
"--project",
"$(execpath {})".format(tsconfig),
Expand Down
3 changes: 2 additions & 1 deletion packages/typescript/test/some_module/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ nodejs_binary(

# custom rule using the executable above via run_node
# invoked via bazel build //packages/typescript/test/some_module:test
# the entry_point on the executable is resolved to the ts file - writer.ts
# as --nobazel_patch_module_resolver is added by default by run_node, the entry_point on the executable is resolved
# to the ts file - writer.ts
# this works for bazel run //packages/typescript/test/some_module:writer_bin as this will patch require and resolve the
# ts to js
ts_write_file(
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/test/ts_project/a/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// (05:54:49) ERROR: C:/b/bk-windows-b4qr/bazel/rules-nodejs-nodejs/packages/typescript/test/ts_project/b/BUILD.bazel:6:1: Compiling TypeScript project packages/typescript/test/ts_project/b/tsconfig.json failed (Exit 2): tsc.bat failed: error executing command
// cd C:/b/uuxnwop3/execroot/build_bazel_rules_nodejs
// SET COMPILATION_MODE=fastbuild
// bazel-out/host/bin/external/npm/typescript/bin/tsc.bat -p packages/typescript/test/ts_project/b/tsconfig.json --outDir bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/b --declarationDir bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/b --bazel_node_modules_manifest=bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/b/_tsconfig.module_mappings.json
// bazel-out/host/bin/external/npm/typescript/bin/tsc.bat -p packages/typescript/test/ts_project/b/tsconfig.json --outDir bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/b --declarationDir bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/b --bazel_node_modules_manifest=bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/b/_tsconfig.module_mappings.json --nobazel_patch_module_resolver
// Execution platform: @local_config_platform//:host
// packages/typescript/test/ts_project/b/b.ts(1,17): error TS6305: Output file 'C:/b/uuxnwop3/execroot/build_bazel_rules_nodejs/packages/typescript/test/ts_project/a/a.d.ts' has not been built from source file 'C:/b/uuxnwop3/execroot/build_bazel_rules_nodejs/packages/typescript/test/ts_project/a/a.ts'.
"outDir": "../../../../../bazel-out/x64_windows-fastbuild/bin/packages/typescript/test/ts_project/a",
}
}
}

0 comments on commit d0b08d5

Please sign in to comment.