Skip to content

Commit 68238af

Browse files
author
Alex Eagle
committed
chore: add rules_sass patch for downstream projects
1 parent 724dd80 commit 68238af

File tree

8 files changed

+40
-15
lines changed

8 files changed

+40
-15
lines changed

BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pkg_npm(
7979
srcs = glob(["*.bzl"]) + [
8080
"BUILD.bazel",
8181
"LICENSE",
82+
"rules_sass.pr126.patch",
8283
],
8384
substitutions = COMMON_REPLACEMENTS,
8485
deps = [

e2e/packages/BUILD.bazel

+16-8
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ VARIANTS = [
2020
],
2121
entry_point = ":%s.spec.js" % variant,
2222
node_modules = "@e2e_packages_" + variant + "//:node_modules",
23-
# On Windows, the yarn and npm variants fight over who creates the link
24-
# [link_node_modules.js] [Error: EEXIST: file already exists, mkdir 'C:\users\b\_bazel_b\p4se2lwa\execroot\e2e_packages\node_modules'] {
25-
# errno: -4075,
26-
# code: 'EEXIST',
27-
# syscall: 'mkdir',
28-
# path: 'C:\\users\\b\\_bazel_b\\p4se2lwa\\execroot\\e2e_packages\\node_modules'
29-
# }
30-
templated_args = ["--nobazel_run_linker"],
23+
templated_args = [
24+
# TODO: use runfiles
25+
"--bazel_patch_module_resolver",
26+
# On Windows, the yarn and npm variants fight over who creates the link
27+
# [link_node_modules.js] [Error: EEXIST: file already exists, mkdir 'C:\users\b\_bazel_b\p4se2lwa\execroot\e2e_packages\node_modules'] {
28+
# errno: -4075,
29+
# code: 'EEXIST',
30+
# syscall: 'mkdir',
31+
# path: 'C:\\users\\b\\_bazel_b\\p4se2lwa\\execroot\\e2e_packages\\node_modules'
32+
# }
33+
"--nobazel_run_linker",
34+
],
3135
) for variant in VARIANTS]
3236

3337
nodejs_test(
@@ -40,6 +44,8 @@ nodejs_test(
4044
node_modules = "@e2e_packages_npm_install_duplicate_for_determinism_testing//:node_modules",
4145
# TODO(gregmagolan): fix this test on windows
4246
tags = ["fix-windows"],
47+
# TODO: use runfiles
48+
templated_args = ["--bazel_patch_module_resolver"],
4349
)
4450

4551
nodejs_test(
@@ -52,4 +58,6 @@ nodejs_test(
5258
node_modules = "@e2e_packages_yarn_install_duplicate_for_determinism_testing//:node_modules",
5359
# TODO(gregmagolan): fix this test on windows
5460
tags = ["fix-windows"],
61+
# TODO: use runfiles
62+
templated_args = ["--bazel_patch_module_resolver"],
5563
)

e2e/typescript/BUILD.bazel

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ jasmine_node_test(
6060
# Verify that worker_protocol.proto can be referenced as a target in the generated npm bazel workspace
6161
"@npm//@bazel/typescript/third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto",
6262
],
63-
templated_args = ["--node_options=--require=$$(rlocation $(rootpath chdir.js))"],
63+
templated_args = [
64+
# ts_library produces named AMD output with repo name in the require statement
65+
"--bazel_patch_module_resolver",
66+
"--node_options=--require=$$(rlocation $(rootpath chdir.js))",
67+
],
6468
deps = [
6569
":test_lib",
6670
],

examples/angular/WORKSPACE

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ http_archive(
3636
# Fetch sass rules for compiling sass files
3737
http_archive(
3838
name = "io_bazel_rules_sass",
39+
patch_args = ["-p1"],
40+
patches = ["@build_bazel_rules_nodejs//:rules_sass.pr126.patch"],
3941
sha256 = "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647",
4042
strip_prefix = "rules_sass-1.25.0",
4143
urls = [

examples/angular/tools/angular_prerender.bzl

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ def ng_prerender(name, index, prerender_roots = [], **kwargs):
4646
"@npm//reflect-metadata",
4747
],
4848
entry_point = "//src:prerender.ts",
49-
templated_args = ["--nobazel_run_linker"],
49+
templated_args = [
50+
# Due to not using linker, we need the patched require() function
51+
"--bazel_patch_module_resolver",
52+
"--nobazel_run_linker",
53+
],
5054
)
5155

5256
root_at = "_prerender/" + native.package_name()

examples/angular_view_engine/WORKSPACE

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ http_archive(
2323
# Fetch sass rules for compiling sass files
2424
http_archive(
2525
name = "io_bazel_rules_sass",
26+
patch_args = ["-p1"],
27+
patches = ["@build_bazel_rules_nodejs//:rules_sass.pr126.patch"],
2628
sha256 = "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647",
2729
strip_prefix = "rules_sass-1.25.0",
2830
urls = [

packages/jasmine/test/BUILD.bazel

+4
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ jasmine_node_test(
127127
"dynamic_import.js",
128128
],
129129
args = [
130+
# TODO: investigate why this fails without the patched require() function
131+
"--bazel_patch_module_resolver",
130132
# the --node_options arg will be consumed by the node launcher
131133
"--node_options=--experimental-modules",
132134
# the remaining args should be passed to the spec
@@ -147,6 +149,8 @@ jasmine_node_test(
147149
"arg3",
148150
],
149151
templated_args = [
152+
# TODO: investigate why this fails without the patched require() function
153+
"--bazel_patch_module_resolver",
150154
# the --node_options templated arg will be consumed by the node launcher
151155
"--node_options=--experimental-modules",
152156
# the remaining args should be passed to the spec

packages/protractor/protractor.conf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ if (onPreparePath) {
105105
setConf(conf, 'framework', 'jasmine2', 'is set to jasmine2');
106106

107107
const specs =
108-
[TMPL_specs].map(s => require.resolve(s)).filter(s => /(\b|_)(spec|test)\.js$/.test(s));
108+
[TMPL_specs].map(s => runfiles.resolve(s)).filter(s => /(\b|_)(spec|test)\.js$/.test(s));
109109

110110
setConf(conf, 'specs', specs, 'are determined by the srcs and deps attribute');
111111

112112
// WEB_TEST_METADATA is configured in rules_webtesting based on value
113113
// of the browsers attribute passed to karma_web_test_suite
114114
// We setup the protractor configuration based on the values in this object
115115
if (process.env['WEB_TEST_METADATA']) {
116-
const webTestMetadata = require(process.env['WEB_TEST_METADATA']);
116+
const webTestMetadata = require(runfiles.resolve(process.env['WEB_TEST_METADATA']));
117117
log_verbose(`WEB_TEST_METADATA: ${JSON.stringify(webTestMetadata, null, 2)}`);
118118
if (webTestMetadata['environment'] === 'local') {
119119
// When a local chrome or firefox browser is chosen such as
@@ -124,8 +124,8 @@ if (process.env['WEB_TEST_METADATA']) {
124124
const webTestNamedFiles = webTestMetadata['webTestFiles'][0]['namedFiles'];
125125
const headless = !process.env['DISPLAY'];
126126
if (webTestNamedFiles['CHROMIUM']) {
127-
const chromeBin = require.resolve(webTestNamedFiles['CHROMIUM']);
128-
const chromeDriver = require.resolve(webTestNamedFiles['CHROMEDRIVER']);
127+
const chromeBin = runfiles.resolve(webTestNamedFiles['CHROMIUM']);
128+
const chromeDriver = runfiles.resolve(webTestNamedFiles['CHROMEDRIVER']);
129129

130130
// The sandbox needs to be disabled, because it causes Chrome to crash on some environments.
131131
// See: http://chromedriver.chromium.org/help/chrome-doesn-t-start
@@ -147,7 +147,7 @@ if (process.env['WEB_TEST_METADATA']) {
147147
// TODO(gmagolan): implement firefox support for protractor
148148
throw new Error('Firefox not yet support by protractor_web_test_suite');
149149

150-
// const firefoxBin = require.resolve(webTestNamedFiles['FIREFOX'])
150+
// const firefoxBin = runfiles.resolve(webTestNamedFiles['FIREFOX'])
151151
// const args = [];
152152
// if (headless) {
153153
// args.push("--headless")

0 commit comments

Comments
 (0)