Skip to content

Commit

Permalink
chore: add rules_sass patch for downstream projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eagle committed Dec 9, 2020
1 parent f70ae45 commit 6bf8ae7
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 16 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pkg_npm(
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
"LICENSE",
"rules_sass.pr126.patch",
],
substitutions = COMMON_REPLACEMENTS,
deps = [
Expand Down
24 changes: 16 additions & 8 deletions e2e/packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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"],
)
6 changes: 5 additions & 1 deletion e2e/typescript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
2 changes: 2 additions & 0 deletions examples/angular/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 5 additions & 1 deletion examples/angular/tools/angular_prerender.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions examples/angular_view_engine/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
6 changes: 5 additions & 1 deletion examples/kotlin/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@ jasmine_node_test(
":bundle",
"@npm//domino",
],
templated_args = ["--node_options=--experimental-modules"],
templated_args = [
# TODO: don't rely on patching require()
"--bazel_patch_module_resolver",
"--node_options=--experimental-modules",
],
)
4 changes: 4 additions & 0 deletions packages/jasmine/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/protractor/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ 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');

// WEB_TEST_METADATA is configured in rules_webtesting based on value
// 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
Expand All @@ -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
Expand All @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions packages/protractor/protractor_web_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def protractor_web_test(
entry_point = Label(protractor_entry_point),
data = srcs + deps + data + [Label(d) for d in peer_deps],
testonly = 1,
# TODO: make protractor binary not depend on monkey-patched require()
templated_args = ["--bazel_patch_module_resolver"],
visibility = ["//visibility:private"],
)

Expand Down

0 comments on commit 6bf8ae7

Please sign in to comment.