Skip to content

Commit

Permalink
feat: user’s workspace node_modules used by yarn_install & npm_install (
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored and alexeagle committed May 22, 2019
1 parent 3990186 commit 9d302bf
Show file tree
Hide file tree
Showing 91 changed files with 5,018 additions and 520 deletions.
3 changes: 3 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ packages/
# A subset of legacy e2e tests are nested workspaces
# TODO(gregmagolan): move these to /e2e
internal/e2e/bazel_workspaces_compat
internal/e2e/fine_grained_deps/npm/node_modules
internal/e2e/fine_grained_deps/yarn/node_modules
internal/e2e/fine_grained_no_bin/node_modules
internal/e2e/fine_grained_symlinks
internal/e2e/node_loader_no_preserve_symlinks
internal/e2e/node_loader_preserve_symlinks
Expand Down
5 changes: 5 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# If you change the `default_docker_image` version, also change the `cache_key` version
var_1: &default_docker_image circleci/node:10.12
var_2: &browsers_docker_image circleci/node:10.12-browsers
var_3: &cache_key node-0.12-{{ checksum "yarn.lock" }}-{{ checksum "examples/program/yarn.lock" }}-{{ checksum "internal/npm_install/test/package/yarn.lock" }}
var_3: &cache_key node-0.12-{{ checksum "yarn.lock" }}-{{ checksum "examples/program/yarn.lock" }}-{{ checksum "internal/npm_install/test/package/yarn.lock" }}-bust3

var_4: &init_environment
run:
Expand Down
33 changes: 9 additions & 24 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "build_bazel_rules_nodejs")
workspace(
name = "build_bazel_rules_nodejs",
managed_directories = {
"@fine_grained_deps_npm": ["internal/e2e/fine_grained_deps/npm/node_modules"],
"@fine_grained_deps_yarn": ["internal/e2e/fine_grained_deps/yarn/node_modules"],
"@fine_grained_no_bin": ["internal/e2e/fine_grained_no_bin/node_modules"],
"@npm": ["node_modules"],
},
)

load("//:package.bzl", "rules_nodejs_dev_dependencies")

Expand Down Expand Up @@ -64,29 +72,6 @@ node_repositories(

yarn_install(
name = "npm",
data = [
"@build_bazel_rules_nodejs//:tools/npm_packages/hello/index.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/hello/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index/index.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index_2/index.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index_2/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index_3/index.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index_3/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index_4/index.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_index_4/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_main/main.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_main/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_main_2/main.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_main_2/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_nested_main/nested/main.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_nested_main/nested/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/node_resolve_nested_main/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/test_workspace/BUILD.bazel",
"@build_bazel_rules_nodejs//:tools/npm_packages/test_workspace/index.js",
"@build_bazel_rules_nodejs//:tools/npm_packages/test_workspace/package.json",
"@build_bazel_rules_nodejs//:tools/npm_packages/test_workspace/subdir/BUILD.bazel",
"@build_bazel_rules_nodejs//:tools/npm_packages/test_workspace/subdir/index.js",
],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
Expand Down
5 changes: 5 additions & 0 deletions e2e/bazel_bin/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
9 changes: 4 additions & 5 deletions e2e/bazel_bin/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_bazel_bin")
workspace(
name = "e2e_bazel_bin",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand All @@ -23,10 +26,6 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

yarn_install(
name = "npm",
data = [
"@e2e_bazel_bin//:npm/testy/index.js",
"@e2e_bazel_bin//:npm/testy/package.json",
],
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
5 changes: 5 additions & 0 deletions e2e/define_var/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/define_var/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_define_var")
workspace(
name = "e2e_define_var",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
5 changes: 5 additions & 0 deletions e2e/jasmine/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/jasmine/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_jasmine")
workspace(
name = "e2e_jasmine",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
5 changes: 5 additions & 0 deletions e2e/karma/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/karma/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_karma")
workspace(
name = "e2e_karma",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
5 changes: 5 additions & 0 deletions e2e/karma_stack_trace/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/karma_stack_trace/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_karma_stack_trace")
workspace(
name = "e2e_karma_stack_trace",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
5 changes: 5 additions & 0 deletions e2e/karma_typescript/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/karma_typescript/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_karma_typescript")
workspace(
name = "e2e_karma_typescript",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
5 changes: 5 additions & 0 deletions e2e/ts_auto_deps/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
13 changes: 5 additions & 8 deletions e2e/ts_auto_deps/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_ts_auto_deps")
workspace(
name = "e2e_ts_auto_deps",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
path = "../../dist/build_bazel_rules_nodejs/release",
)

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

# This test depend on there being a user node_modules folder
# TODO(gregmagolan): remove this once yarn_install sets up the user's node_modules folder
node_repositories(
package_json = ["//:package.json"],
)
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

yarn_install(
name = "npm",
Expand Down
5 changes: 5 additions & 0 deletions e2e/ts_devserver/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
13 changes: 5 additions & 8 deletions e2e/ts_devserver/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_ts_devserver")
workspace(
name = "e2e_ts_devserver",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
path = "../../dist/build_bazel_rules_nodejs/release",
)

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

# This test depend on there being a user node_modules folder
# TODO(gregmagolan): remove this once yarn_install sets up the user's node_modules folder
node_repositories(
package_json = ["//:package.json"],
)
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

yarn_install(
name = "npm",
Expand Down
5 changes: 5 additions & 0 deletions e2e/ts_library/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
34 changes: 19 additions & 15 deletions e2e/ts_library/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
workspace(name = "e2e_ts_library")
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(
name = "e2e_ts_library",
managed_directories = {"@npm": ["node_modules"]},
)

# In your code, you'd fetch this repository with an `http_archive` call.
# We do this local repository only because this example lives in the same
# repository with the rules_nodejs code and we want to test them together.
local_repository(
name = "build_bazel_rules_nodejs",
path = "../../dist/build_bazel_rules_nodejs/release",
)

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

# This test depend on there being a user node_modules folder
# TODO(gregmagolan): remove this once yarn_install sets up the user's node_modules folder
node_repositories(
package_json = ["//:package.json"],
)
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")

# This runs yarn install, then our generate_build_file.js to create BUILD files
# inside the resulting node_modules directory.
# The name "npm" here means the resulting modules are referenced like
# @npm//jasmine
yarn_install(
name = "npm",
package_json = "//:package.json",
Expand Down
14 changes: 14 additions & 0 deletions e2e/tsconfig_extends/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Print test logs for failed tests
test --test_output=errors

# Enable debugging tests with --config=debug
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results

# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/tsconfig_extends/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_tsconfig_extends")
workspace(
name = "e2e_tsconfig_extends",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
5 changes: 5 additions & 0 deletions e2e/typescript_2.7/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test
# Turn off legacy external runfiles
run --nolegacy_external_runfiles
test --nolegacy_external_runfiles

# Turn on managed_directories
build --experimental_allow_incremental_repository_updates
test --experimental_allow_incremental_repository_updates
run --experimental_allow_incremental_repository_updates
5 changes: 4 additions & 1 deletion e2e/typescript_2.7/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "e2e_typescript_2_7")
workspace(
name = "e2e_typescript_2_7",
managed_directories = {"@npm": ["node_modules"]},
)

local_repository(
name = "build_bazel_rules_nodejs",
Expand Down
Loading

0 comments on commit 9d302bf

Please sign in to comment.