Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js_run_devserver symlinks scoped node_modules to bazel-out instead of runfiles (unscoped node_modules are already linked to bazel-out) #1210

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8ad47df
js_run_devserver symlinks scoped node_modules to bazel-out instead of…
gregjacobs Aug 12, 2023
11c3c07
Add test which confirms the single node_modules tree
gregjacobs Aug 13, 2023
00a11f6
Little cleanup
gregjacobs Aug 13, 2023
0e96e51
Simplify test script, exit test even if server still has connections
gregjacobs Aug 13, 2023
b91d243
Clarify comment
gregjacobs Aug 13, 2023
beea654
Move tests to Jasmine, add explicit symlink tests
gregjacobs Aug 13, 2023
faee925
Simplify tests to just the symlink tests
gregjacobs Aug 15, 2023
3031b4d
Add js_run_devserver_internal to keep original js_run_devserver API t…
gregjacobs Aug 16, 2023
1143663
Dedicate test target specifically to the node_modules symlinks
gregjacobs Aug 16, 2023
be90ef0
Identifier name fix
gregjacobs Aug 16, 2023
3d58e0f
Second identifier name fix in test
gregjacobs Aug 16, 2023
3425c75
Fix docs
gregjacobs Aug 16, 2023
cb11c40
Fix macro for docs update
gregjacobs Aug 16, 2023
57a23f8
Update npm/private/test/repositories_checked.bzl - fixes test
gregjacobs Aug 16, 2023
d4dd118
Buildifier fix for js_run_devserver_test.bzl
gregjacobs Aug 17, 2023
4c5326c
Use 'tool' instead of 'command' for js_run_devserver_test
gregjacobs Aug 17, 2023
cc616ae
Workaround for "js_run_devserver_internal() got multiple values for p…
gregjacobs Aug 17, 2023
5eef3a4
Slight comment tweak
gregjacobs Aug 17, 2023
3b1d5f4
Remove unnecessary js_run_devserver_internal macro
gregmagolan Aug 17, 2023
f682ea0
Turns out still need to scope stardoc with the symbol name to avoid p…
gregmagolan Aug 17, 2023
c19b23b
Update docs
gregmagolan Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add js_run_devserver_internal to keep original js_run_devserver API t…
…he same
  • Loading branch information
gregjacobs committed Aug 16, 2023
commit 3031b4d8f47e1e8c937d2050d736c154b13e23b2
24 changes: 17 additions & 7 deletions js/private/js_run_devserver.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ _js_run_devserver = rule(

def js_run_devserver(
name,
tool = None,
command = None,
grant_sandbox_write_permissions = False,
use_execroot_entry_point = True,
allow_execroot_entry_point_with_no_copy_data_to_bin = False,
js_run_devserver_rule = _js_run_devserver,
**kwargs):
"""Runs a devserver via binary target or command.

Expand Down Expand Up @@ -241,10 +235,26 @@ def js_run_devserver(

See https://docs.aspect.build/rules/aspect_rules_js/docs/js_binary
"""
js_run_devserver_internal(
name,
rule_to_execute = _js_run_devserver,
**kwargs,
)

def js_run_devserver_internal(
name,
rule_to_execute,
tool = None,
command = None,
grant_sandbox_write_permissions = False,
use_execroot_entry_point = True,
allow_execroot_entry_point_with_no_copy_data_to_bin = False,
**kwargs):

if kwargs.get("entry_point", None):
fail("`entry_point` is set implicitly by `js_run_devserver` and cannot be overridden.")

js_run_devserver_rule(
rule_to_execute(
name = name,
enable_runfiles = select({
"@aspect_rules_js//js:enable_runfiles": True,
Expand Down
9 changes: 4 additions & 5 deletions js/private/test/js_run_devserver/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ load(":js_run_devserver_test.bzl", "js_run_devserver_test")

npm_link_all_packages(name = "node_modules")

# Test that bundlers see a single node_modules tree.
# https://github.com/aspect-build/rules_js/issues/1204
js_run_devserver_test(
name = "js_run_devserver_test",
args = ["*.spec.mjs"],
chdir = "js/private/test/js_run_devserver",
command = "./node_modules/.bin/jasmine",
args = ["*.spec.mjs"],
data = glob(["*.spec.mjs"]) + [
# Some packages to link back to the exec root for the tests (and need jasmine anyway)
# Some packages to link back to the exec root for the tests for
# https://github.com/aspect-build/rules_js/issues/1204 (and need jasmine
# anyway for the runner)
":node_modules/@types/node",
":node_modules/jasmine",
],
)

6 changes: 3 additions & 3 deletions js/private/test/js_run_devserver/js_run_devserver_test.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//js/private:js_run_devserver.bzl", "js_run_devserver", "js_run_devserver_lib")
load("//js/private:js_run_devserver.bzl", "js_run_devserver_internal", "js_run_devserver_lib")

# 'test' version of the _js_run_devserver` rule
_js_run_devserver_test = rule(
Expand Down Expand Up @@ -26,9 +26,9 @@ def js_run_devserver_test(

See https://docs.aspect.build/rules/aspect_rules_js/docs/js_run_devserver
"""
js_run_devserver(
js_run_devserver_internal(
name,
js_run_devserver_rule = _js_run_devserver_test,
rule_to_execute = _js_run_devserver_test,
# 'no-sandbox' needed to simulate 'bazel run' command - normally tests
# are sandboxed, but sandboxing doesn't exhibit the issue in
# https://github.com/aspect-build/rules_js/issues/1204
Expand Down