diff --git a/BUILD.bazel b/BUILD.bazel index 67fb6217d3..bbeddef661 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -79,6 +79,7 @@ pkg_npm( srcs = glob(["*.bzl"]) + [ "BUILD.bazel", "LICENSE", + "rules_sass.pr126.patch", ], substitutions = COMMON_REPLACEMENTS, deps = [ diff --git a/e2e/packages/BUILD.bazel b/e2e/packages/BUILD.bazel index 8af7845a75..db892369c1 100644 --- a/e2e/packages/BUILD.bazel +++ b/e2e/packages/BUILD.bazel @@ -20,14 +20,18 @@ VARIANTS = [ ], entry_point = ":%s.spec.js" % variant, node_modules = "@e2e_packages_" + variant + "//:node_modules", - # On Windows, the yarn and npm variants fight over who creates the link - # [link_node_modules.js] [Error: EEXIST: file already exists, mkdir 'C:\users\b\_bazel_b\p4se2lwa\execroot\e2e_packages\node_modules'] { - # errno: -4075, - # code: 'EEXIST', - # syscall: 'mkdir', - # path: 'C:\\users\\b\\_bazel_b\\p4se2lwa\\execroot\\e2e_packages\\node_modules' - # } - templated_args = ["--nobazel_run_linker"], + templated_args = [ + # TODO: use runfiles + "--bazel_patch_module_resolver", + # On Windows, the yarn and npm variants fight over who creates the link + # [link_node_modules.js] [Error: EEXIST: file already exists, mkdir 'C:\users\b\_bazel_b\p4se2lwa\execroot\e2e_packages\node_modules'] { + # errno: -4075, + # code: 'EEXIST', + # syscall: 'mkdir', + # path: 'C:\\users\\b\\_bazel_b\\p4se2lwa\\execroot\\e2e_packages\\node_modules' + # } + "--nobazel_run_linker", + ], ) for variant in VARIANTS] nodejs_test( @@ -40,6 +44,8 @@ nodejs_test( node_modules = "@e2e_packages_npm_install_duplicate_for_determinism_testing//:node_modules", # TODO(gregmagolan): fix this test on windows tags = ["fix-windows"], + # TODO: use runfiles + templated_args = ["--bazel_patch_module_resolver"], ) nodejs_test( @@ -52,4 +58,6 @@ nodejs_test( node_modules = "@e2e_packages_yarn_install_duplicate_for_determinism_testing//:node_modules", # TODO(gregmagolan): fix this test on windows tags = ["fix-windows"], + # TODO: use runfiles + templated_args = ["--bazel_patch_module_resolver"], ) diff --git a/e2e/typescript/BUILD.bazel b/e2e/typescript/BUILD.bazel index 74765faa99..d907ca13ed 100644 --- a/e2e/typescript/BUILD.bazel +++ b/e2e/typescript/BUILD.bazel @@ -60,7 +60,11 @@ jasmine_node_test( # 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 = ["--node_options=--require=$$(rlocation $(rootpath chdir.js))"], + 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", ], diff --git a/examples/angular/WORKSPACE b/examples/angular/WORKSPACE index 1a91a10a9c..c000a59994 100644 --- a/examples/angular/WORKSPACE +++ b/examples/angular/WORKSPACE @@ -36,6 +36,8 @@ http_archive( # Fetch sass rules for compiling sass files http_archive( name = "io_bazel_rules_sass", + patch_args = ["-p1"], + patches = ["@build_bazel_rules_nodejs//:rules_sass.pr126.patch"], sha256 = "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647", strip_prefix = "rules_sass-1.25.0", urls = [ diff --git a/examples/angular/tools/angular_prerender.bzl b/examples/angular/tools/angular_prerender.bzl index 080758fc95..d4e1f2a4b7 100644 --- a/examples/angular/tools/angular_prerender.bzl +++ b/examples/angular/tools/angular_prerender.bzl @@ -46,7 +46,11 @@ def ng_prerender(name, index, prerender_roots = [], **kwargs): "@npm//reflect-metadata", ], entry_point = "//src:prerender.ts", - templated_args = ["--nobazel_run_linker"], + templated_args = [ + # Due to not using linker, we need the patched require() function + "--bazel_patch_module_resolver", + "--nobazel_run_linker", + ], ) root_at = "_prerender/" + native.package_name() diff --git a/examples/angular_view_engine/WORKSPACE b/examples/angular_view_engine/WORKSPACE index 867e54a655..f70cbb59e2 100644 --- a/examples/angular_view_engine/WORKSPACE +++ b/examples/angular_view_engine/WORKSPACE @@ -23,6 +23,8 @@ http_archive( # Fetch sass rules for compiling sass files http_archive( name = "io_bazel_rules_sass", + patch_args = ["-p1"], + patches = ["@build_bazel_rules_nodejs//:rules_sass.pr126.patch"], sha256 = "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647", strip_prefix = "rules_sass-1.25.0", urls = [ diff --git a/packages/jasmine/test/BUILD.bazel b/packages/jasmine/test/BUILD.bazel index 3799b50059..8673c278ca 100644 --- a/packages/jasmine/test/BUILD.bazel +++ b/packages/jasmine/test/BUILD.bazel @@ -127,6 +127,8 @@ jasmine_node_test( "dynamic_import.js", ], args = [ + # TODO: investigate why this fails without the patched require() function + "--bazel_patch_module_resolver", # the --node_options arg will be consumed by the node launcher "--node_options=--experimental-modules", # the remaining args should be passed to the spec @@ -147,6 +149,8 @@ jasmine_node_test( "arg3", ], templated_args = [ + # TODO: investigate why this fails without the patched require() function + "--bazel_patch_module_resolver", # the --node_options templated arg will be consumed by the node launcher "--node_options=--experimental-modules", # the remaining args should be passed to the spec diff --git a/packages/protractor/protractor.conf.js b/packages/protractor/protractor.conf.js index c0f5be11f6..897cf48f90 100644 --- a/packages/protractor/protractor.conf.js +++ b/packages/protractor/protractor.conf.js @@ -105,7 +105,7 @@ if (onPreparePath) { setConf(conf, 'framework', 'jasmine2', 'is set to jasmine2'); const specs = - [TMPL_specs].map(s => require.resolve(s)).filter(s => /(\b|_)(spec|test)\.js$/.test(s)); + [TMPL_specs].map(s => runfiles.resolve(s)).filter(s => /(\b|_)(spec|test)\.js$/.test(s)); setConf(conf, 'specs', specs, 'are determined by the srcs and deps attribute'); @@ -113,7 +113,7 @@ setConf(conf, 'specs', specs, 'are determined by the srcs and deps attribute'); // of the browsers attribute passed to karma_web_test_suite // We setup the protractor configuration based on the values in this object if (process.env['WEB_TEST_METADATA']) { - const webTestMetadata = require(process.env['WEB_TEST_METADATA']); + const webTestMetadata = require(runfiles.resolve(process.env['WEB_TEST_METADATA'])); log_verbose(`WEB_TEST_METADATA: ${JSON.stringify(webTestMetadata, null, 2)}`); if (webTestMetadata['environment'] === 'local') { // When a local chrome or firefox browser is chosen such as @@ -124,8 +124,8 @@ if (process.env['WEB_TEST_METADATA']) { const webTestNamedFiles = webTestMetadata['webTestFiles'][0]['namedFiles']; const headless = !process.env['DISPLAY']; if (webTestNamedFiles['CHROMIUM']) { - const chromeBin = require.resolve(webTestNamedFiles['CHROMIUM']); - const chromeDriver = require.resolve(webTestNamedFiles['CHROMEDRIVER']); + const chromeBin = runfiles.resolve(webTestNamedFiles['CHROMIUM']); + const chromeDriver = runfiles.resolve(webTestNamedFiles['CHROMEDRIVER']); // The sandbox needs to be disabled, because it causes Chrome to crash on some environments. // See: http://chromedriver.chromium.org/help/chrome-doesn-t-start @@ -147,7 +147,7 @@ if (process.env['WEB_TEST_METADATA']) { // TODO(gmagolan): implement firefox support for protractor throw new Error('Firefox not yet support by protractor_web_test_suite'); - // const firefoxBin = require.resolve(webTestNamedFiles['FIREFOX']) + // const firefoxBin = runfiles.resolve(webTestNamedFiles['FIREFOX']) // const args = []; // if (headless) { // args.push("--headless")